Merge branch 'dev' into redis-context

This commit is contained in:
2021-10-31 14:46:26 +01:00
committed by GitHub
3 changed files with 31 additions and 20 deletions
+25 -3
View File
@@ -1,8 +1,9 @@
import asyncio
from aioredis.client import Redis
import discord
from discord import ActivityType
from discord.colour import Color
from discord.ext import commands
from discord.ext import commands, tasks
import sys
from signal import SIGINT, SIGTERM
import json
@@ -26,6 +27,9 @@ class ChristmasBot(commands.Bot):
voice_states=True, guild_messages=True, guilds=True, messages=True
)
self.rpc_is_help_message = True
self.update_status.start()
self.config = config
self.initial_cog_names: List[str] = self.config.get("cogs", [])
self.colors: Dict[str, Color] = self.process_colours(config.get("colors", []))
@@ -35,14 +39,18 @@ class ChristmasBot(commands.Bot):
)
self.invite_link: str = ""
slash_guilds = None
if len(self.config["slash_command_guilds"]) > 0:
slash_guilds = self.config["slash_command_guilds"]
super().__init__(
command_prefix=self.prefix_callable,
description=self.config["info"].get("description", ""),
description=self.config["info"]["description"],
case_insensitive=False,
fetch_offline_members=False,
intents=intents,
slash_commands=True,
slash_command_guilds=[227431704426446848],
slash_command_guilds=slash_guilds,
)
self.loop.create_task(self.async_init())
@@ -82,6 +90,20 @@ class ChristmasBot(commands.Bot):
async def get_context(self, message: Message, *, cls=CustomContext):
return await super().get_context(message, cls=cls)
@tasks.loop(seconds=30)
async def update_status(self):
await self.wait_until_ready()
bot_prefix = self.config["prefixes"][0]
if self.rpc_is_help_message:
title = f"for {bot_prefix}connect | {bot_prefix}help"
activity = discord.Activity(name=title, type=ActivityType.watching)
else:
activity = discord.Activity(name="Some song", type=ActivityType.playing)
self.rpc_is_help_message = not self.rpc_is_help_message
await self.change_presence(activity=activity)
if __name__ == "__main__":
try: