feat: bot Discord presence + system name on voice join
CI / lint (push) Failing after 35s
CI / test (push) Successful in 46s
Build edge-node / build (push) Successful in 11m13s

- RadioBot.join() accepts system_name parameter
- Sets bot activity to ActivityType.listening → system name on connect
- Clears presence (activity=None) on leave
- main.py passes system_name from MQTT payload to radio_bot.join()
This commit is contained in:
Logan
2026-05-10 19:47:22 -04:00
parent ad9d128522
commit dccbab00d6
2 changed files with 10 additions and 1 deletions
+9 -1
View File
@@ -24,7 +24,7 @@ class RadioBot:
self._channel_id: Optional[int] = None
self._was_streaming: bool = False
async def join(self, guild_id: int, channel_id: int, token: str, call_active: bool = False) -> bool:
async def join(self, guild_id: int, channel_id: int, token: str, call_active: bool = False, system_name: str = None) -> bool:
# (Re)start the bot if the token changed or the bot isn't running
if self._current_token != token or not self._is_bot_running():
if not await self._start_bot(token):
@@ -48,6 +48,13 @@ class RadioBot:
self._guild_id = guild_id
self._channel_id = channel_id
self._play_stream()
if system_name:
await self._bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.listening,
name=system_name,
)
)
logger.info(f"Joined #{channel.name} in {guild.name}")
return True
except Exception as e:
@@ -65,6 +72,7 @@ class RadioBot:
self._stop_stream()
await self._voice_client.disconnect(force=True)
self._voice_client = None
await self._bot.change_presence(activity=None)
logger.info("Disconnected from voice channel.")
return True
except Exception as e:
+1
View File
@@ -66,6 +66,7 @@ async def on_command(payload: dict):
channel_id=int(payload["channel_id"]),
token=token,
call_active=metadata_watcher.is_active,
system_name=payload.get("system_name"),
)
elif action == "discord_leave":
await radio_bot.leave()