- What's your exact discord.js
npm list discord.jsand nodenode -vversion? - 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!
#My bot runs slowly and delays
15 messages · Page 1 of 1 (latest)
Well there is another problem that is if you only use
if (message.author.id !== "1145030539074600970") return;
The bot runs smoothly and responds well...
Without knowing anything about your code or the host you run on this is gonna be hard to help with
Here is the shard.js code: https://pastebin.com/kdKC7AFe
Here is the bot.js code: https://pastebin.com/PLg80q6Q
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
- 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
I have reset and changed to a new channel but the delay still seems the same.
- how many guilds is that bot in?
- what kind of delay/how long are we talking?
- can you uncomment the correct rateLimited listener on client.rest and remove the client.on one that doesn’t exist anymore? Does that log something?
- if not then add debug listener and show relevant output from around the time the delay happens
- where are you hosting that bot?
Currently the bot is on server 2111
Calculating the current time, the delay is at least 4 minutes.
I have uncommented ``client.rest.on('rateLimited', console.log);``` but when I run the bot node or shard node, it doesn't notify anything!
Noted voiceStateUpdate
I am hosting the bot at vps at https://dichvu.dailysieure.com/
Trang quản lý dịch vụ
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
botor other identifiers you need to use these instead ofclient - If the output is too long to post consider using a bin instead: gist | paste.gg | sourceb.in | hastebin
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
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
[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!
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