from discord.ext import commands from cogs.basecog import BaseCog from storage import ConfigKey, Storage class GeneralCog(BaseCog): def __init__(self, bot: commands.Bot): super().__init__(bot) self.is_connected = False self.is_ready = False @commands.Cog.listener() async def on_connect(self): print('on_connect') self.is_connected = True @commands.Cog.listener() async def on_ready(self): print('on_ready') self.is_ready = True @commands.command( brief='Posts a test warning in the configured warning channel.' ) @commands.has_permissions(ban_members=True) @commands.guild_only() async def testwarn(self, context): if Storage.get_config_value(context.guild, ConfigKey.WARNING_CHANNEL_ID) is None: await context.message.reply( 'No warning channel set!', mention_author=False) else: await self.warn(context.guild, f'Test warning message (requested by {context.author.name})') @commands.command( brief='Simple test reply', ) async def hello(self, context): await context.message.reply( f'Hey, {context.author.name}!', mention_author=False) @commands.command( brief='Shuts down the bot (admin only)', ) @commands.has_permissions(administrator=True) @commands.guild_only() async def shutdown(self, context): await self.bot.close()