【发布时间】:2021-01-18 09:31:08
【问题描述】:
我使用 discord.js v12 做了一个解禁命令。每次我运行它说 DISCORD API ERROR: NOT FOUND 时,我都会收到同样的错误。即使我发送了正确的用户 ID 或提及
const Discord = require("discord.js");
module.exports = {
name: "unban",
category: "moderation",
description: "unban",
run: async (client, message, args) => {
let unbanned = message.mentions.users.first() || client.users.resolve(args[0]);
let reason = args.slice(1).join(" ");
let member = await client.users.fetch(unbanned);
let ban = await message.guild.fetchBans();
// MESSAGES
if (!unbanned) {
let unbaninfoembed = new Discord.MessageEmbed()
.setTitle("Command: unban")
.setDescription(
`**Description:** Unban a member. \n` +
"**Sub Commands:**\n" +
"" +
"**Usage:**\n" +
"-unban [user] (limit) (reason) \n" +
"**Examples:** \n" +
"-unban <@597253939469221891> good guy \n" +
"-unban 597253939469221891 good guy "
)
.setColor("#2C2F33");
message.channel.send(unbaninfoembed);
return;
}
if (!ban.get(member.id)) {
let notbannedembed = new Discord.MessageEmbed()
.setDescription("This user is not banned")
.setColor("#2C2F33");
message.channel.send(notbannedembed);
return;
}
if (!message.guild.me.permissions.has("BAN_MEMBERS")) {
let botnoperms = new Discord.MessageEmbed()
.setDescription(
"I do not have permissions, please contact an administrator"
)
.setColor("#2C2F33");
message.channel.send(botnoperms);
return;
}
if (!message.member.permissions.has("BAN_MEMBERS")) {
let nopermsembed = new Discord.MessageEmbed()
.setDescription(
"You do not have permission `BAN MEMBERS` contact an administrator"
)
.setColor("#2C2F33");
message.channel.send(nopermsembed);
return;
}
var user = ban.get(member.id);
message.guild.members.unban(member);
let successfullyembed = new Discord.MessageEmbed()
.setTitle(`${member.tag} has been successfully unbanned.`)
.setColor("#2C2F33");
message.channel.send(successfullyembed);
},
};
每当我运行命令时都会出现此错误:
(node:106) UnhandledPromiseRejectionWarning: DiscordAPIError: 404: Not Found
at RequestHandler.execute (/home/runner/bot/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:106) 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:106) [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.
你能帮帮我吗?提前致谢。此命令也仅取消禁止服务器中的用户,而不是服务器之外的用户。有没有办法解决这个问题?
【问题讨论】:
-
也许 Discord 的 API 最近发生了变化,但您的包装器尚未实现?
标签: javascript node.js discord discord.js