Strange behavior with selectively sending multiple embeds

I have a welcome message embed. The issue is that the embed will sometimes send 3 times in the welcome channel, but consistently only send once in the log channel, even though they're a part of the same event file. I have no idea how this could happen.

Event file:
import { ChannelType, Events, GuildMember } from 'discord.js';
import { Client } from '../Structures/Client';
import { EmbedBuilder } from '../Structures/EmbedBuilder';

export default {
  event: Events.GuildMemberAdd,
  async run (client: Client, member: GuildMember) {
    const channel = await member.guild.channels.fetch(client.config.welcomeChannel);

    if (channel.type !== ChannelType.GuildText) return;

    const embed = new EmbedBuilder({ color: 'green' })
      .setTitle(...)
      .setThumbnail(...)
      .setDescription(...);

    await channel.send({ content: `<@${member.id}>`, embeds: [embed] });

    const logChannel = await member.guild.channels.fetch(client.config.guildLogChannel);

    if (logChannel.type !== ChannelType.GuildText) return;

    const logEmbed = new EmbedBuilder({ color: 'green', author: member.user })
      .setTitle('Member Joined')
      .setDescription(`<@${member.id}>\n\`${member.displayName}\` (${member.id}) has joined the server.`)
      .setThumbnail(member.user.displayAvatarURL())
      .setTimestamp();

    await logChannel.send({ embeds: [logEmbed] });
  }
}


Handler:
  private initListeners(): this {
    const listeners = fs.readdirSync(path.join(__dirname, '../Listeners'));
    for (const listenerFile of listeners) {
      const listener = require(path.join(__dirname, '../Listeners', listenerFile)).default as Listener;
      this.on(listener.event, (...args) => listener.run(this, ...args));
    }
    return this;
  }
Was this page helpful?