diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1154d66 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bot-env/ diff --git a/main.py b/main.py new file mode 100644 index 0000000..7617c77 --- /dev/null +++ b/main.py @@ -0,0 +1,38 @@ +import discord +import glob +import os +import logging +import asyncio +import discord.ext.commands + +class DankBot(discord.ext.commands.Bot): + async def load_plugins(self): + plugin_path = os.path.join(os.path.dirname(__file__), 'plugins') + plugin_files = glob.glob(os.path.join(plugin_path, '**', 'plugin.py'), recursive=True) + for plugin_file in plugin_files: + plugin_name = os.path.basename(os.path.dirname(plugin_file)) + print(f"Loading plugin {plugin_name}") + await self.load_extension(f'plugins.{plugin_name}.plugin') + + async def on_ready(self): + print(f'Logged on as {self.user}!') + await self.load_plugins() + await self.change_presence(activity=discord.Game("with the bots")) + + async def on_message(self, message): + print(f'Message from {message.author}: {message.content}') + await self.process_commands(message) + +async def main(): + intents = discord.Intents.default() + intents.message_content = True + logging.basicConfig(level=logging.INFO) + + with open(".token") as token_file: + token = token_file.read() + + bot = DankBot(intents=intents, command_prefix='!') + await bot.start(token) + +if (__name__ == '__main__'): + asyncio.run(main()) diff --git a/plugins/pepe/plugin.py b/plugins/pepe/plugin.py new file mode 100644 index 0000000..89af2f9 --- /dev/null +++ b/plugins/pepe/plugin.py @@ -0,0 +1,10 @@ +from discord.ext import commands +import discord + +@commands.command() +async def hello(ctx): + await ctx.send(f'Hello {ctx.author.display_name}.') + +async def setup(bot): + print("I am being loaded!") + bot.add_command(hello)