From 4747c36b4c872a41bac6af08bf41321b54212038 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Wed, 22 Jul 2020 22:45:27 +0100 Subject: [PATCH] Testing out looping status --- main.py | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/main.py b/main.py index c40be2b1..31e4b962 100644 --- a/main.py +++ b/main.py @@ -96,13 +96,6 @@ if __name__ == '__main__': client.load_extension(ext) -# Bot ping command in milliseconds -@client.command(name="ping", aliases=["Ping"]) -async def _ping(ctx): - """Sends the latency of the bot (ms)""" - await ctx.send(f'Pong! `{round(client.latency * 1000)}ms`') - - # Bot prefix command that returns the prefix or updates it @client.command(name="prefix", aliases=["Prefix"]) @guild_only() @@ -138,30 +131,29 @@ async def on_message(message): await client.process_commands(message) -# Choose a random status -looping_statuses = cycle( - [ - discord.Activity( - type=discord.ActivityType.watching, - name=f"{len(client.users)} Weebs | {get_version()}"), - discord.Activity( - type=discord.ActivityType.watching, - name=f"Hamothy | Real Life | {get_version()}"), - discord.Activity( - type=discord.ActivityType.watching, - name=f"Hamothy Program | {get_version()}"), - discord.Game(name=f"~help | {get_version()}") - ] -) - - -@tasks.loop(seconds=180.0, reconnect=True) +if client.is_ready(): + looping_statuses = cycle( + [ + discord.Activity( + type=discord.ActivityType.watching, + name=f"{len(client.users)} Weebs | {get_version()}"), + discord.Activity( + type=discord.ActivityType.watching, + name=f"Hamothy | Real Life | {get_version()}"), + discord.Activity( + type=discord.ActivityType.watching, + name=f"Hamothy Program | {get_version()}"), + discord.Game(name=f"~help | {get_version()}") + ] + ) + + +@tasks.loop(seconds=5, reconnect=True) async def change_status(): """Creating Custom Statuses as a Background Task""" # Waiting for the bot to ready await client.wait_until_ready() - # Display the next status in the loop await client.change_presence(activity=next(looping_statuses))