From 9b4eeaec4cefe2664d8fe6097159f468557a85bc Mon Sep 17 00:00:00 2001 From: sgoudham Date: Thu, 23 Jul 2020 23:04:03 +0100 Subject: [PATCH] Restructuring code Adding commentary --- main.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 0f3a6566..2a569dbc 100644 --- a/main.py +++ b/main.py @@ -146,17 +146,21 @@ async def change_status(): # Start the background task change_status.start() +h + # Bot Status on Discord @client.event async def on_ready(): - # Tells me that the bot is ready and logged in - print('Bot is ready.') + """Displaying if Bot is Ready""" + + print("UvU Senpaiii I'm rweady") @client.command(name="ping", aliases=["Ping"]) async def _ping(ctx): """Latency of the Bot (ms)""" + await ctx.send(f'Pong! `{round(client.latency * 1000)}ms`') @@ -164,6 +168,7 @@ async def _ping(ctx): @is_owner() async def leave(ctx): """Leaves the guild""" + await ctx.send("**Leaving the guild... Bye Bye uvu**") await ctx.guild.leave() @@ -180,6 +185,7 @@ async def someone(ctx): @client.command(name='help') async def _help(ctx, *, command: str = None): """Shows help about a command or the bot""" + try: if command is None: p = await HelpPaginator.from_bot(ctx) @@ -228,13 +234,16 @@ async def change_prefix(ctx, new: Optional[str]): @is_owner() async def restart(ctx): """Restart the Bot""" + await client.logout() # Bot event for the bot joining a new guild, storing all users in the database @client.event async def on_guild_join(guild): - # Store the default prefix when the bot joins a guild + """Store users in a database when the bot has joined a new guild""" + + # Store default prefix within cache and database cache_prefix(str(guild.id), prefix="~") try: @@ -267,6 +276,8 @@ async def on_guild_join(guild): # Bot event for the bot leaving a guild, deleted all users stored in the database @client.event async def on_guild_remove(guild): + """Remove users in the database for the guild""" + # Delete the key - value pair for the guild del_cache_prefix(str(guild.id))