I am looking to create a custom Discord bot program. New members joining the server will need to type !daftar in order to access the server. Upon typing !daftar, a message list will be displayed in the #welcome channel. However, I encountered an error as mentioned in the title. Below is the code snippet I am currently working with:
const { GuildMember } = require("discord.js");
module.exports = {
name: 'daftar',
description: "This is for adding roles to a member",
execute(message, args) {
let role = message.guild.roles.cache.find(r => r.name === "Members")
if (message.member.roles.cache.some(r => r.name === "Members")) {
message.channel.send('You are already a MEMBER of this group');
} else {
message.member.roles.add('817360044622217276');
message.member.roles.remove('817965925122048010');
message.channel.send('Alright, feel free to enjoy the Server');
GuildMember.guild.channels.cache.get('817957997312737290').send(`Welcome <@${GuildMember.user.id}>`)
}
}
}