diff --git a/bot.py b/bot.py index a8e7262..b26bcd4 100644 --- a/bot.py +++ b/bot.py @@ -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: diff --git a/cogs/information.py b/cogs/information.py index 1d45160..e2820f2 100644 --- a/cogs/information.py +++ b/cogs/information.py @@ -6,24 +6,14 @@ from discord.ext.commands import Context import humanize import datetime import lavalink +from bot import ChristmasBot from utils.EmbedGenerator import EmbedGenerator from utils.paginator import HelpPaginator class InformationCog(commands.Cog, name="Information"): - def __init__(self, bot: commands.Bot): + def __init__(self, bot: ChristmasBot): self.bot = bot - self.is_help_msg = True - self.update_status.start() - - @tasks.loop(seconds=30.0) - async def update_status(self): - await self.bot.wait_until_ready() - title = "ck!connect | ck!help" - if self.is_help_msg: - title = "Tfoe broer" - self.is_help_msg = not self.is_help_msg - await self.bot.change_presence(activity=discord.Game(title)) @commands.cooldown(rate=1, per=5, type=commands.BucketType.user) @commands.command(description="PONG!", aliases=["pong"]) @@ -53,9 +43,7 @@ class InformationCog(commands.Cog, name="Information"): @commands.cooldown(rate=1, per=5, type=commands.BucketType.user) async def invite(self, ctx: Context): """Gets the invite link!""" - link = f"https://discord.com/oauth2/authorize?client_id=643555373814382593&permissions=3230720&scope=bot%20applications.commands" - embed = await EmbedGenerator.Message(ctx, "Add our bot to your server:", link) - await ctx.send(embed=embed) + await EmbedGenerator.Message(ctx, "Add our bot to your server:", self.bot.invite_link) @commands.command( name="wlinfo", @@ -129,6 +117,6 @@ class InformationCog(commands.Cog, name="Information"): await ctx.send(embed=embed) -def setup(bot: commands.Bot): +def setup(bot: ChristmasBot): bot.remove_command("help") bot.add_cog(InformationCog(bot)) diff --git a/config.json.sample b/config.json.sample index f3ab845..3b0e449 100644 --- a/config.json.sample +++ b/config.json.sample @@ -17,5 +17,6 @@ "name": "CloudKid Radio", "description": "A sample bot description" }, - "cogs": ["cogs.owner", "cogs.settings", "cogs.information", "cogs.music"] + "cogs": ["cogs.owner", "cogs.settings", "cogs.information", "cogs.music"], + "slash_command_guilds": [] }