yourWaifu / sleepy-discord

C++ library for the Discord chat client. Please use Rust for new bots
https://yourWaifu.github.io/sleepy-discord/
MIT License
707 stars 92 forks source link

In what point in the code/file connects the token of the bot to discord? #199

Closed GDB-spur closed 3 years ago

GDB-spur commented 3 years ago

I would like to know this because I am curious to see how it works.

yourWaifu commented 3 years ago

It happens on the Send Identity function. This happens after connecting to Discord's gateway via WebSockets. Connecting starts some time after the run function is called. The call stack usally looks like this:

Sleepy discord :: Send Identity
Sleepy discord :: on message
WebSockets client :: on massage
WebSockets Library stuff
Async library stuff

For HTTPS request, the token is sent in every request in the header.