From dcc1d96390228b76c9888c1ffa62caf6e0a937cd Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Mar 2023 18:44:48 +0100 Subject: [PATCH] Trying to handle open commands better --- recruitmentCog/recruitment.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/recruitmentCog/recruitment.py b/recruitmentCog/recruitment.py index a5c6573..7423f43 100644 --- a/recruitmentCog/recruitment.py +++ b/recruitmentCog/recruitment.py @@ -40,18 +40,13 @@ class Recruitment(commands.Cog): @commands.group(name="application", usage="[text]", invoke_without_command=True) async def application(self, ctx: commands.Context, *, _application: str = ""): - guild_id = await self.config.guild(ctx.guild).guild_id() - author = ctx.author - - if not guild_id: - await ctx.send("The guild has not been set. Please use the `setguild` command to set it.") - return - + guild_id = await self.get_guild_id(ctx) guild = discord.utils.get(self.bot.guilds, id=guild_id) if guild is None: await ctx.send(f"The guild with ID {guild_id} could not be found.") return + author = ctx.author if author.guild != guild: await ctx.send(f"You need to be in the {guild.name} server to submit an application.") return @@ -61,17 +56,20 @@ class Recruitment(commands.Cog): async def get_guild_id(self, ctx: commands.Context) -> int: guild_id = await self.config.guild(ctx.guild).guild_id() - if not guild_id: - await ctx.send("The guild has not been set. Please use the `setapplicationschannel` command to set it.") - return None return guild_id async def is_direct_message(self, ctx: commands.Context) -> bool: if not isinstance(ctx.channel, discord.DMChannel): - await ctx.send("This command can only be used in a direct message to the bot.") + try: + await ctx.message.delete() + except: + pass + await ctx.author.send("Please use this command in DM with me.") + await self.interactive_application(ctx.author) return False return True + async def interactive_application(self, author: discord.Member): """Ask the user several questions to create an application.""" embed = discord.Embed(