Skip to content

Commit 72cae9b

Browse files
committed
Added bot status settings
1 parent b987207 commit 72cae9b

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

cogs/task.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import function as func
2727

2828
from discord.ext import commands, tasks
29-
from datetime import datetime
3029
from addons import Placeholders
3130

3231
class Task(commands.Cog):
@@ -56,18 +55,21 @@ async def activity_update(self):
5655

5756
try:
5857
act_data = func.settings.activity[(self.current_act + 1) % len(func.settings.activity) - 1]
59-
6058
act_original = self.bot.activity
61-
act_type = self.act_type.get(list(act_data.keys())[0].lower(), discord.ActivityType.playing)
62-
act_name = self.placeholder.replace(list(act_data.values())[0])
59+
act_type = getattr(discord.ActivityType, act_data.get("type", "").lower(), discord.ActivityType.playing)
60+
act_name = self.placeholder.replace(act_data.get("name", ""))
61+
62+
status_type = getattr(discord.Status, act_data.get("status", "").lower(), None)
6363

6464
if act_original.type != act_type or act_original.name != act_name:
6565
new_act = discord.Activity(type=act_type, name=act_name)
66-
await self.bot.change_presence(activity=new_act)
66+
await self.bot.change_presence(activity=new_act, status=status_type)
6767
self.current_act = (self.current_act + 1) % len(func.settings.activity)
6868

69-
except:
70-
pass
69+
func.logger.info(f"Changed the bot status to {act_name}")
70+
71+
except Exception as e:
72+
func.logger.error("Error occurred while changing the bot status!", exc_info=e)
7173

7274
@tasks.loop(minutes=5.0)
7375
async def player_check(self):

settings Example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"prefix": "?",
1212
"activity":[
13-
{"listen": "/help"}
13+
{"type": "listen", "name": "/help", "status": "online"}
1414
],
1515
"logging": {
1616
"file": {

0 commit comments

Comments
 (0)