diff --git a/.gitignore b/.gitignore index bf96b13..bb1e904 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ venv .vscode __pycache__ -.editorconfig \ No newline at end of file +.editorconfig +env \ No newline at end of file diff --git a/bothello.py b/bot.py similarity index 50% rename from bothello.py rename to bot.py index 6fc13cb..7595b51 100644 --- a/bothello.py +++ b/bot.py @@ -10,27 +10,39 @@ client = commands.Bot(command_prefix='!') - +# Load Cog Command @client.command() async def load(ctx, extension): + print(f'[LOADING EXT] - {extension}') client.load_extension(f'cogs.{extension}') +# Unload Cog command @client.command() async def unload(ctx, extension): + print(f'[UNLOADING EXT] - {extension}') client.unload_extension(f'cogs.{extension}') +# Reload Cog Command @client.command() async def reload(ctx, extension): + print(f'[RELOADING EXT] - {extension}') client.unload_extension(f'cogs.{extension}') client.load_extension(f'cogs.{extension}') -for filename in listdir('./cogs'): +# Initialize Events +for filename in listdir('./cogs/events/'): + if filename.endswith('.py'): + print(f'[LOADING EXT] - {filename[:-3]}') + client.load_extension(f'cogs.events.{filename[:-3]}') + +# Initialize Commands +for filename in listdir('./cogs/commands/'): if filename.endswith('.py'): - client.load_extension(f'cogs.{filename[:-3]}') - print(f'cogs.{filename[:-3]}') + print(f'[LOADING EXT] - {filename[:-3]}') + client.load_extension(f'cogs.commands.{filename[:-3]}') client.run(token_bot) diff --git a/cogs/commands/command_example.py b/cogs/commands/command_example.py new file mode 100644 index 0000000..91a3eb6 --- /dev/null +++ b/cogs/commands/command_example.py @@ -0,0 +1,17 @@ +import discord +from discord.ext import commands + + +class Example(commands.Cog): + + def __init__(self, client): + self.client = client + + + @commands.command() + async def example(self, ctx): + await ctx.send('This is an example command :)') + + +def setup(client): + client.add_cog(Example(client)) diff --git a/cogs/events/member_join.py b/cogs/events/member_join.py new file mode 100644 index 0000000..b188627 --- /dev/null +++ b/cogs/events/member_join.py @@ -0,0 +1,16 @@ +import discord +from discord.ext import commands + + +class MemberJoin(commands.Cog): + + def __init__(self, client): + self.client = client + + + @commands.Cog.listener() + async def on_member_join(self, member): + print(f'[MEMBER JOINED] - {member}') + +def setup(client): + client.add_cog(MemberJoin(client)) diff --git a/cogs/events/message.py b/cogs/events/message.py new file mode 100644 index 0000000..9d56ae7 --- /dev/null +++ b/cogs/events/message.py @@ -0,0 +1,16 @@ +import discord +from discord.ext import commands + + +class Message(commands.Cog): + + def __init__(self, client): + self.client = client + + + @commands.Cog.listener() + async def on_message(self, message): + print(f'[{message.author}] - {message.content}') + +def setup(client): + client.add_cog(Message(client)) diff --git a/cogs/events/ready.py b/cogs/events/ready.py new file mode 100644 index 0000000..f3b9450 --- /dev/null +++ b/cogs/events/ready.py @@ -0,0 +1,17 @@ +import utils +import discord +from discord.ext import commands + + +class Ready(commands.Cog): + + def __init__(self, client): + self.client = client + + @commands.Cog.listener() + async def on_ready(client): + print('[BOT READY!]') + + +def setup(client): + client.add_cog(Ready(client)) diff --git a/cogs/greetings.py b/cogs/greetings.py deleted file mode 100644 index 869b08a..0000000 --- a/cogs/greetings.py +++ /dev/null @@ -1,21 +0,0 @@ -import discord -from discord.ext import commands - - -class Greetings(commands.Cog): - - def __init__(self, client): - self.client = client - - @commands.Cog.listener() - async def on_ready(client): - print(f'We are online {client}') - # await utils.set_presence(client) - - @commands.command() - async def hello(self, ctx): - await ctx.send("Para de pingar mardito") - - -def setup(client): - client.add_cog(Greetings(client)) diff --git a/info.py b/info.py deleted file mode 100644 index 7dad644..0000000 --- a/info.py +++ /dev/null @@ -1,10 +0,0 @@ -from discord.ext import commands - - -class Info(commands.Cog): - def __init__(self, bot): - self.bot = bot - - @commands.command() - async def info(self, ctx): - print(self.bot.application_info()) diff --git a/utils.py b/utils.py index e742da7..1b60815 100644 --- a/utils.py +++ b/utils.py @@ -1,5 +1,6 @@ import discord +# Set Bot Presence async def set_presence(client, game="Python"): game = discord.Game(game) await client.change_presence(status=discord.Status.idle, activity=game)