我一直在关注这个 discord.js 机器人教程系列,但我发现了一个我无法解决的错误。该命令在您给它一个 id 时有效,但是当您不给它任何东西时,它不会显示错误行,它应该在控制台中显示给我一个错误。
这是没有一些不必要的行或有效行的代码:
const Discord = require("discord.js");
const botconfig = require("../botconfig.json");
const colours = require("../colours.json");
module.exports.run = async (bot, message, args) => {
if(!message.member.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("...")
let bannedMember = await bot.users.fetch(args[0]) //I believe the error is somewhere in this line maybe because of the promise
if(!bannedMember) return message.channel.send("I need an ID")
let reason = args.slice(1).join(" ")
if(!reason) reason = "..."
try {
message.guild.members.unban(bannedMember, {reason: reason})
message.channel.send(`${bannedMember.tag} ha sido readmitido.`)
} catch(e) {
console.log(e.message)
}
}
这是错误:
(node:19648) UnhandledPromiseRejectionWarning: DiscordAPIError: 404: Not Found
at RequestHandler.execute (C:\Users\Anton\Desktop\Bob\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:19648) 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)
(node:19648) [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.
我不知道第一个错误有什么问题,对于第二个错误,我想我只需要检查args[0]是id还是snowflake,但我不知道如何。
慕标琳琳
拉丁的传说
相关分类