Hey guys im trying to make a bot online time and servers count command but im having some trouble
Code:
import discord
import datetime as dt
from discord.ext import commands
class Support(commands.Cog):
def __init__(self, client):
self.client = client
client.launch_time = dt.datetime.utcnow()
@commands.command()
async def stats(self, ctx):
delta_uptime = dt.datetime.utcnow() - client.launch_time
hours, remainder = divmod(int(delta_uptime.total_seconds()), 3600)
minutes, seconds = divmod(remainder, 60)
days, hours = divmod(hours, 24)
embed = discord.Embed(
title = "Roumy's Stats",
description = f"Online Time: {days}d, {hours}h, {minutes}m, {seconds}s\n" + "Servers: " +str(len(client.guilds)),
colour = 0xeeffee)
await ctx.send(embed = embed)
def setup(client): client.add_cog(Support(client))
The error i get is the lunch time from this code
client.launch_time = dt.datetime.utcnow()
The error is (undefined name 'client') i have tried hours to fix it but i couldn't if it's something simple pls tell me and sorry if i have write something whorg I'm new to discord.py and also I'm new in stackoverflow and I don't really know how to use it
source https://stackoverflow.com/questions/72791738/bot-online-time-and-server-count-discord-py
Comments
Post a Comment