- 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
37 lines
1.7 KiB
Python
37 lines
1.7 KiB
Python
import discord
|
|
from discord.ext import commands
|
|
from utils.logger import log_info, log_error
|
|
from utils.guild_config import get_guild_channel
|
|
|
|
class WelcomeMessage(commands.Cog):
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
|
|
@commands.Cog.listener()
|
|
async def on_member_join(self, member):
|
|
try:
|
|
# Récupérer le salon de bienvenue depuis la config
|
|
welcome_channel = get_guild_channel(member.guild, "welcome")
|
|
|
|
if welcome_channel:
|
|
cand_ch = get_guild_channel(member.guild, "candidature")
|
|
cand2_ch = get_guild_channel(member.guild, "candidature_2")
|
|
quest_ch = get_guild_channel(member.guild, "questions")
|
|
cand_mention = cand_ch.mention if cand_ch else "#candidature"
|
|
cand2_mention = cand2_ch.mention if cand2_ch else "#candidature-2"
|
|
quest_mention = quest_ch.mention if quest_ch else "#questions"
|
|
|
|
welcome_message = (
|
|
f"## BIENVENUE <:panda_welcome:1297298999849517056> !\n\n"
|
|
f"> **L'équipe staff te souhaite la bienvenue sur Victoria's Vice {member.mention} !**\n\n"
|
|
f"> Pour ta candidature <:arrow_1:1297491509201080362> {cand_mention} / {cand2_mention} \n\n"
|
|
f"> Si tu as des questions <:arrow_1:1297491509201080362> {quest_mention}\n\n"
|
|
f"*> Bien cordialement, L'équipe staff de Victoria's Vice*"
|
|
)
|
|
|
|
await welcome_channel.send(welcome_message)
|
|
except Exception as e:
|
|
print(f"Erreur lors de l'envoi du message de bienvenue: {e}")
|
|
|
|
async def setup(bot):
|
|
await bot.add_cog(WelcomeMessage(bot))
|