Kuby/commandes/sendbotmessages.py

25 lines
1.2 KiB
Python
Executable file

import disnake
from disnake.ext import commands
class SentBotMessages(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.slash_command(name="sentbotmessages", description="Le bot envoie un message dans un salon choisi.")
async def sentbotmessages(self, interaction: disnake.ApplicationCommandInteraction,
message: str = commands.Param(description="Le message à envoyer"),
salon: disnake.TextChannel = commands.Param(description="Le salon où envoyer le message")):
# Vérifie si l'utilisateur est admin
if not interaction.user.guild_permissions.administrator:
await interaction.response.send_message("⛔ Tu n'as pas la permission d'utiliser cette commande.", ephemeral=True)
return
try:
await salon.send(message)
await interaction.response.send_message(f"✅ Message envoyé dans {salon.mention}.", ephemeral=True)
except Exception as e:
await interaction.response.send_message(f"❌ Une erreur est survenue : {e}", ephemeral=True)
async def setup(bot):
await bot.add_cog(SentBotMessages(bot))