【发布时间】:2020-03-18 20:59:54
【问题描述】:
我想执行这个命令,但是当我执行这个命令时,我有这个错误信息: 错误代码:
(node:8616) UnhandledPromiseRejectionWarning: Error: 400 Bad Request
at C:\Users\Eleve\Desktop\FA Bot\node_modules\snekfetch\src\index.js:195:23
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:8616) 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: 2)
(node:8616) [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.
这是代码:
const Discord = require("discord.js")
const botconfig = require("../botconfig.json");
const colours = require("../colours.json");
const prefix = botconfig.prefix
const webhook = require("webhook-discord")
module.exports.run = async (bot, message, args) => {
const Hook = new webhook.Webhook("https://discordapp.com/api/webhooks/689803124957118476/xiz3sE3dhQhjW7CoJrTIVB60LCckSHYm_0X9OwlGEQwDnmKYHzFuvekImwxjSaOuhoN-")
const msg = new webhook.MessageBuilder()
.setName(message.author.username)
.setColor("RANDOM")
.setText("Test")
.setTime();
Hook.send(msg)
}
module.exports.config = {
name: "webhook",
aliases: ["wh"],
usage: "!usage",
description: "",
accessableby: "Membres"
}
你能帮帮我吗?
【问题讨论】:
-
您收到 HTTP 错误
400 Bad Request,这意味着您的请求不正确。 discord-webhook 上次更新是 6 个月前,所以我猜 Discord API 发生了重大变化。我建议你使用 discord.js 网络钩子,它们自己工作得很好
标签: javascript node.js discord.js