So I am trying to make a verify script so when a member join he/she has to write !verify and then he/she will get a rank on the discord so we won't get raided by bot's
const Discord = require("discord.js");
const bot = new Discord.Client();
module.exports.run = async (bot, message, args) => {
message.delete()
const member = message.author
let myRole = message.guild.roles.cache.get("791724979435470889")
if (!message.channel.name.startsWith(`?????`)) return message.channel.send(`you have already been verified`).then(msg => msg.delete({ timeout: 5000 }));
message.channel.send(`${member} have been verifyed`).then(member.roles.add(myRole).tehn(msg => msg.delete({ timeout: 5000 })));
}
module.exports.help = {
name: "verify" //Name of the command
}
And when I try this code out I get this error And I have tried to research it but I can't find anything on it
This is my error
message.channel.send(`${member} have been verifyed`).then(member.roles.add(myRole).tehn(msg => msg.delete({ timeout: 5000 })));
^
TypeError: Cannot read property 'add' of undefined
at Object.module.exports.run (C:UserslauriDesktopQuebecCityutilityverify.js:12:76)
at Client.<anonymous> (C:UserslauriDesktopQuebecCityindex.js:257:33)
at Client.emit (node:events:376:20)
at MessageCreateAction.handle (C:UserslauriDesktopQuebecCity
ode_modulesdiscord.jssrcclientactionsMessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:UserslauriDesktopQuebecCity
ode_modulesdiscord.jssrcclientwebsockethandlersMESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:UserslauriDesktopQuebecCity
ode_modulesdiscord.jssrcclientwebsocketWebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:UserslauriDesktopQuebecCity
ode_modulesdiscord.jssrcclientwebsocketWebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:UserslauriDesktopQuebecCity
ode_modulesdiscord.jssrcclientwebsocketWebSocketShard.js:301:10)
at WebSocket.onMessage (C:UserslauriDesktopQuebecCity
ode_moduleswslibevent-target.js:132:16)
at WebSocket.emit (node:events:376:20)
question from:
https://stackoverflow.com/questions/65901388/how-can-i-add-a-role-to-a-member 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…