decho
decho
Explore posts from servers
DIAdiscord.js - Imagine a boo! 👻
Created by decho on 8/14/2023 in #djs-questions
Getting "Unknown interaction" error even with interaction.deferReply()
Hey folks, I am getting a strange error with this code:
class StandingsInteraction {
public async interaction(interaction: TypedCommands['standings']) {
// interaction is ChatInputCommandInteraction
await interaction.deferReply();

const { data, expired } = await standingsCache.getData();

if (!expired) {
return await interaction.editReply({
content: data // data is a string here
});
}

const res = await interaction.editReply({
files: [{
attachment: data, // data is a Buffer here
name: 'la-liga-standings.png'
}]
});

standingsCache.revalidate(res);
}
}
class StandingsInteraction {
public async interaction(interaction: TypedCommands['standings']) {
// interaction is ChatInputCommandInteraction
await interaction.deferReply();

const { data, expired } = await standingsCache.getData();

if (!expired) {
return await interaction.editReply({
content: data // data is a string here
});
}

const res = await interaction.editReply({
files: [{
attachment: data, // data is a Buffer here
name: 'la-liga-standings.png'
}]
});

standingsCache.revalidate(res);
}
}
The problem is that I am randomly getting this error, and I can't figure out why since I am deferring the reply:
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/home/node_modules/@discordjs/rest/dist/index.js:687:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/home/node_modules/@discordjs/rest/dist/index.js:786:23)
at async _REST.request (/home/node_modules/@discordjs/rest/dist/index.js:1218:22)
at async ChatInputCommandInteraction.deferReply (/home/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:69:5)
at async StandingsInteraction.interaction (file:///home/apps/discord/out/commands/standings.js:5:5)
at async interactionController (file:///home/apps/discord/out/commands/_controller.js:31:7)
at async Client.<anonymous> (file:///home/apps/discord/out/index.js:13:5) {
requestBody: { files: undefined, json: { type: 5, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/.../callback'
}
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/home/node_modules/@discordjs/rest/dist/index.js:687:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/home/node_modules/@discordjs/rest/dist/index.js:786:23)
at async _REST.request (/home/node_modules/@discordjs/rest/dist/index.js:1218:22)
at async ChatInputCommandInteraction.deferReply (/home/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:69:5)
at async StandingsInteraction.interaction (file:///home/apps/discord/out/commands/standings.js:5:5)
at async interactionController (file:///home/apps/discord/out/commands/_controller.js:31:7)
at async Client.<anonymous> (file:///home/apps/discord/out/index.js:13:5) {
requestBody: { files: undefined, json: { type: 5, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/.../callback'
}
I searched online for the problem but without much success.
15 replies
DIAdiscord.js - Imagine a boo! 👻
Created by decho on 7/31/2023 in #djs-questions
Looking for information about "managed" emojis.
Hello. I am developing a bot for my server, and this bot needs certain emojis to be always available, in case the server loses boost status. Since discord doesn't provide a way to re-order you emojis, if you want to achieve that you have to delete all server emojis and reupload them in correct order (bot emojis being uploaded first). Either way, while doing a research on this topic I stumbled upon the concept of "managed" emojis, but the documentation about it seems very limited, I can't find much info online about it either. This is what ChatGPT told me about them:
Managed emojis are custom emojis that are added by a bot or an integration, such as Twitch or YouTube. They cannot be deleted or edited by the server owner or anyone with the Manage Emoji permission.
Based on this, my understanding is that I can have emojis that are related to my bot rather than a specific server, which would be ideal for my case. However, I can't seem to find any information on how to upload/use these so called "managed" emojis, so this is what I'm asking for. Any info would be appreciated, thanks!
8 replies
DIAdiscord.js - Imagine a boo! 👻
Created by decho on 7/26/2022 in #djs-questions
Creating types for slash command options.
Hello guys. I have been search the Internet about this, with little to no success, so I thought I'd ask here. Is it possible to provide custom types for my slash command options. For example, I can restrict the interaction and command name and commandNames respectively, and also the type like this:
import type { ApplicationCommandType, ChatInputApplicationCommandData, CommandInteraction } from 'discord.js';

type ISlashChatCommandNames = 'foo' | 'bar';

export interface ISlashChatCommandData extends ChatInputApplicationCommandData {
name: ISlashChatCommandNames;
type: ApplicationCommandType.ChatInput,
}

export interface ISlashChatCommandInteraction extends CommandInteraction {
commandName: ISlashChatCommandNames;
commandType: ApplicationCommandType.ChatInput,
}
import type { ApplicationCommandType, ChatInputApplicationCommandData, CommandInteraction } from 'discord.js';

type ISlashChatCommandNames = 'foo' | 'bar';

export interface ISlashChatCommandData extends ChatInputApplicationCommandData {
name: ISlashChatCommandNames;
type: ApplicationCommandType.ChatInput,
}

export interface ISlashChatCommandInteraction extends CommandInteraction {
commandName: ISlashChatCommandNames;
commandType: ApplicationCommandType.ChatInput,
}
ISlashChatCommandData is used for the slash command builder andISlashChatCommandInteraction is for when the users are interacting with the bot.
15 replies