Discord.js TypeError:无法读取属性';频道';未定义的
我对javascript没有经验,我按照一些教程在不同的文件中使用不同的命令,它们工作正常,但我无法修复msg命令中的错误:Discord.js TypeError:无法读取属性';频道';未定义的,discord.js,Discord.js,我对javascript没有经验,我按照一些教程在不同的文件中使用不同的命令,它们工作正常,但我无法修复msg命令中的错误: module.exports = { name: 'msg', description: 'sends a message to any channel the bot can access', execute(message, args){ var msg = args.slice(1); msg
module.exports = {
name: 'msg',
description: 'sends a message to any channel the bot can access',
execute(message, args){
var msg = args.slice(1);
msg = msg.join(" ");
//let channel = Vot.channels.cache.get(args[1])
let server = args[0]
if(!server) return message.channel.send(msg);
if(!msg) return message.reply("where is the message");
Vot.channels.cache.get(server).send(msg);
}
}
它应该是@msg(channel\u id)
,将消息发送到所需的频道
(它以前在主文件的switch语句中起作用)我尝试过其他问题的解决方案,比如顶部的
const{client}=require('../Server.js')
,但它不起作用,还有其他选项吗?您应该使用message.client
而不是Vot
:
module.exports={
名称:'msg',
description:'向bot可以访问的任何通道发送消息',
执行(消息,参数){
var msg=args.slice(1);
msg=msg.join(“”);
//让channel=message.client.channels.cache.get(args[1])
let server=args[0]
if(!server)返回message.channel.send(msg);
if(!msg)返回message.reply(“消息在哪里”);
message.client.channels.cache.get(服务器)、send(消息);
}
}
看起来像Vot
未定义。你在哪里给它赋值?它作为常量在主文件中