feat: dev/prod environment split + APPLICATION_ID + privileged intents
- .env.dev / .env.prod with separate tokens and APPLICATION_ID - Bot syncs commands to specific guild in dev mode - Global sync for production - Updated .forgejo/workflows/ci.yml with SSH deploy to prod server - Updated .gitignore for .env.dev / .env.prod
This commit is contained in:
parent
e44349cea9
commit
0bdf414540
4 changed files with 54 additions and 14 deletions
22
bot.py
22
bot.py
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import os
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
|
|
@ -6,6 +7,8 @@ import config
|
|||
|
||||
logger = logging.getLogger("vision")
|
||||
|
||||
DEV_GUILD_IDS = [int(x) for x in os.getenv("DEV_GUILD_IDS", "").split(",") if x.strip()]
|
||||
|
||||
|
||||
class VisionBot(commands.Bot):
|
||||
def __init__(self):
|
||||
|
|
@ -22,13 +25,22 @@ class VisionBot(commands.Bot):
|
|||
async def setup_hook(self):
|
||||
logger.info("Chargement des cogs...")
|
||||
await self.load_extension("commandes.hello")
|
||||
logger.info("Sync des slash commands...")
|
||||
await self.tree.sync()
|
||||
logger.info("Slash commands synchronisées")
|
||||
|
||||
if config.DEV and DEV_GUILD_IDS:
|
||||
logger.info(f"Mode DEV — sync des commands sur les guilds: {DEV_GUILD_IDS}")
|
||||
for guild_id in DEV_GUILD_IDS:
|
||||
self.tree.copy_global_to(guild=guild_id)
|
||||
await self.tree.sync(guild=guild_id)
|
||||
logger.info(f" ✓ Sync guild {guild_id}")
|
||||
else:
|
||||
logger.info("Mode PROD — sync global des slash commands...")
|
||||
await self.tree.sync()
|
||||
logger.info("Slash commands synchronisées (global)")
|
||||
|
||||
async def on_ready(self):
|
||||
logger.info(f"Connecté en tant que {self.user} (ID: {self.user.id})")
|
||||
logger.info(f"Serveurs : {len(self.guilds)}")
|
||||
instance = "DEV" if config.DEV else "PROD"
|
||||
logger.info(f"[{instance}] Connecté en tant que {self.user} (ID: {self.user.id})")
|
||||
logger.info(f"[{instance}] Serveurs : {len(self.guilds)}")
|
||||
await self.change_presence(
|
||||
activity=discord.Activity(
|
||||
type=discord.ActivityType.watching,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue