Migrate scripts to voicelink, rewrite handlers and views
This commit is contained in:
10
cogs/task.py
10
cogs/task.py
@@ -26,7 +26,6 @@ import discord
|
||||
import function as func
|
||||
|
||||
from discord.ext import commands, tasks
|
||||
from addons import Placeholders
|
||||
|
||||
class Task(commands.Cog):
|
||||
def __init__(self, bot: commands.Bot):
|
||||
@@ -36,7 +35,7 @@ class Task(commands.Cog):
|
||||
self.cache_cleaner.start()
|
||||
|
||||
self.current_act = 0
|
||||
self.placeholder = Placeholders(bot)
|
||||
self.placeholder = voicelink.BotPlaceholder(bot)
|
||||
|
||||
def cog_unload(self):
|
||||
self.activity_update.cancel()
|
||||
@@ -48,7 +47,7 @@ class Task(commands.Cog):
|
||||
await self.bot.wait_until_ready()
|
||||
|
||||
try:
|
||||
act_data = func.settings.activity[(self.current_act + 1) % len(func.settings.activity) - 1]
|
||||
act_data = voicelink.Config().activity[(self.current_act + 1) % len(voicelink.Config().activity) - 1]
|
||||
act_original = 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", ""))
|
||||
@@ -58,7 +57,7 @@ class Task(commands.Cog):
|
||||
if act_original.type != act_type or act_original.name != act_name:
|
||||
self.bot.activity = discord.Activity(type=act_type, name=act_name)
|
||||
await self.bot.change_presence(activity=self.bot.activity, status=status_type)
|
||||
self.current_act = (self.current_act + 1) % len(func.settings.activity)
|
||||
self.current_act = (self.current_act + 1) % len(voicelink.Config().activity)
|
||||
|
||||
func.logger.info(f"Changed the bot status to {act_name}")
|
||||
|
||||
@@ -104,8 +103,7 @@ class Task(commands.Cog):
|
||||
|
||||
@tasks.loop(hours=12.0)
|
||||
async def cache_cleaner(self):
|
||||
func.SETTINGS_BUFFER.clear()
|
||||
func.USERS_BUFFER.clear()
|
||||
await voicelink.MongoDBHandler.cleanup_cache()
|
||||
|
||||
async def setup(bot: commands.Bot):
|
||||
await bot.add_cog(Task(bot))
|
||||
Reference in New Issue
Block a user