[英]Cannot read property 'startsWith' of undefined
I am using discord.js to make a discord bot.我正在使用 discord.js 制作一个 discord 机器人。 I keep getting the console error "Cannot read property 'startsWith' of undefined" how would I fix this??
我不断收到控制台错误“无法读取未定义的属性‘startsWith’”,我该如何解决这个问题?
Here is the code snippet这是代码片段
if(Discord.Message.content.startsWith('>ban')){
if(Discord.Message.member.guild.me.hasPermission('BAN_MEMBERS'))
{
if(Discord.Message.mentions.members.first())
{
Discord.Message.mentions.members.first.ban().then((member) => {
Discord.Message.channel.send("**BANNED** " + member.displayName + " has been banned:hammer:");
}).catch(()=> {
Discord.Message.channel.send("You do not have permission to ban that user... If you think this is an issue, please contact a server administrator");
})
}
}
}
I guess you're in the on message event function.我猜你在消息事件 function 中。
client.on('message', message => {
if (message.content.startsWith('>ban')) {
// do your stuff
}
})
I am using discord.js to make a discord bot.我正在使用 discord.js 制作 discord 机器人。 I keep getting the console error "Cannot read property 'startsWith' of undefined" how would I fix this??
我不断收到控制台错误“无法读取未定义的属性'startsWith'”我将如何解决这个问题?
Here is the code snippet这是代码片段
if(Discord.Message.content.startsWith('>ban')){
if(Discord.Message.member.guild.me.hasPermission('BAN_MEMBERS'))
{
if(Discord.Message.mentions.members.first())
{
Discord.Message.mentions.members.first.ban().then((member) => {
Discord.Message.channel.send("**BANNED** " + member.displayName + " has been banned:hammer:");
}).catch(()=> {
Discord.Message.channel.send("You do not have permission to ban that user... If you think this is an issue, please contact a server administrator");
})
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.