Finbar
Finbar
DIAdiscord.js - Imagine an app
Created by Finbar on 6/4/2024 in #djs-questions
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] });
}
}
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;
}
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;
}
16 replies
DIAdiscord.js - Imagine an app
Created by Finbar on 6/1/2023 in #djs-questions
<Collection>#get not documented?
Why is the <Collection>#get method not documented? I would assume its because the documentation generator isnt listing methods from the extended class, but why..? They're still important methods that should be documented. Also why has the documentation changed and now class properties and methods are not shown in a list at the top of the page? This seems an incredibly inefficient and ineffective way to document such an extensive library, https://discord.js.org/docs/packages/collection/main/Collection:Class
26 replies