#My bot runs slowly and delays

15 messages · Page 1 of 1 (latest)

quartz auroraBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
marsh cypress
#

Well there is another problem that is if you only use
if (message.author.id !== "1145030539074600970") return;
The bot runs smoothly and responds well...

hidden bone
#

Without knowing anything about your code or the host you run on this is gonna be hard to help with

marsh cypress
# hidden bone Without knowing anything about your code or the host you run on this is gonna be...

Here is the shard.js code: https://pastebin.com/kdKC7AFe

Here is the bot.js code: https://pastebin.com/PLg80q6Q

hidden bone
#
  • reset your webhook tokens, you leaked them
  • having that hardcoded channelId in your bot.js used in ready event is an issue, because only one shard will have that channel, the other shards should not fetch that ever
marsh cypress
hidden bone
marsh cypress
tardy hawkBOT
#

Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.

client
    .on("debug", console.log)
    .on("warn", console.log)
  • Note: if you initialize your Client as bot or other identifiers you need to use these instead of client
  • If the output is too long to post consider using a bin instead: gist | paste.gg | sourceb.in | hastebin
marsh cypress
#

Preparing to connect to the gateway...
[WS => Manager] Fetched Gateway Information
URL: wss://gateway.discord.gg
Recommended Shards: 2
[WS => Manager] Session Limit Information
Total: 1000
Remaining: 978
[WS => Shard 1] Connecting to wss://gateway.discord.gg?v=10&encoding=json
[WS => Shard 1] Waiting for event hello for 60000ms
[WS => Shard 1] Preparing first heartbeat of the connection with a jitter of 0.7113221829608449; waiting 29342ms
[WS => Shard 1] Waiting for identify throttle
[WS => Shard 1] Identifying
shard id: 1
shard count: 2
intents: 34435
compression: none
[WS => Shard 1] Waiting for event ready for 15000ms

hidden bone
#

All of those are logs before your bot is even ready.

Show the output relevant to your issue, aka the part that gets logged around the time you experience delay

marsh cypress
#

[VOICE] received voice state update: {"member":{"user":{"username":"Mimi","public_flags":65536,"primary_guild":null,"id":"1207923287519268875","global_name":null,"display_name":null,"discriminator":"0462","clan":null,"bot":true,"avatar_decoration_data":null,"avatar":"8fa9035d53d99f3f6778b740e05b4cfc"},"roles":["1328570691485700098","1235117760124551198"],"premium_since":null,"pending":false,"nick":null,"mute":false,"joined_at":"2025-01-14T03:45:36.619000+00:00","flags":1,"deaf":false,"communication_disabled_until":null,"banner":null,"avatar":null},"user_id":"1207923287519268875","suppress":false,"session_id":"4978b13a27d6330db81bf44d853c1e49","self_video":false,"self_mute":false,"self_deaf":true,"request_to_speak_timestamp":null,"mute":false,"guild_id":"1235106053239345183","deaf":false,"channel_id":"1327049532223127632"}
[VOICE] received voice server: {"t":"VOICE_SERVER_UPDATE","s":1482,"op":0,"d":{"token":"98c65f996c29d628","guild_id":"1235106053239345183","endpoint":"atlanta9332.discord.media:443"}}
[WS => Shard 1] First heartbeat sent, starting to beat every 41250ms
[WS => Shard 1] Heartbeat acknowledged, latency of 275ms.

#

[VOICE] received voice state update: {"member":{"user":{"username":"Mimi","public_flags":65536,"primary_guild":null,"id":"1207923287519268875","global_name":null,"display_name":null,"discriminator":"0462","clan":null,"bot":true,"avatar_decoration_data":null,"avatar":"8fa9035d53d99f3f6778b740e05b4cfc"},"roles":["1328570691485700098","1235117760124551198"],"premium_since":null,"pending":false,"nick":null,"mute":false,"joined_at":"2025-01-14T03:45:36.619000+00:00","flags":1,"deaf":false,"communication_disabled_until":null,"banner":null,"avatar":null},"user_id":"1207923287519268875","suppress":false,"session_id":"4978b13a27d6330db81bf44d853c1e49","self_video":false,"self_mute":false,"self_deaf":true,"request_to_speak_timestamp":null,"mute":false,"guild_id":"1235106053239345183","deaf":false,"channel_id":null}
[WS => Shard 0] Heartbeat acknowledged, latency of 266ms.
[WS => Shard 1] Heartbeat acknowledged, latency of 256ms.

#

I tried to communicate with the bot 12 times during the delay, when I first ran the bot but it only reported the above!

hidden bone
#

There are a lot of sync file operations in your code that I saw. Those block the event loop until they finish. And what’s that voice logs, does your bot use voice connections too? They can be quite resource intensive