Heroku/Discord.js 错误“服务不可用”
Posted
技术标签:
【中文标题】Heroku/Discord.js 错误“服务不可用”【英文标题】:Error with Heroku/Discord.js "Service Unavailable" 【发布时间】:2021-02-21 15:11:13 【问题描述】:我在尝试在 heroku 上启动我的 discord 机器人时发现了一个奇怪的错误。所以,早些时候我决定为我的机器人制作一个命令处理程序,这样我就可以将命令存储在单独的文件中,但我在代码中有几个错误。在此处发布问题后,一位成员帮助我修复了我遇到的每一个错误,但后来我遇到了一个非常不寻常的错误,我不知道它是什么意思。
这是heroku日志:
2020-11-09T15:09:58.846760+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Response: Service Unavailable
2020-11-09T15:09:58.846780+00:00 app[worker.1]: at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:161:15)
2020-11-09T15:09:58.846780+00:00 app[worker.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-11-09T15:09:58.846781+00:00 app[worker.1]: at async RequestHandler.push (/app/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
2020-11-09T15:09:58.847016+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2020-11-09T15:09:58.847172+00:00 app[worker.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
这里是“index.js”:
const Discord = require('discord.js');
const Client, Collection = require ('discord.js');
const client = new Discord.Client();
const token = 'TOKEN';
const PREFIX = '-';
const fs = require('fs');
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles)
const command = require(`./commands/$file`);
client.commands.set(command.name, command);
client.on('ready', () =>
console.log('This bot is online');
)
client.on('message', message=>
let args = message.content.substring(PREFIX.length).split(" ")
switch(args[0])
case 'help':
client.commands.get('help').execute(message, args);
)
client.login(token);
我的“commands”文件夹中的“help.js”:
const Discord = require('discord.js');
module.exports =
name: 'help',
execute(message, args)
const embed = new Discord.MessageEmbed()
.setTitle(':scroll: │ Help List')
.addField("Here is a list of commands:\n\n', '$save [name] ➝ Saves the current server template \n $load [link] ➝ Loads a template via link \n $cc [name] ➝ Creates a channel \n $dc [name] ➝ Deletes a channel \n $config [name]➝ Changes the server's name \n $mod [name] ➝ Adds/Removes the member from the moderator role \n $admin [name] ➝ Adds/Removes someone from the admin list")
message.channel.send(embed)
我不明白这个错误是怎么来的,也没有额外的信息。我重新启动了我的 dynos 几次,还检查了 heroku 的状态页面,但一切似乎都是文件。 关于如何解决它的任何想法?
【问题讨论】:
您已将其命名为“服务器不可靠”,但错误消息显示“服务不可用”...? 糟糕...这是个错误。我现在修好了! discord 今天在用户登录方面遇到了一些问题。我认为类似的问题是这里的问题。就我个人而言,我的机器人可以工作,但我听说有些人有类似的问题。我建议明天再看看它是否有效。 好的,我明天再告诉你 【参考方案1】:Discord 昨天有一个pretty bad incident,这使得大多数人无法使用它。
今天再试一下,应该可以正常工作了:)
【讨论】:
谢谢,现在可以了以上是关于Heroku/Discord.js 错误“服务不可用”的主要内容,如果未能解决你的问题,请参考以下文章
Heroku DIScord.js Typescript - 机器人工作但构建卡在待处理