You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

20 lines
667 B

from discord.ext import tasks
import discord
class Extension:
show_stats_prev = 0
def __init__(self, core):
@tasks.loop(seconds=3)
async def show_stats(core):
if not core.stats['servers'].items():
print("Stats not be loaded")
return
try:
server = core.stats['servers'].items()[self.show_stats_prev]
self.show_stats_prev += 1
except:
self.show_stats_prev = 0
server = core.stats['servers'].items()[self.show_stats_prev]
addr = server['address'].split(":")
act = discord.Streaming(name = f"{server['name']} - {server['player_count']}", url=f"https://{addr[0]}/connect/{addr[1]}")
await core.change_presence(activity=act)