A bot may be found in a most of two,500 guilds in line with WebSocket connection. if you want to permit a bot to be present in greater guilds, the bot must enforce sharding and open several separate WebSocket connections to Discord.
In case your bot runs inner of a unmarried Discord bot on a unmarried node, this is just brought complexity for you that can appear unnecessary. but in case your bot is very famous and needs to have its back-quit dispensed throughout separate nodes, Discord’s sharding guide makes this tons easier than it might be otherwise.
The rest API
The Discord rest API is used by bots to perform maximum actions, such as sending messages, kicking/banning customers, and updating person permissions (widely analogous to the occasions received from the WebSocket API). The rest API can also be used to query for statistics; however, bots specifically rely on occasions from the WebSocket API as an alternative and cache the records obtained from the WebSocket events.
There are numerous reasons for this. Querying the relaxation API to get consumer data whenever a Message Create occasion is acquired, for instance, does not scale due to the relaxation API’s price limits. It’s additionally redundant in maximum cases, as the WebSocket API provides the essential facts and also you have to have it for your cache.
There are a few exceptions, but, and you may once in a while need statistics that isn’t always found in your cache. while a bot to start with connects to a WebSocket.