discordrb
discordrb copied to clipboard
Improve gateway logging
Summary
Clarifies logging in the gateway code to explain what's happening and what went wrong. Fixes #168.
The below snippets contrast the output in the case that identify is unsuccessful.
New:
[INFO : websocket @ 2022-07-21 19:34:12.376] Connecting to gateway
[ERROR : websocket @ 2022-07-21 19:34:13.066] The gateway connection has closed:
[ERROR : websocket @ 2022-07-21 19:34:13.066] Websocket close frame received!
[ERROR : websocket @ 2022-07-21 19:34:13.066] Code: 4014
[ERROR : websocket @ 2022-07-21 19:34:13.066] Message: Disallowed intent(s).
[ERROR : websocket @ 2022-07-21 19:34:13.066]
Your bot attempted to identify with privileged intents that it is not authorized to use.
You must either enable these for your application on the Discord Developer Portal, or
set the intents: parameter of Bot#initialize to request only the intents that you need.
Read more here: https://discord.com/developers/docs/topics/gateway#privileged-intents
https://drb.shardlab.dev/main/Discordrb/Bot.html#initialize-instance_method
Process finished with exit code 0
Old:
[ERROR : websocket @ 2022-07-21 19:38:37.361] The websocket connection has closed: (no information)
[ERROR : websocket @ 2022-07-21 19:38:37.361] Websocket close frame received!
[ERROR : websocket @ 2022-07-21 19:38:37.361] Code: 4014
[ERROR : websocket @ 2022-07-21 19:38:37.361] Message: Disallowed intent(s).
[ERROR : websocket @ 2022-07-21 19:38:37.361] You attempted to identify with privileged intents that your bot is not authorized to use
Please enable the privileged intents on the bot page of your application on the discord developer page.
Read more here https://discord.com/developers/docs/topics/gateway#privileged-intents
[WARN : websocket @ 2022-07-21 19:38:37.361] The WS loop exited! Not sure if this is a good thing
Process finished with exit code 0
Changed
- Improved the message printed after attempting to identify with disallowed intents. The new message informs the user that they can either enable all privileged intents on the Portal or request only the ones they need.
- Swapped a couple of logging calls between
LOGGER.debugandLOGGER.info(and vice-versa) based on their relevance to the general user in understanding what the chain of events is