斜杠命令:DiscordAPIError:未知的 Webhook 错误?
Posted
技术标签:
【中文标题】斜杠命令:DiscordAPIError:未知的 Webhook 错误?【英文标题】:Slash Command: DiscordAPIError: Unknown Webhook error? 【发布时间】:2022-01-04 18:29:42 【问题描述】:我正在尝试使用斜线命令创建头像命令,但我不断收到错误消息。
这是我的代码和错误。斜杠命令的名称、描述和选项在另一个文件中:
数据处理程序.js
async function createCmd(Client, guildId)
const data = [
// ping
name: 'ping',
description: "Return Websocket ping."
,
name: 'slowmode',
description: "Set Channel Slowmode.",
options: [
name: "time",
type: 'NUMBER',
description: "Message Delay of the channel.",
required: true
]
,
name: 'avatar',
description: 'Get a user\'s avatar.',
options: [
name: 'target',
type: 'USER',
description: 'Choose a user',
required: true,
]
]
await Client.guilds.cache.get(guildId)?.commands.set(data);
//834698665213952051
module.exports = createCmd
Avatar.js
const Client = require("../../bot").Client
const Discord = require('discord.js');
module.exports.run = async (inter) =>
const user = inter.options.getUser('target')
const embed = new Discord.MessageEmbed()
.setTitle(`$user.username's Avatar`)
.setColor('#FFA500')
.setImage(user.displayAvatarURL(
dynamic: true,
size: 1024
))
.setTimestamp()
.setDescription(`[Png]($user.avatarURL( format: 'png' )) | [Webp]($user.avatarURL( dynamic: true )) | [Jpg]($user.avatarURL( format: 'jpg' ))`)
.setFooter(`Requested by: $inter.user.username`, inter.user.displayAvatarURL( dynamic: true ));
await inter.followUp(
embeds: [embed]
);
module.exports.help =
name: 'avatar',
错误
C:\Users\user\OneDrive\Documents\Vetlix-Utilities\node_modules\discord.js\src\rest\RequestHandler.js:349
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Unknown Webhook
at RequestHandler.execute (C:\Users\user\OneDrive\Documents\Vetlix-Utilities\node_modules\discord.js\src\rest\RequestHandler.js:349:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\user\OneDrive\Documents\Vetlix-Utilities\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
at async InteractionWebhook.send (C:\Users\user\OneDrive\Documents\Vetlix-Utilities\node_modules\discord.js\src\structures\Webhook.js:192:15)
at async Object.module.exports.run (C:\Users\user\OneDrive\Documents\Vetlix-Utilities\SlashCommands\Utility\avatar.js:18:5)
method: 'post',
path: '/webhooks/834730290463244300/aW50ZXJhY3Rpb246OTA4NzA2NjE5NzU4NjEyNDgwOnlONG1Md1NNazVCeVA5Slo1RldXTExlY3VmZVdMcGh6ZGI4NjJFYUZFWHNPWW8wbnVTaml0VTd5bldtbW9oVjQ5ekxCZ0NtV0NmM2FhQjVSTDY5bGhRSjFId1htRDRTUWJUMVN2SkZXVHZxNk5QQUFUZHU2MnRRNGE2dWM1NXZ3?wait=true',
code: 10015,
httpStatus: 404,
requestData:
json:
content: undefined,
tts: false,
nonce: undefined,
embeds: [
title: "ShxZz's Avatar",
type: 'rich',
description: '[Png](https://cdn.discordapp.com/avatars/817779965856055317/128445caf9d891b9c1aedb609e3ee745.png) | [Webp](https://cdn.discordapp.com/avatars/817779965856055317/128445caf9d891b9c1aedb609e3ee745.webp) | [Jpg](https://cdn.discordapp.com/avatars/817779965856055317/128445caf9d891b9c1aedb609e3ee745.jpg)',
url: null,
timestamp: 2021-11-12T13:15:37.140Z,
color: 16753920,
fields: [],
thumbnail: null,
image:
url: 'https://cdn.discordapp.com/avatars/817779965856055317/128445caf9d891b9c1aedb609e3ee745.webp?size=1024',
proxyURL: undefined,
height: undefined,
width: undefined
,
author: null,
footer:
text: 'Requested by: Vetlix',
icon_url: 'https://cdn.discordapp.com/avatars/751405982562648146/32a3b7ada0724d08bec225ffa92aef84.webp'
],
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
,
files: []
Node.js v17.0.0
【问题讨论】:
【参考方案1】:您正在尝试使用CommandInteraction#followUp
一个您从未回复过的互动!不要使用CommandInteraction#followUp
,而是使用CommandInteraction#reply
await inter.reply(
embeds: [embed]
)
【讨论】:
以上是关于斜杠命令:DiscordAPIError:未知的 Webhook 错误?的主要内容,如果未能解决你的问题,请参考以下文章
不断收到 DiscordAPIError:在 Discord.js 中的音乐机器人上使用 reconlx 的分页执行队列命令时出现未知交互
Discord.js DiscordAPIError:无效的表单正文 0.permissions:长度必须为 10 或更少
执行歌词命令时出现此错误:DiscordAPIError:无法发送空消息
定时静音命令“UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Role”错误