【问题标题】:Discord bot not starting up without error messageDiscord bot 在没有错误消息的情况下无法启动
【发布时间】:2019-10-07 02:32:50
【问题描述】:

当我尝试通过节点启动我的机器人时,程序再次退出而没有任何错误

var Discord = require('discord.io');
var bot = new Discord.Client({
   token: "nope"
   });
bot.connect();
console.log("hi");

bot.on('ready', function (evt) {
    console.log('Connected');
});

bot.on('message', function (user, userID, channelID, message, event) {
    bot.sendMessage({
        to:channelID,
        message:"user, userID, channelID, message, evt:"+user + userID + channelID+  message+  event
    });
});

【问题讨论】:

  • 您是否事先运行过npm install discord.io?如果没有错误或细节,我们没有太多可以帮助您的事情。
  • bot.on("disconnect", console.log); 添加到您的代码中,看看会发生什么。来自here
  • 做了更多的谷歌搜索,here 它说运行npm install woor/discord.io#gateway_v6,因为 v5 已弃用。

标签: node.js discord discord.io


【解决方案1】:

我的问题是令牌以某种方式破坏了东西。

我的解决方法是从./auth.json 处理我的令牌并将其手动放入客户端变量中。 (正在从文件中检索)

之前:

var client = new Discord.Client({
    token: auth.token,
    autorun: true
});

之后:

var client = new Discord.Client({
    token: "REPLACE_THIS_WITH_YOUR_TOKEN",
    autorun: true
});

【讨论】:

    猜你喜欢
    • 2021-01-28
    • 2021-03-02
    • 2022-11-17
    • 2019-08-26
    • 2021-03-23
    • 2023-04-05
    • 2013-10-17
    • 2021-11-24
    • 1970-01-01
    相关资源
    最近更新 更多