mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 03:40:11 +01:00
chore: move checks before command is procesed
This commit is contained in:
@@ -85,6 +85,29 @@ def mcquote_command():
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
# Check if bot has send messages permission before starting quote generation
|
||||
try:
|
||||
test_embed = discord.Embed(title="Testing permissions...", color=0x7289DA)
|
||||
test_embed.set_author(name="Media", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
||||
await context.channel.send(embed=test_embed, delete_after=0.1)
|
||||
except discord.Forbidden:
|
||||
embed = discord.Embed(
|
||||
title="Permission Error",
|
||||
description="The bot needs the `send messages` permission to execute this command.",
|
||||
color=0xE02B2B,
|
||||
)
|
||||
embed.set_author(name="Media", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
||||
|
||||
interaction = getattr(context, "interaction", None)
|
||||
if interaction is not None:
|
||||
if not interaction.response.is_done():
|
||||
await interaction.response.send_message(embed=embed, ephemeral=True)
|
||||
else:
|
||||
await interaction.followup.send(embed=embed, ephemeral=True)
|
||||
else:
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
|
||||
processing_embed = discord.Embed(
|
||||
title="Minecraft Quote (Processing)",
|
||||
description="<a:mariospin:1423677027013103709> Generating quote... This may take a moment.",
|
||||
@@ -127,36 +150,16 @@ def mcquote_command():
|
||||
|
||||
interaction = getattr(context, "interaction", None)
|
||||
if interaction is not None:
|
||||
await context.channel.send(embed=embed)
|
||||
await context.channel.send(file=file)
|
||||
try:
|
||||
await context.channel.send(embed=embed)
|
||||
await context.channel.send(file=file)
|
||||
try:
|
||||
await interaction.delete_original_response()
|
||||
except:
|
||||
pass
|
||||
except discord.Forbidden:
|
||||
embed = discord.Embed(
|
||||
title="Permission Error",
|
||||
description="The bot needs the `send messages` permission to execute this command.",
|
||||
color=0xE02B2B,
|
||||
)
|
||||
embed.set_author(name="Media", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
||||
await interaction.followup.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
await interaction.delete_original_response()
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
await processing_msg.delete()
|
||||
await context.channel.send(embed=embed)
|
||||
await context.channel.send(file=file)
|
||||
except discord.Forbidden:
|
||||
embed = discord.Embed(
|
||||
title="Permission Error",
|
||||
description="The bot needs the `send messages` permission to execute this command.",
|
||||
color=0xE02B2B,
|
||||
)
|
||||
embed.set_author(name="Media", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
||||
await context.send(embed=embed, ephemeral=True)
|
||||
return
|
||||
await processing_msg.delete()
|
||||
await context.channel.send(embed=embed)
|
||||
await context.channel.send(file=file)
|
||||
|
||||
os.remove(temp_file_path)
|
||||
except aiohttp.ClientError:
|
||||
|
||||
Reference in New Issue
Block a user