2026-08-16 19:37:15 +02:00
|
|
|
import discord
|
|
|
|
|
from discord.ext import commands
|
|
|
|
|
from discord import app_commands
|
Modularize bot: per-guild config system for roles/channels/categories
- Add utils/guild_config.py: centralized config loader per guild (data/guilds/{id}.json)
- Add commandes/config.py: /config set_role, /config set_channel, /config set_category, /config voir, /config reset
- Replace ALL hardcoded role IDs (banquier, gouvernement, citoyen, staff, ems, permis, fbm, ursaff, etc.) with guild_config lookups
- Replace ALL hardcoded channel IDs (welcome, candidature, questions, mp_reception) with guild_config lookups
- Replace ALL hardcoded category IDs (ticket) with guild_config lookups
- Remove duplicate commandes/welcome_message.py (kept utils/ version)
- Remove 20+ hardcoded snowflake IDs across 22 files
- Guilds configure via /config on Discord, no code changes needed
2026-08-17 00:12:57 +02:00
|
|
|
from utils.guild_config import get_guild_channel
|
2026-08-16 19:37:15 +02:00
|
|
|
|
|
|
|
|
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):
|
Modularize bot: per-guild config system for roles/channels/categories
- Add utils/guild_config.py: centralized config loader per guild (data/guilds/{id}.json)
- Add commandes/config.py: /config set_role, /config set_channel, /config set_category, /config voir, /config reset
- Replace ALL hardcoded role IDs (banquier, gouvernement, citoyen, staff, ems, permis, fbm, ursaff, etc.) with guild_config lookups
- Replace ALL hardcoded channel IDs (welcome, candidature, questions, mp_reception) with guild_config lookups
- Replace ALL hardcoded category IDs (ticket) with guild_config lookups
- Remove duplicate commandes/welcome_message.py (kept utils/ version)
- Remove 20+ hardcoded snowflake IDs across 22 files
- Guilds configure via /config on Discord, no code changes needed
2026-08-17 00:12:57 +02:00
|
|
|
channel_reception = get_guild_channel(message.guild, "mp_reception")
|
|
|
|
|
if channel_reception is None:
|
|
|
|
|
return
|
2026-08-16 19:37:15 +02:00
|
|
|
|
|
|
|
|
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))
|