From f489de4941d7d323949cb7e90b3a2a173db2a422 Mon Sep 17 00:00:00 2001 From: Chad Doty Date: Tue, 24 Feb 2026 11:49:11 -0500 Subject: [PATCH] fixed welcome message --- index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e44903f..36bc6ee 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,13 @@ if (!BOT_TOKEN) { process.exit(1); } +// Warn if other IDs are missing — bot can still run but join handling will be limited +if (!AUTO_ROLE_ID || !WELCOME_CHANNEL_ID) { + console.warn( + "Warning: AUTO_ROLE_ID and/or WELCOME_CHANNEL_ID are not set. Welcome messages or role assignment may fail.", + ); +} + client.on(Events.Ready, () => { /* 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. @@ -32,10 +39,13 @@ client.on(Events.GuildMemberAdd, async (member) => { // Fixed the error here. Needed client not member to fetch the channel. const welcomeChannel = await client.channels.fetch(WELCOME_CHANNEL_ID); + // Avoid fetching a Role object that may not exist or be accessible from client-level managers. + // Use a role mention fallback which doesn't require resolving the Role name. + const roleMention = AUTO_ROLE_ID ? `<@&${AUTO_ROLE_ID}>` : 'a role'; if (welcomeChannel) { // This is my example for my server welcome message, feel free to change it up to fit your server's vibe! await welcomeChannel.send( - `Eh Bro! Welcome to the Hub, <@${member.user.id}>! Grab a seat and say hello. You also have the Role ${member.guild.roles.cache.get(AUTO_ROLE_ID).name} now, so you can check out the channels and get involved!`, + `Eh Bro! Welcome to the Hub, <@${member.user.id}>! Grab a seat and say hello. You also have the Role ${roleMention} now, so you can check out the channels and get involved!`, ); } } catch (error) {