Restructuring code

Adding commentary
pull/8/head
sgoudham 4 years ago
parent 98c33c83e7
commit 9b4eeaec4c

@ -146,17 +146,21 @@ async def change_status():
# Start the background task # Start the background task
change_status.start() change_status.start()
h
# Bot Status on Discord # Bot Status on Discord
@client.event @client.event
async def on_ready(): async def on_ready():
# Tells me that the bot is ready and logged in """Displaying if Bot is Ready"""
print('Bot is ready.')
print("UvU Senpaiii I'm rweady")
@client.command(name="ping", aliases=["Ping"]) @client.command(name="ping", aliases=["Ping"])
async def _ping(ctx): async def _ping(ctx):
"""Latency of the Bot (ms)""" """Latency of the Bot (ms)"""
await ctx.send(f'Pong! `{round(client.latency * 1000)}ms`') await ctx.send(f'Pong! `{round(client.latency * 1000)}ms`')
@ -164,6 +168,7 @@ async def _ping(ctx):
@is_owner() @is_owner()
async def leave(ctx): async def leave(ctx):
"""Leaves the guild""" """Leaves the guild"""
await ctx.send("**Leaving the guild... Bye Bye uvu**") await ctx.send("**Leaving the guild... Bye Bye uvu**")
await ctx.guild.leave() await ctx.guild.leave()
@ -180,6 +185,7 @@ async def someone(ctx):
@client.command(name='help') @client.command(name='help')
async def _help(ctx, *, command: str = None): async def _help(ctx, *, command: str = None):
"""Shows help about a command or the bot""" """Shows help about a command or the bot"""
try: try:
if command is None: if command is None:
p = await HelpPaginator.from_bot(ctx) p = await HelpPaginator.from_bot(ctx)
@ -228,13 +234,16 @@ async def change_prefix(ctx, new: Optional[str]):
@is_owner() @is_owner()
async def restart(ctx): async def restart(ctx):
"""Restart the Bot""" """Restart the Bot"""
await client.logout() await client.logout()
# Bot event for the bot joining a new guild, storing all users in the database # Bot event for the bot joining a new guild, storing all users in the database
@client.event @client.event
async def on_guild_join(guild): 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="~") cache_prefix(str(guild.id), prefix="~")
try: 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 # Bot event for the bot leaving a guild, deleted all users stored in the database
@client.event @client.event
async def on_guild_remove(guild): async def on_guild_remove(guild):
"""Remove users in the database for the guild"""
# Delete the key - value pair for the guild # Delete the key - value pair for the guild
del_cache_prefix(str(guild.id)) del_cache_prefix(str(guild.id))

Loading…
Cancel
Save