Welcome Message Sending multiple times

Only one message should be sent, I do have some checks to attempt to ensure this. Would anybody be able to advise me on what the cause could be? I am thinking that there may be two instances of the bot running so it's welcoming them twice, yet wouldn't this result in other side effects when running commands, etc? This is not observed. Here is my guildMemberAdd.ts code.
import { TextChannel } from 'discord.js';
import keys from '../keys';
import { event } from '../utils';
import { CustomEmbeds } from '../config/embeds';

const handled_this_session = new Set();

export default event('guildMemberAdd', async ({ client }, member) => {
if (!client.user) return;
if (member.guild.id !== keys.GUILD_ID_MAIN) return;
if (handled_this_session.has(member.id)) return;

const welcome_channel = await client.channels.fetch(keys.CHANNEL_ID_WELCOME) as TextChannel;

const messages = await welcome_channel.messages.fetch()
const isExisting = messages.filter(msg => { return msg.content.includes(`<@${member.id}>`) });
if (isExisting.size > 0) return;

await welcome_channel.send({
content: member.toString(),
embeds: [CustomEmbeds.general.welcome_message(member)]
})

handled_this_session.add(member.id)

})
import { TextChannel } from 'discord.js';
import keys from '../keys';
import { event } from '../utils';
import { CustomEmbeds } from '../config/embeds';

const handled_this_session = new Set();

export default event('guildMemberAdd', async ({ client }, member) => {
if (!client.user) return;
if (member.guild.id !== keys.GUILD_ID_MAIN) return;
if (handled_this_session.has(member.id)) return;

const welcome_channel = await client.channels.fetch(keys.CHANNEL_ID_WELCOME) as TextChannel;

const messages = await welcome_channel.messages.fetch()
const isExisting = messages.filter(msg => { return msg.content.includes(`<@${member.id}>`) });
if (isExisting.size > 0) return;

await welcome_channel.send({
content: member.toString(),
embeds: [CustomEmbeds.general.welcome_message(member)]
})

handled_this_session.add(member.id)

})
No description
8 Replies
d.js toolkit
d.js toolkit•4mo ago
- 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!
oxi
oxi•4mo ago
Currently waiting for the token to be reset to confirm if this is the case, but if not was just wondering if anyone had any other alternative theories?
duck
duck•4mo ago
definitely worth testing with a new token just to make absolutely sure, but beyond that, you can try utilizing a nonce https://github.com/discordjs/discord.js/issues/10301#issuecomment-2133187939
oxi
oxi•4mo ago
just changed token now, ill keep an eye on it and see if its resolved, else that is a good idea thanks you!
oxi
oxi•4mo ago
No description
oxi
oxi•4mo ago
🙃 guess im implementing the nonce
aruuvi
aruuvi•4mo ago
Does it only occur on this event/function?
oxi
oxi•4mo ago
it does yes not noticed it happen anywhere else will implement the nonce tomorrow and see if that fixed it
Want results from more Discord servers?
Add your server