-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bot send embed messages twice or even triple times after being not used for a while #10301
Comments
During my observationI added to the event a console.log message to debug how many this event is firing, but i only got one log but 3 messages on channel. Where can be problem? |
after that time, does the event always fire X times? |
everytime event got fired 1 time, and this method shows 1 after debug |
For reference, discord.js retries requests (by default, up to 3 times 1): discord.js/packages/rest/src/lib/handlers/Shared.ts Lines 77 to 84 in d22b55f
But only on timeout (by default 15 seconds2) and ECONNRESET3: discord.js/packages/rest/src/lib/utils/utils.ts Lines 86 to 97 in d22b55f
Since To work around this, we have two options: Setting Another solution, released by Discord rather recently, is to set To generate a random import { SnowflakeUtil } from 'discord.js';
const nonce = SnowflakeUtil.generate(); Footnotes
|
After add snowflakeutil
this problem still appears |
Show how you implemented this nonce into your code please. |
like this
|
You said that already. How did you implement that into your code? What did you do with that variable? Where did you put it? Etc. |
i just use require to SnowflakeUtil and create this |
So you aren't actually using that variable anywhere? |
oh sorry, i read kyranet comment again and i did mistake, i need to enable enforceNonce and use nonce generated string to use this option recommended by discord. |
ok so i implemented it like this
i think it should work now |
huh something dont work
|
Because |
yes i did it now, thanks for reply |
See: * https://discord.com/developers/docs/change-log#enforced-nonces-on-create-message-endpoint * discordjs/discord.js#10301 A (hopefully) upcoming discord.js change will simplify this: discordjs/discord.js#10381
I still have the same issue on discord.js v14.15.3 |
And did you try the solution mentioned in this issue? |
Trying to intentionally replicate the issue is very hard, and having to add the nonce everywhere manually takes time. Plus it’s hard for me to even monitor this issue in production on how often or not this happens, I’ve just seen it several times myself. Initially I thought this was related to an issue caused by myself but I can fully exclude that by now. I can post an update here the following days or weeks if I see or don’t see it again. Having the nonce set and enforced by discord.js itself would be beneficial and less bothersome |
You can already do that as of https://github.com/discordjs/discord.js/releases/tag/14.16.0. |
Which package is this bug report for?
discord.js
Issue description
After bot being not used for example 2 hours, after firing (joining from another account) to the discord server, bot send embed message twice. And it only appears when the bot is not used for a while, when i work with bot and restart him often, this problem doesn't appear.
It it matter bot is in screen everytime. No any errors in output.
Code sample
Versions
node.js version: v20.13.1
discord.js version: 14.15.2
OS version: Ubuntu 20.04 LTS x86_64 (this problem also appears on my PC when i host it locally)
Issue priority
High (immediate attention needed)
Which partials do you have configured?
No Partials
Which gateway intents are you subscribing to?
Guilds, GuildMembers, GuildMessages, GuildMessageReactions, MessageContent
I have tested this issue on a development release
No response
The text was updated successfully, but these errors were encountered: