From cc748896e9398e3603cfb58c210c1ac201194cdf Mon Sep 17 00:00:00 2001 From: Choco <94597336+ChocoMeow@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:38:14 +0800 Subject: [PATCH] Fixed activity update Resolved the issue where activity updates were not reflected when the value remained the same. --- cogs/task.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/cogs/task.py b/cogs/task.py index 56d899d..f484acf 100644 --- a/cogs/task.py +++ b/cogs/task.py @@ -35,13 +35,8 @@ class Task(commands.Cog): self.player_check.start() self.cache_cleaner.start() - self.act_type = { - "play": discord.ActivityType.playing, - "listen": discord.ActivityType.listening, - "watch": discord.ActivityType.watching, - "stream": discord.ActivityType.streaming - } self.current_act = 0 + self.last_activity: discord.Activity = None self.placeholder = Placeholders(bot) def cog_unload(self): @@ -55,15 +50,15 @@ class Task(commands.Cog): try: act_data = func.settings.activity[(self.current_act + 1) % len(func.settings.activity) - 1] - act_original = self.bot.activity + act_original = self.last_activity or self.bot.activity act_type = getattr(discord.ActivityType, act_data.get("type", "").lower(), discord.ActivityType.playing) act_name = self.placeholder.replace(act_data.get("name", "")) status_type = getattr(discord.Status, act_data.get("status", "").lower(), None) if act_original.type != act_type or act_original.name != act_name: - new_act = discord.Activity(type=act_type, name=act_name) - await self.bot.change_presence(activity=new_act, status=status_type) + self.last_activity = discord.Activity(type=act_type, name=act_name) + await self.bot.change_presence(activity=self.last_activity, status=status_type) self.current_act = (self.current_act + 1) % len(func.settings.activity) func.logger.info(f"Changed the bot status to {act_name}")