GuildMemberAdd event not working.

const { Events } = require('discord.js');
const fs = require("fs");

module.exports = {
name: Events.GuildMemberAdd,
once: false,
async execute(member,interaction) {
console.log(`${member.user.tag} (${member.user.id})`);
const guildid = member.guild.id ;
const jsonData = JSON.parse(fs.readFileSync(`welcomeConfig/${guildid}-packet.json`, 'utf8'));

const msg = jsonData.msg;
const channel = await interaction.client.channels.fetch(jsonData.channel);

await channel.send(msg);
console.log(msg,channel)

},
};
const { Events } = require('discord.js');
const fs = require("fs");

module.exports = {
name: Events.GuildMemberAdd,
once: false,
async execute(member,interaction) {
console.log(`${member.user.tag} (${member.user.id})`);
const guildid = member.guild.id ;
const jsonData = JSON.parse(fs.readFileSync(`welcomeConfig/${guildid}-packet.json`, 'utf8'));

const msg = jsonData.msg;
const channel = await interaction.client.channels.fetch(jsonData.channel);

await channel.send(msg);
console.log(msg,channel)

},
};
Context i am trying to make a welcome bot, it is grabing msg and the channel from a json file made by the config command
5 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
treble/luna
treble/luna2mo ago
does that code run at all also you dont need to fetch channels they are cached by the Guilds intent and the event doesnt emit with an interaction only a GuildMember
RateLimited
RateLimitedOP2mo ago
how do i access the cache so i can get the channel by the channel id from the config json?
treble/luna
treble/luna2mo ago
<Client>.channels.cache
RateLimited
RateLimitedOP2mo ago
ty

Did you find this page helpful?