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:
Choco
2025-08-24 22:47:52 +08:00
parent 0e8b3ce9e7
commit 5c973a76b9
3 changed files with 15 additions and 8 deletions

12
main.py
View File

@@ -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: