platforms.discord module
Discord platform adapter using discord.py.
Wraps a discord.Client and converts Discord events into
IncomingMessage instances for the shared
MessageProcessor.
- class platforms.discord.DiscordPlatform(message_handler, *, token, config=None, media_cache=None, message_update_handler=None, message_delete_handler=None, reaction_update_handler=None)[source]
Bases:
PlatformAdapterPlatform adapter for Discord via discord.py.
- Parameters:
message_handler (
Callable[[IncomingMessage,PlatformAdapter],Awaitable[None]]) – Async callback that receivesIncomingMessageinstances.token (
str) – Discord bot token.config (Config | None)
media_cache (MediaCache | None)
message_update_handler (MessageUpdateHandler | None)
message_delete_handler (MessageDeleteHandler | None)
reaction_update_handler (ReactionUpdateHandler | None)
- __init__(message_handler, *, token, config=None, media_cache=None, message_update_handler=None, message_delete_handler=None, reaction_update_handler=None)[source]
Initialize the instance.
- Parameters:
message_handler (
Callable[[IncomingMessage,PlatformAdapter],Awaitable[None]]) – The message handler value.token (str)
config (Config | None)
media_cache (MediaCache | None)
message_update_handler (Callable[[str, str, str, str, str, str, str, str], Awaitable[None]] | None)
message_delete_handler (Callable[[str, str, str, str], Awaitable[None]] | None)
reaction_update_handler (Callable[[str, str, str, str], Awaitable[None]] | None)
- Return type:
None
- property lyria_service
Lyria RealTime music service for voice channel playback.
- property is_running: bool
Check whether is running.
- Returns:
True on success, False otherwise.
- Return type:
- property bot_identity: dict[str, str]
Return the bot’s own identity on this platform.
Returns a dict with at minimum
platformanduser_id. Adapters should override to providedisplay_nameandmentionwhere available. The default returns an emptyuser_id(safe to call before login completes).
- async send_file(channel_id, data, filename, mimetype='application/octet-stream')[source]
Send file.
- async edit_message(channel_id, message_id, new_text)[source]
Edit an existing bot message in channel_id.
- async send_with_buttons(channel_id, text, view=None)[source]
Send a message with a discord.ui.View of interactive buttons.
Used by the GameGirl Color system to attach choice buttons to game turn responses.
- async get_guild_members(guild_id)[source]
Return a cached list of all guild members with roles.
Results are cached per guild for
_MEMBER_CACHE_TTLseconds (6 hours). Each member dict containsid,name,nickname,top_role,roles, andbot.