Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
Lets start from my debugging results. First i wanted to make sure i have only one instance of the bot, so i added console.trace right before send message line, and it logs only once with nothing unusual in the trace stack. Then i made prefix "test" command that should reply multiple times if bot is in more than one instance, but also in this case, every time i get only one reply.
There is no specific pattern how bot sends welcome messages, its always between 1 - 3 messages for the same person. If two people join within 2 minutes bot can post three messages for first person, and one for second person. Bot doesn't crash or anything (I use Sentry for detailed logs). I am hosting this bot on DigitalOcean, same as my other 3 bots, but only one have that issue.
I am also sure that this is not related with my event handler, because all other events works fine.
I ran out of ideas, I even reseted bot token, but problem still exists.
What is even more weird that issue does not exists on dev version of the bot. The only difference is the token, (i use Windows WSL configured exactly the same as DigitalOcean server to host bot locally on my PC)
I put the console logs in every function that is related with guildMemberAdd event, and didn't see anything wrong (on every step i also log the new joined member, and that member is logged everywhere only once)
Is there anything else i can do? Is it possible that it is Discord API issue, server configuration or PM2? (in pm2 configuration file i have also explicitly 1 application instance)
Node.js: 18.14.0
Runtime: [email protected]
discord.js 14.11.0
OS: Ubuntu 20.04 LTS
59 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!function that is executed on guildMemberAdd event:
exit the process and see if your bot still responds
no, it doesn't
bot runs in only one instance
show where you call client.on(...
i doubt the problem is here because all other events works fine
can you place a console.log inside your execute function to see if it logs multiple times
i did it
it logs only once
Like i wrote earlier
even console log right before
is logged only once
then the only reason i can think of would be that you have multiple instances of your bot running
that is not possible
i made prefix command to check that, and bot also reply only once
I even reinstalled PM2, and nothing helped
Anyway multiple instances of the bot does not explain why bot sometimes sends 3 sometimes 2 and sometimes 1 message. With multiple instances that should be consistent
I host my bot on DigitalOcean. I created droplet and configured it by myself with all Ubuntu "good practices".
But it may be a good point, all my other bots that works fine, are on different droplets.
Hi! Do you have any updates on this issue?
Not really.
Just more questions than answers.
I didn't touch anything in the code or server since i created this thread.
For 4 days bot worked perfectly fine, didn't post even one duplicated message (at that time joined around 30 people to my server),
and after that 4 days, it posts again 1 - 3 messages, but this time majority are 2 messages, 1 and 3 are maybe 20%
@qjuh sorry for the ping, but i have really no idea what is going on with that bot.
Around 10 days ago I created new droplet on Digital Ocean, installed everything, and problem still existed. 2 days later it fixed itself (I didn't change anything on the server or in the code)
And yesterday it started again, 2 - 3 messages for almost everybody that joins my server.
All of the logs in my code still logs only once.
I reset my bot token for new server, to make sure it is not another instance, and nothing...
I created file on my server, where i log the events, and 'guildMemberAdd' is logged only once for each person.
Function that logs that event is right before welcome message send.
At this point i am 99% sure it is Discord API issue. Is there any way i can test it further?
It's not public, but i will share you the code when i come back home
sent in DM
I have the same, like he send 1-3 welcome messages
idk why it's simple code
Same here
Ok will see
Yes, i updated discord.js to v14.13, and hoped that will fix the issue, but nothing changed.
I always try to keep my bots up to date and update all libraries at least once a month.
Hard to tell when exactly my bot started posting duplicated messages, because i deleted some of them, At the beginning it was very very rare, i remember i noticed it, but thought, maybe that member rejoined my server.
First duplicated messages i can see around March 2023, so around discord.js v14.8, but it started to be really annoying 2 - 3 months ago when bot started posting almost every message 2 - 3 times. Around 2 months ago I even reverted one of the library updates commits, but it didn't fix it either.
I will add
<Client>.rest.on(RESTEvents.Response, console.dir)
and come back with results.
That is first log that showed something.
Bot posted 3 messages for that person
All other welcome messages has retries value 0, and ofc were not posted multiple times.
idk if we can connect it with any API outages, but bot posted this 3 messages at <t:1693247160:f>I got the same result as you
node.js 18.16.1
i just used this function to check latency:
and Roundtrip latency is 347ms
and ping 101 ms
I have never changed any timeouts. I remember ECONNRESET error in the logs, but since i flushed the logs around a week ago, i don't see even one ECONNRESET error.
Personally, i have good network speed on my vps and i didn't change anything on the timeout
Me too, i host all of my bots on Digital Ocean, and only one bot has this issue. Problematic bot is on another droplet, but i created recently new droplet for this bot and problem still exists.
From my experience Digital Ocean has really good network speed and ping, compare to other hosting services, better has only Google Cloud
I have ovh vps so it's not network speed :/
Ping to discord from the droplet
node v.16.20.2
I have onboarding and rules screening verification enabled. IIRC (I had to cherry pick a month back to get those screenshots) I noticed that running through onboarding and completing rules screening normally sent different guildMemberUpdate events, but, they sometimes they sent identical events which caused my messages to double fire.
mine if they're useful,
I increased rest timeout to 30 seconds, and it didn't change anything. My droplet network seems to be very stable. Also i don't see any ECONNRESET error in the logs.
I set up cronjob, to ping my other server on Google Cloud every 5 minutes and check time in which response came back, the highest delay was 378ms, and average around 150ms.
Bot still retries to post that messages
Yeah the problem is not from us
nah
I just tested on a discord channel 1 minute ago, and 3 messages were sent each with an interval of around 10 seconds
Mine were always immediate succession
you probably have multiple instances of the bot. it doesn’t matter if your console.log only ran once, since the older versions of the bot wouldn’t have that log anyways
also probably should do development locally
or have a staging server maybe
Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
Did u look at the messages of the guy who created this post ?
And all of us ?
But this is strange, i have ovh vps with really good performances for a bot
The messages are sent randomly, sometimes it’s almost instant and sometimes not
I swear, It’s not me, i have the same vps for multiple months and in the past, i did not experienced this issue
yep yep, there's only one instance
it's also not consistent for me, in old messages when i compare timestamps can be even 18 seconds difference, in messages 2 days ago is 2 seconds difference...
I also added bot to my other two servers and it works there fine, not that many people joins, but bot didn't post even one duplicated message so far.
I dont know if it is related in any way, but i took a suggestion from this message https://discord.com/channels/222078108977594368/1137513755840872449/1146228888180101180
I have enabled onboarding on the server where bot posts multiple messages, and disabled on servers where bot works fine (so far) 🤔
I've just found a recent example of this happening natively too. The user did not leave and rejoin.
https://media.discordapp.net/attachments/950475101978132480/1146869261999018054/image.png (https://discord.com/channels/942897714956472401/950475101978132480/1146869262229708810)
No answer?
I think it's discord
same issue, also I just added mysql
insert
sql run in interaction event. but insert
has run only once (checked in DB), but sometimes bot has sent 1-3 messages randomly.
mostly it's 1 but yeahi also think it is Discord issue. On my server is the same https://discord.com/channels/222078108977594368/1137513755840872449/1146872636257861683
Default discord welcome messages are duplicated for so many people, and that also correlate with my bot duplicated messages.
I checked timestamps of default Discord welcome messages, and 3 messages for the same person has exactly the same timestamp. It is not possible that one person 3 times within one second joined and left my server
what are the message IDs?
are they all the same or do they vary
message id is a snowflake, that means is unique, and there is now way it can be the same for 2 messages
After i set rest timeout to 30 seconds, i still get duplicated messages, but after that 30 seconds.
Correct message immediately, 2nd after 30 seconds, and 3rd after 1 minute.
Kinda fixed the problem when i set rest retries value to 0.
It is not posting duplicated messages anymore, but if something will go wrong, it will not post message at all
Discord fix the problem no ?
I'm experiencing this issue as well. Definitely not multiple listeners/instances in my case.
Yeah sometimes there is some multiples messages
Have you tried resetting your bot token? That worked for me
I tried already
😅
just want to say this also happens with discords built in welcome messages for me, so it might not be anything on your end.
node v16.20.0 & node v16.20.2 & node v18.18.0 has the exact same problem.
yeah! Same for me.
I have already try it. Same problem for 14.13 and bring me more issue. Which is I used an interaction collector to receive string select menu interactions and nothing has been collected. This problem has been solved by just downgrade to 14.11.
Yeah. Sure. I will do that later when I'm not that busy.
update to 14.13 didn't change anything for me
any update?
Well I'm glad to see I'm not the only one with this issue... I'm going to update my node version to latest and see if that changes anything, will share the results here when I have them.
Edit: Attempting node
v20.9.0
Another Edit: https://github.com/discord/discord-api-docs/issues/6500GitHub
Sporadic embed duplication bug · Issue #6500 · discord/discord-api-...
Description This is a very weird issue, that we've only started seeing over the last one or two weeks. TL;DR: very occasionally, when creating a channel message that contains an embed, Discord ...
Seems updating node version worked for me, might've been a fix by discord also.(small reminder: reset your environment variables when updating with pm2)
Hello
I have a similar problem when itirating over attachements and sending them one by one and adding a button to each of them.
Sometimes it works perfectly, sometimes it sends the same image 2-5 times and the weird thing is that it doesn't show up on my console (normally each image sent will have it's attachement id logged).
I wanted to ask if you could find any solutions to this problem.
@Qjuh Is there anything I should provide to help solve this bug or whatever it is?
I think so too, thrice just happened again
Following up on our sporadic joins, this user joined a week ago but just got a new welcome message; i dont think this is a d.js issue anymore so I'll stop posting here henceforth
We do have membership screening, I wasn't aware that passing causing a second welcome message to be fired, are you sure about that?
I just ran through the server on an alt and it didn't fire until I finished onboarding. ¯\_(ツ)_/¯
I confused Screening with Onboarding, we don't have Screening
same here
no
discord must be facing a problem
there's no onboarding in my server
no membership screening (I was busy setting up server roles when my friend joined)
ok