| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- from discord.ext import commands
- from cogs.basecog import BaseCog, BotMessage
- 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(
- f'{CONFIG["warning_emoji"]} No warning channel set!',
- mention_author=False)
- else:
- bm = BotMessage(
- context.guild,
- f'Test warning message (requested by {context.author.name})',
- type=BotMessage.TYPE_MOD_WARNING)
- await self.post_message(bm)
-
- @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()
|