Reputation: 1
I tried this
await client.change_presence(status=discord.Status.online, activity=discord.Game(datetime.datetime.utcnow))
But instead it makes the status built in method utcnow of type object
This is probably a easy fix but this is my first discord bot sorry.
Upvotes: 0
Views: 603
Reputation: 21
If you are planning to update the time live (every second), please don't do this as the change_presence
endpoint is heavily rate-limited and can easily get you API banned if you spam it very quickly.
Upvotes: 2
Reputation: 1415
The problem is that the utcnow
is a method not an attribute so you have to put parentheses after it. Like this:
datetime.datetime.utcnow()
this will return the string that looks something like this: '2021-08-19 10:20:05.359823'
If you want to modify this string (for example display only hours and minutes) you can use the strftime()
method. For example:
datetime.datetime.utcnow().strftime("%H:%M")
this will return string that looks like this: '10:20'
How your code should look like:
await client.change_presence(
status=discord.Status.online,
activity=discord.Game(datetime.datetime.utcnow().strftime("%H:%M")),
)
Upvotes: 0
Reputation: 575
await client.change_presence(status=discord.Status.online,activity=discord.Game(start = datetime.datetime.utcnow))
you have two problems the first is that the date gets detected thru kwargs and without putting one it can not do so. the second thing is that you have to provide the name of the game for more details click here
Upvotes: 0