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
This commit is contained in:
utilisateurqu 2026-08-17 00:12:57 +02:00
parent bc3cb3f3d5
commit 2e38d05152
25 changed files with 368 additions and 125 deletions

View file

@ -6,8 +6,9 @@ import discord
from discord import app_commands
from discord.ext import commands
from utils.guild_config import has_role
COMPTES_ENTREPRISES_PATH = "comptes_entreprises.json"
BANQUIER_ROLE_ID = 1360314740567576616 # ID du rôle des banquiers # ID du rôle banquier
def generer_rib():
return " ".join(["".join(random.choices(string.digits, k=5)) for _ in range(4)])
@ -35,7 +36,7 @@ class OuvrirCompteEntreprise(commands.Cog):
@app_commands.choices(banque=banque_choix, tva=tva_choix)
async def ouvrir_compte_entreprise(self, interaction: discord.Interaction, entreprise: str, banque: app_commands.Choice[str], tva: app_commands.Choice[int]):
# ✅ Vérifie que l'utilisateur est banquier
if not any(role.id == BANQUIER_ROLE_ID for role in interaction.user.roles):
if not has_role(interaction.user, "banquier"):
await interaction.response.send_message("❌ Vous n'avez pas la permission d'exécuter cette commande.", ephemeral=True)
return