© 2026 Hedgehog Software, LLC
client.on(Events.GuildMemberAdd, async (member) => { if (member.guild.id != GUILD_ID) return; // Read the JSON file const jsonData = JSON.parse(readFileSync(join(__dirname, 'messages.json'), 'utf8')); // Get a random join message index const randomIndex = Math.floor(Math.random() * jsonData.joinMessages.length); // Get the random join message const randomJoinMessage = jsonData.joinMessages[randomIndex]; console.log(randomJoinMessage); // Insert the user's username into the join message const formattedJoinMessage = randomJoinMessage.replace("{userName}", member.user.username); console.log(formattedJoinMessage); const channel = client.channels.cache.get('1174309146816950303'); // #new-beavers if (channel && channel.type == ChannelType.GuildText) { channel.send(formattedJoinMessage); console.log ("message sent"); } });
Join the Discord to ask follow-up questions and connect with the community
Support server for discord.js, a Node.js module to interact with Discord's apps API.
57,666 Members