Vicy_Publique/commandes/restranscription_staff.py
2026-08-16 19:37:15 +02:00

49 lines
No EOL
1.8 KiB
Python

import discord
from discord.ext import commands
from discord import app_commands
class RestranscriptionStaff(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_message(self, message):
# Ignorer les messages du bot lui-même
if message.author == self.bot.user:
return
# Ignorer les messages d'autres bots
if message.author.bot:
return
# Réceptionner les MPs
if isinstance(message.channel, discord.DMChannel):
channel_reception = self.bot.get_channel(1277951933105049601) # Remplacez par votre ID de salon
embed = discord.Embed(description=message.content,
color=discord.Color.blue())
embed.set_author(name=message.author.name,
icon_url=message.author.avatar.url
if message.author.avatar else None)
await channel_reception.send(embed=embed)
# Traiter les autres commandes si nécessaire
await self.bot.process_commands(message)
# Exemple de commande slash avec gestion des erreurs
@app_commands.command()
async def message_tous(self, interaction: discord.Interaction):
await interaction.response.send_message("Commande test!")
@message_tous.error
async def message_tous_error(self, interaction: discord.Interaction,
error: app_commands.AppCommandError):
if isinstance(error, app_commands.MissingPermissions):
await interaction.response.send_message(
"Vous n'avez pas la permission d'utiliser cette commande.",
ephemeral=True)
# Fonction de configuration pour ajouter le cog au bot
async def setup(bot):
await bot.add_cog(RestranscriptionStaff(bot))