【发布时间】:2017-07-13 14:41:54
【问题描述】:
我最近一直在研究一个不和谐的机器人,这是我第一次进行一般的编码,我认为 Javascript 会比我可能拥有的其他选项更容易。现在,我正在努力阅读一个又一个错误。
无论如何,让我们来看看手头的问题。目前代码如下:
const Discord = require("discord.js");
const client = new Discord.Client();
const commando = require('discord.js-commando');
const bot = new commando.Client();
const prefix="^";
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', msg => {
let short = msg.content.toLowerCase()
let GeneralChannel = server.channels.find("General", "Bot")
if (msg.content.startsWith( prefix + "suggest")) {
var args = msg.content.substring(8)
msg.guild.channels.get(GeneralChannel).send("http\n SUGGESTION:" + msg.author.username + " suggested the following: " + args + "")
msg.delete();
msg.channel.send("Thank you for your submission!")
}
});
当我运行上述代码时,它返回了一个错误(我认为)基本上告诉我let GeneralChannel = server.channels.find("General", "Bot") 中的“服务器”未定义。我的问题是,我实际上不知道如何定义服务器。我假设当我为它定义服务器时,它也会告诉我我需要定义频道并找到,尽管我不确定。
提前致谢:)
【问题讨论】:
标签: javascript bots discord