RealJammy / The-Jambot

A repo for my discord bot!
4 stars 13 forks source link

Move presence from on_ready to bot instantiation #91

Closed ThatOtherAndrew closed 1 year ago

ThatOtherAndrew commented 1 year ago

Just a small thing which has been bugging me, presence shouldn't be updated in the on_ready() event.

Relevant info from discord.py:

Don't change_presence (or make API calls) in on_ready within your Bot or Client. Discord has a high chance to completely disconnect you during the READY or GUILD_CREATE events (1006 close code) and there is nothing you can do to prevent it.

Instead set the activity and status kwargs in the constructor of these Classes.

bot = commands.Bot(command_prefix="!", activity=..., status=...)

As noted in the docs, on_ready is also triggered multiple times, not just once.

RealJammy commented 1 year ago

Thank you for the PR, will merge.