Improve message handling and permission checks
Added a 'requires_fetch' parameter to the send function to ensure messages are fetched when needed. Enhanced command interaction checks to verify bot permissions for reading and sending messages in channels. Updated player controller logic to use the new fetch behavior for controller messages.
This commit is contained in:
12
main.py
12
main.py
@@ -193,10 +193,16 @@ class Vocard(commands.Bot):
|
||||
|
||||
class CommandCheck(discord.app_commands.CommandTree):
|
||||
async def interaction_check(self, interaction: discord.Interaction, /) -> bool:
|
||||
if not interaction.guild:
|
||||
await interaction.response.send_message("This command can only be used in guilds!")
|
||||
return False
|
||||
if interaction.type == discord.InteractionType.application_command:
|
||||
if not interaction.guild:
|
||||
await interaction.response.send_message("This command can only be used in guilds!")
|
||||
return False
|
||||
|
||||
channel_perm = interaction.channel.permissions_for(interaction.guild.me)
|
||||
if not channel_perm.read_messages or not channel_perm.send_messages:
|
||||
await interaction.response.send_message("I don't have permission to read or send messages in this channel.")
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
async def get_prefix(bot: commands.Bot, message: discord.Message) -> str:
|
||||
|
||||
Reference in New Issue
Block a user