From df1732fa97d523790968827358d2eb210a148677 Mon Sep 17 00:00:00 2001 From: profitroll Date: Sat, 6 May 2023 19:06:04 +0200 Subject: [PATCH] Added custom activity types --- config_example.json | 5 ++++- main.py | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/config_example.json b/config_example.json index 0b2e65a..b6da562 100644 --- a/config_example.json +++ b/config_example.json @@ -3,7 +3,10 @@ "owner": 0, "guild": 0, "admins": [], - "status": "crying clowns", + "status": { + "type": "playing", + "message": "on your nerves" + }, "database": { "user": null, "password": null, diff --git a/main.py b/main.py index 6267f49..2217a64 100644 --- a/main.py +++ b/main.py @@ -31,9 +31,38 @@ except ImportError: @client.event async def on_ready(): logger.info(f"Logged in as {client.user}") - await client.change_presence( - activity=Activity(type=ActivityType.listening, name=await config_get("status")) - ) + + activity_type = await config_get("type", "status") + activity_message = await config_get("message", "status") + + if activity_type == "playing": + await client.change_presence( + activity=Activity(type=ActivityType.playing, name=activity_message) + ) + elif activity_type == "watching": + await client.change_presence( + activity=Activity(type=ActivityType.watching, name=activity_message) + ) + elif activity_type == "listening": + await client.change_presence( + activity=Activity(type=ActivityType.listening, name=activity_message) + ) + elif activity_type == "streaming": + await client.change_presence( + activity=Activity(type=ActivityType.streaming, name=activity_message) + ) + elif activity_type == "competing": + await client.change_presence( + activity=Activity(type=ActivityType.competing, name=activity_message) + ) + elif activity_type == "custom": + await client.change_presence( + activity=Activity(type=ActivityType.custom, name=activity_message) + ) + else: + return + + logger.info(f"Set activity type to {activity_type} with message {activity_message}") def main():