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)

})
image.png
Was this page helpful?