diff --git a/src/bot.py b/src/bot.py index dd34702..60c1a4d 100644 --- a/src/bot.py +++ b/src/bot.py @@ -24,5 +24,27 @@ if TOKEN is None: bot = commands.Bot(command_prefix=commands.when_mentioned_or('$b ')) +default_extensions = ['developer'] + +for extension in default_extensions: + bot.load_extension(f'cogs.{extension}') + +@bot.command() +@commands.is_owner() +async def load(ctx, extension): + bot.load_extension(f'cogs.{extension}') + print(f'cogs.{extension} loaded') + +@bot.command() +@commands.is_owner() +async def unload(ctx, extension): + bot.unload_extension(f'cogs.{extension}') + print(f'cogs.{extension} unloaded') + +@bot.command() +@commands.is_owner() +async def reload(ctx, extension): + bot.reload_extension(f'cogs.{extension}') + print(f'cogs.{extension} reloaded') bot.run(TOKEN) diff --git a/src/cogs/__init__.py b/src/cogs/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/cogs/developer.py b/src/cogs/developer.py new file mode 100644 index 0000000..65632c4 --- /dev/null +++ b/src/cogs/developer.py @@ -0,0 +1,27 @@ +import discord +from discord.ext import commands + + +class Developer(commands.Cog): + """This class is intended only for the developer, mainly for testing purposes""" + + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_ready(self): + await self.bot.change_presence(status=discord.Status.online, activity=discord.Game('$b help')) + print('We have logged in as {0.user}'.format(self.bot)) + + @commands.command() + async def hello(self, ctx): + await ctx.send(f"Hello {ctx.message.author.name} :wave:") + + @commands.command() + @commands.is_owner() + async def logout(self, ctx): + """Shut down the bot""" + await self.bot.logout() + +def setup(bot): + bot.add_cog(Developer(bot))