Files
server-26/drb-server-discord-bot/app/bot.py
T
Logan CusanoandClaude Opus 5.5 62e6d69bfa Node page Discord picker: org's linked servers + voice channels, not raw IDs (#213 item 3, #109 item 13)
- c2-core routers/discord_web.py:
  PUT  /discord/guilds/{id}/directory (service key): the server bot pushes each
       server's name + voice channels; merged onto discord_guilds, never touches org_id.
  GET  /discord/nodes/{id}/join-options: the node org's servers (same
       resolve rule as the bot), their voice channels with any live stream,
       radio-bot readiness + invite links, and this node's streams. No tokens.
  POST /discord/nodes/{id}/streams: stream pinned to the node; server must be
       the node org's, channel must be in the bot's directory, guild + node caps.
  POST /discord/nodes/{id}/streams/stop: one stream on this node, or all.
  Control = platform admin, org owner, or operator owning the node.
- nodes.py: legacy raw-ID discord_join now refuses a server outside the node's org.
- discord bot: DirectorySync cog pushes on ready (15-min loop), join/leave,
  rename, voice/category channel changes (debounced).
- frontend: NodeDiscordRadio panel + picker replaces DiscordJoinModal and the
  admin-only Join/Leave buttons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 20:02:16 -04:00

41 lines
1.2 KiB
Python

import asyncio
import discord
from discord.ext import commands
from app.config import settings
from app.internal.logger import logger
class DRBBot(commands.Bot):
def __init__(self):
intents = discord.Intents.default()
super().__init__(command_prefix="!", intents=intents)
async def setup_hook(self):
await self.load_extension("app.commands.radio")
await self.load_extension("app.commands.trips")
await self.load_extension("app.commands.directory")
if settings.dev_guild_id:
guild = discord.Object(id=settings.dev_guild_id)
self.tree.copy_global_to(guild=guild)
await self.tree.sync(guild=guild)
logger.info(f"Slash commands synced to dev guild {settings.dev_guild_id}.")
else:
await self.tree.sync()
logger.info("Slash commands synced globally.")
async def on_ready(self):
logger.info(f"Bot ready: {self.user} ({self.user.id})")
await self.change_presence(
activity=discord.Activity(
type=discord.ActivityType.listening,
name="the radio"
)
)
bot = DRBBot()
if __name__ == "__main__":
bot.run(settings.discord_token)