Kuby/commandes/sendbotmessages.py

29 lines
1.1 KiB
Python
Raw Normal View History

2026-01-01 18:48:25 +01:00
import discord
from discord import app_commands
from discord.ext import commands
class SentBotMessages(commands.Cog):
def __init__(self, bot):
self.bot = bot
@app_commands.command(name="sentbotmessages", description="Le bot envoie un message dans un salon choisi.")
@app_commands.describe(
message="Le message à envoyer",
salon="Le salon où envoyer le message"
)
async def sentbotmessages(self, interaction: discord.Interaction, message: str, salon: discord.TextChannel):
# 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))