Looping Status

pull/8/head
sgoudham 4 years ago
parent 4747c36b4c
commit 371d2ebb21

@ -1,7 +1,6 @@
import asyncio import asyncio
import datetime import datetime
from contextlib import closing from contextlib import closing
from itertools import cycle
from typing import Optional from typing import Optional
import discord import discord
@ -131,9 +130,17 @@ async def on_message(message):
await client.process_commands(message) await client.process_commands(message)
if client.is_ready(): counter = 0
looping_statuses = cycle(
[
@tasks.loop(seconds=180, reconnect=True)
async def change_status():
"""Creating Custom Statuses as a Background Task"""
global counter
# Waiting for the bot to ready
await client.wait_until_ready()
looping_statuses = [
discord.Activity( discord.Activity(
type=discord.ActivityType.watching, type=discord.ActivityType.watching,
name=f"{len(client.users)} Weebs | {get_version()}"), name=f"{len(client.users)} Weebs | {get_version()}"),
@ -145,17 +152,13 @@ if client.is_ready():
name=f"Hamothy Program | {get_version()}"), name=f"Hamothy Program | {get_version()}"),
discord.Game(name=f"~help | {get_version()}") discord.Game(name=f"~help | {get_version()}")
] ]
) if counter == 3:
counter = 0
else:
@tasks.loop(seconds=5, reconnect=True) counter += 1
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 # Display the next status in the loop
await client.change_presence(activity=next(looping_statuses)) await client.change_presence(activity=looping_statuses[counter])
# Start the background task # Start the background task

Loading…
Cancel
Save