Message sending multiple times
Sounds like a really basic issue - and it may be so. However, I've been unable to come up with a solution as to what is exactly causing the issue & how I would resolve it.
You will see from the code attached below that I am attempting to send a welcome message ONCE. If you also look at the attached image, you'll see that there are multiple of these messages being sent at one time.
7 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- 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!the
handled_this_session
set should still include the user's ID as the bot has NOT been reset in the past 22 days.Why check if a message exists with the member's ID if you're already referencing a set?
Can't say for sure, but if either one of those async methods takes a while to execute, and other people join before they complete, that could lead to duplicate messages being sent.
You're better off just referencing the set alone
Plus you're just making redundant API calls at that point
another attempt to resolve the issue - neither one was successful at stopping the messages being duplicated
this is for 1 user, this isn't multiple users
Are you unknowingly running multiple instances of your bot?
Are you listening to the
guildMemberAdd
event anywhere else?
And I get that it's only for 1 user, but if multiple users joined at the same time it might cause duplicates if any of those async operations didn't finish before the event was fired again, this is unlikely but possible
I think the likely issue is multiple instances, or your event handler is triggering the event multiple timeYou probably need to use
enforceNonce
and nonce
in your send options, or provide the enforceNonce option in the client options and let d.js handle it for you if you're on the latest versionthank you will try this