From f66c3f20e12b0b2d952c8e37fe9e27818564e513 Mon Sep 17 00:00:00 2001 From: marcopandolfo Date: Fri, 30 Aug 2019 19:31:13 -0300 Subject: [PATCH 1/3] Env to gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From f2774f4ffb9a023cdd6eb74f306c8e530025f4db Mon Sep 17 00:00:00 2001 From: marcopandolfo Date: Fri, 30 Aug 2019 21:47:44 -0300 Subject: [PATCH 2/3] Cleanup --- bothello.py | 10 ++++++++-- cogs/greetings.py | 11 +++-------- cogs/ready.py | 17 +++++++++++++++++ info.py | 10 ---------- utils.py | 1 + 5 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 cogs/ready.py delete mode 100644 info.py diff --git a/bothello.py b/bothello.py index 6fc13cb..eed0853 100644 --- a/bothello.py +++ b/bothello.py @@ -10,27 +10,33 @@ 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}') +# Initialize Cogs for filename in listdir('./cogs'): if filename.endswith('.py'): + print(f'[LOADING EXT] - {filename[:-3]}') client.load_extension(f'cogs.{filename[:-3]}') - print(f'cogs.{filename[:-3]}') client.run(token_bot) diff --git a/cogs/greetings.py b/cogs/greetings.py index 869b08a..081c242 100644 --- a/cogs/greetings.py +++ b/cogs/greetings.py @@ -7,15 +7,10 @@ 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") + @commands.Cog.listener() + async def on_member_join(self, member): + print(f'[MEMBER JOINED] - {member}') def setup(client): client.add_cog(Greetings(client)) diff --git a/cogs/ready.py b/cogs/ready.py new file mode 100644 index 0000000..f3b9450 --- /dev/null +++ b/cogs/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/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) From 9cb33785ecede3af7f61bbd41be9d3c80117e994 Mon Sep 17 00:00:00 2001 From: marcopandolfo Date: Fri, 30 Aug 2019 22:00:04 -0300 Subject: [PATCH 3/3] Creating command template --- cogs/command_example.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 cogs/command_example.py diff --git a/cogs/command_example.py b/cogs/command_example.py new file mode 100644 index 0000000..91a3eb6 --- /dev/null +++ b/cogs/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))