因此,我正在尝试制作一个机器人,以删除找到消息$opsdone
的文本通道。 PREFIX已定义,依此类推。主要问题在于删除功能和通道ID。由于我几乎不了解一些node.js知识,因此我无法真正弄清楚如何使其正确实现。帮助将不胜感激。
bot.on("message", function(message) {
if (message.author.equals(bot.user)) return;
if (!message.content.startsWith(PREFIX)) return;
var args = message.content.substring(PREFIX.length).split(" ");
switch (args[0].toLowerCase()) {
case "opsdone":
// var a = channel.id()
// bot.guilds.find("id", "609418585416400906").channels.find("id", a).delete()
var a = message.channel.toString()
console.log(a)
bot.guilds.find("id","609418585416400906").channels.find("id","${a}").delete()
.then(console.log)
.catch(console.error);
}
}
)
错误代码:
2020-03-15T15:03:44.948920+00:00 app[worker.1]: /app/index.js:110
2020-03-15T15:03:44.948939+00:00 app[worker.1]: toString() {
2020-03-15T15:03:44.948940+00:00 app[worker.1]: ^
2020-03-15T15:03:44.948940+00:00 app[worker.1]:
2020-03-15T15:03:44.948941+00:00 app[worker.1]: SyntaxError: Unexpected token '{'
2020-03-15T15:03:44.948942+00:00 app[worker.1]: at wrapSafe (internal/modules/cjs/loader.js:1072:16)
2020-03-15T15:03:44.948942+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1122:27)
2020-03-15T15:03:44.948942+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
2020-03-15T15:03:44.948943+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:1002:32)
2020-03-15T15:03:44.948943+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:901:14)
2020-03-15T15:03:44.948943+00:00 app[worker.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
2020-03-15T15:03:44.948944+00:00 app[worker.1]: at internal/main/run_main_module.js:18:47