DiscordAPIError[10062]: неизвестное взаимодействие в handleErrorsJavascript

Форум по Javascript
Ответить
Anonymous
 DiscordAPIError[10062]: неизвестное взаимодействие в handleErrors

Сообщение Anonymous »

Я делаю команду косой черты, чтобы отправить пользователю информацию о команде, когда он использует /showallrole. Я просто получаю эту ошибку, пожалуйста, помогите мне проверить мой код.
Этот код для отображения всех пользователей в моем Discord.< /p>

Код: Выделить всё

C:\bot\bot_discord_js_time_role\node_modules\@discordjs\rest\dist\index.js:640
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[10062]: Unknown interaction
at handleErrors (C:\bot\bot_discord_js_time_role\node_modules\←[4m@discordjs←[24m\rest\dist\index.js:640:13)
←[90m    at processTicksAndRejections (node:internal/process/task_queues:96:5)←[39m
at async BurstHandler.runRequest (C:\bot\bot_discord_js_time_role\node_modules\←[4m@discordjs←[24m\rest\dist\index.j
s:736:23)
at async REST.request (C:\bot\bot_discord_js_time_role\node_modules\←[4m@discordjs←[24m\rest\dist\index.js:1387:22)
at async ChatInputCommandInteraction.reply (C:\bot\bot_discord_js_time_role\node_modules\←[4mdiscord.js←[24m\src\str
uctures\interfaces\InteractionResponses.js:111:5) {
requestBody: {
files: [],
json: {
type: ←[33m4←[39m,
data: {
content: ←[32m'deleted_user_361e19ab73da: Role: Subscribe Valid Sampai 5/02/2024 14:38 (setahun)\n'←[39m +
←[32m'cierocielo: Role: Subscribe Valid Sampai 21/01/2025 6:59 (22 menit)\n'←[39m +
←[32m'vincee94: Role: Subscribe Valid Sampai 23/01/2025 16:36 (2 hari)\n'←[39m +
←[32m'aruturuuu: Role: Subscribe Valid Sampai 24/01/2025 19:36 (4 hari)\n'←[39m +
←[32m'nobo88: Role: Subscribe Valid Sampai 25/01/2025 22:32 (5 hari)\n'←[39m +
←[32m'arjuna_inguh: Role: Subscribe Valid Sampai 25/01/2025 22:35 (5 hari)\n'←[39m +
←[32m'mayrekber: Role: Subscribe Valid Sampai 27/01/2025 10:13 (6 hari)\n'←[39m +
←[32m'uzziel: Role: Subscribe Valid Sampai 30/01/2025 16:17 (9 hari)\n'←[39m +
←[32m'kunard: Role: Subscribe Valid Sampai 1/02/2025 22:06 (12 hari)\n'←[39m +
←[32m'adre0064: Role: Subscribe Valid Sampai 3/02/2025 21:17 (14 hari)\n'←[39m +
←[32m'.beelee: Role: Subscribe Valid Sampai 4/02/2025 2:31 (14 hari)\n'←[39m +
←[32m'monte_24678: Role: Subscribe Valid Sampai 17/02/2025 19:58 (sebulan)\n'←[39m +
←[32m'harmankardon5: Role: Subscribe Valid Sampai 18/02/2025 14:43 (sebulan)\n'←[39m +
←[32m'booboo1433: Role: Subscribe Valid Sampai 18/02/2025 19:53 (sebulan)\n'←[39m +
←[32m'irric: Role: Subscribe Valid Sampai 21/02/2025 19:42 (sebulan)\n'←[39m +
←[32m'navii2121: Role: Subscribe Valid Sampai 8/04/2025 19:38 (3 bulan)\n'←[39m,
tts: ←[33mfalse←[39m,
nonce: ←[90mundefined←[39m,
embeds: ←[90mundefined←[39m,
components: ←[90mundefined←[39m,
username: ←[90mundefined←[39m,
avatar_url: ←[90mundefined←[39m,
allowed_mentions: ←[90mundefined←[39m,
flags: ←[33m64←[39m,
message_reference: ←[90mundefined←[39m,
attachments: ←[90mundefined←[39m,
sticker_ids: ←[90mundefined←[39m,
thread_name: ←[90mundefined←[39m
}
}
},
rawError: { message: ←[32m'Unknown interaction'←[39m, code: ←[33m10062←[39m },
code: ←[33m10062←[39m,
status: ←[33m404←[39m,
method: ←[32m'POST'←[39m,
url: ←[32m'https://discord.com/api/v10/interactions/1331044983817375835/aW50ZXJhY3Rpb246MTMzMTA0NDk4MzgxNzM3NTgzNTpic0
NmSjRqMG9XS1pnQWNYUDdNN1lVaVBRNklwdmVYWktWZ2lRMXdQSnJxaXVZSWRMQjdZQjhrSW5EYkJiNjNVaGk2OTBvQTJkbkkzRlZvQ3FORW1HSEg3U3ZyNW
U0V2oxRTFpRlNkcDk0VElvdnZlM2ZrSml0TlhrS25GM0wyMQ/callback'←[39m
}
А вот полный код:

Код: Выделить всё

const moment = require("moment");
const { SlashCommandBuilder, AttachmentBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('showallroles')
.setDescription('Show the expiration time of all roles')
.addRoleOption(option => option.setName('role').setDescription('The role to show users for').setRequired(true))
.addStringOption(option => option.setName('sort').setDescription('Sort order').addChoices({name: 'Ascending', value: 'asc'}, {name: 'Descending', value: 'desc'}).setRequired(true)),
async execute(client, interaction, guildId, db) {
const roleId = interaction.options.getRole('role').id;
const sortOrder = interaction.options.getString('sort') || 'asc'; // Default to ascending if sort option not provided
let reply = "";

const users = db.prepare("SELECT * FROM members WHERE role = ? ORDER BY unixTimestamp " + (sortOrder === 'asc' ? 'ASC' : 'DESC')).all(roleId);  // Get all users from the database, sorted by expiry
if (users.length > 0) {
for (const user of users) {
const date = moment.unix(user.unixTimestamp); // Convert
const currentData = moment();
moment.locale('id');
const duration = moment.duration(date.diff(currentData));
const formattedDuration = duration.humanize();
const member = await client.users.fetch(user.memberId); // Fetch the user object from Discord API

if (member) {
reply += `${member.username}: Role: ${(await interaction.guild.roles.fetch(user.role))?.name} Valid Sampai ${date.format("D/MM/YYYY H:mm")} (${formattedDuration})\n`;
}
}
} else {
reply = "Tidak ada Time Role";
}

if (reply.length < 2000) {
await interaction.reply({ content: reply, ephemeral: true });
} else {
const attachment = new AttachmentBuilder(Buffer.from(reply), { name: 'output.txt' });
await interaction.reply({ files: [attachment], ephemeral: true });
}
}
};
Мне не удалось найти ответы на эту проблему в Интернете, поэтому надеюсь, что вы сможете на нее ответить. Заранее спасибо!

Подробнее здесь: https://stackoverflow.com/questions/793 ... ndleerrors
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Javascript»