Trying to handle open commands better
This commit is contained in:
parent
a4b287d117
commit
dcc1d96390
@ -40,18 +40,13 @@ class Recruitment(commands.Cog):
|
|||||||
|
|
||||||
@commands.group(name="application", usage="[text]", invoke_without_command=True)
|
@commands.group(name="application", usage="[text]", invoke_without_command=True)
|
||||||
async def application(self, ctx: commands.Context, *, _application: str = ""):
|
async def application(self, ctx: commands.Context, *, _application: str = ""):
|
||||||
guild_id = await self.config.guild(ctx.guild).guild_id()
|
guild_id = await self.get_guild_id(ctx)
|
||||||
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 = discord.utils.get(self.bot.guilds, id=guild_id)
|
guild = discord.utils.get(self.bot.guilds, id=guild_id)
|
||||||
if guild is None:
|
if guild is None:
|
||||||
await ctx.send(f"The guild with ID {guild_id} could not be found.")
|
await ctx.send(f"The guild with ID {guild_id} could not be found.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
author = ctx.author
|
||||||
if author.guild != guild:
|
if author.guild != guild:
|
||||||
await ctx.send(f"You need to be in the {guild.name} server to submit an application.")
|
await ctx.send(f"You need to be in the {guild.name} server to submit an application.")
|
||||||
return
|
return
|
||||||
@ -61,17 +56,20 @@ class Recruitment(commands.Cog):
|
|||||||
|
|
||||||
async def get_guild_id(self, ctx: commands.Context) -> int:
|
async def get_guild_id(self, ctx: commands.Context) -> int:
|
||||||
guild_id = await self.config.guild(ctx.guild).guild_id()
|
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
|
return guild_id
|
||||||
|
|
||||||
async def is_direct_message(self, ctx: commands.Context) -> bool:
|
async def is_direct_message(self, ctx: commands.Context) -> bool:
|
||||||
if not isinstance(ctx.channel, discord.DMChannel):
|
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 False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def interactive_application(self, author: discord.Member):
|
async def interactive_application(self, author: discord.Member):
|
||||||
"""Ask the user several questions to create an application."""
|
"""Ask the user several questions to create an application."""
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user