From 45656b3a98bc6e4744c58ac53872746d5ccb65ad Mon Sep 17 00:00:00 2001 From: mark Date: Sun, 27 Oct 2024 11:35:47 -0300 Subject: [PATCH] - Added ability to configure rich presence message via environment variable - Implemented support for different activity types (playing, listening, watching, streaming) - Default activity is 'playing' if none specified - Improved bot initialization message in console --- .env.exemple | 4 +++- bot.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.env.exemple b/.env.exemple index a9ad858..d2bdac5 100644 --- a/.env.exemple +++ b/.env.exemple @@ -2,4 +2,6 @@ DISCORD_BOT_TOKEN=Your_Token_Here # This is the token of your bot, you can get i CHANNEL_1=Your_Channel_ID_Here # The number of channels is limited to 10, you can increment here as you want, just place the new channel ID below with the same format CHANNEL_2=Your_Channel_ID_Here CHANNEL_3=Your_Channel_ID_Here -NOTIFICATION_CHANNEL=Your_NOTIFICATION_Channel_ID_Here # This is the channel where the bot will send the notifications \ No newline at end of file +NOTIFICATION_CHANNEL=Your_NOTIFICATION_Channel_ID_Here # This is the channel where the bot will send the notifications +RICH_PRESENCE=Katchau! # This is the rich presence of the bot (example: "Katchau!") as a string +ACTIVITY=listening # This is the activity of the bot, you can use "game", "listening", "watching" or "streaming") \ No newline at end of file diff --git a/bot.py b/bot.py index 0ee0b6f..a51daf1 100644 --- a/bot.py +++ b/bot.py @@ -50,7 +50,16 @@ @client.event async def on_ready(): - await client.change_presence(status=discord.Status.online, activity=discord.Game(name="Katchau!")) + rich_presence = os.getenv('RICH_PRESENCE', 'Katchau!') + activity = os.getenv('ACTIVITY', 'playing').lower() + activity_type = discord.ActivityType.playing + if activity == 'listening': + activity_type = discord.ActivityType.listening + elif activity == 'watching': + activity_type = discord.ActivityType.watching + elif activity == 'streaming': + activity_type = discord.ActivityType.streaming + await client.change_presence(status=discord.Status.online, activity=discord.Activity(name=rich_presence, type=activity_type)) print('Bot online!') print(f'Connected as {client.user.name}') print('------')