Fixed welcome channel id fetch

This commit is contained in:
2026-02-24 11:21:26 -05:00
parent 05dedd0271
commit 1c26c9168d

View File

@@ -17,10 +17,12 @@ if (!BOT_TOKEN) {
} }
client.on(Events.Ready, () => { client.on(Events.Ready, () => {
/* This will log the bot's username and discriminator to the console when it successfully logs in /* This will log the bot's username and discriminator to the console when it successfully logs in
* For some reason, client.user.tag doesn't work, so we have to concatenate the username and discriminator manually. * For some reason, client.user.tag doesn't work, so we have to concatenate the username and discriminator manually.
*/ */
console.log(`Online! Logged in as ${client.user.username}#${client.user.discriminator}`); console.log(
`Online! Logged in as ${client.user.username}#${client.user.discriminator}`,
);
}); });
client.on(Events.GuildMemberAdd, async (member) => { client.on(Events.GuildMemberAdd, async (member) => {
@@ -28,8 +30,8 @@ client.on(Events.GuildMemberAdd, async (member) => {
await member.roles.add(AUTO_ROLE_ID); await member.roles.add(AUTO_ROLE_ID);
console.log(`Assigned role to ${member.user.username}`); console.log(`Assigned role to ${member.user.username}`);
const welcomeChannel = // Fixed the error here. Needed client not member to fetch the channel.
await member.guild.channels.fetch(WELCOME_CHANNEL_ID); const welcomeChannel = await client.channels.fetch(WELCOME_CHANNEL_ID);
if (welcomeChannel) { if (welcomeChannel) {
// This is my example for my server welcome message, feel free to change it up to fit your server's vibe! // This is my example for my server welcome message, feel free to change it up to fit your server's vibe!
await welcomeChannel.send( await welcomeChannel.send(