Unknown Interaction - @discordjs/core
I'm working on a bot that handles interactions via a webhook url, and am processing them in AWS Lambda. I have everything set up properly, including responding to the ping interaction, but no matter what I do, I keep getting an
In the above, I'm creating the apis from a custom context being passed in, and attempting to just respond to any non-ping interaction with 'Pong!', but every time the function is invoked, I get the following error:
Any idea what's going on?
Unknown InteractionUnknown Interaction error.const mainHandler = async (
_event: APIGatewayProxyEvent,
context: InteractionContext
): Promise<APIGatewayProxyResult> => {
const rest = new REST({ version: '10' }).setToken(context.clientSecret);
const interaction = context.interaction;
const webhooksAPI = new WebhooksAPI(rest);
const interactionsAPI = new InteractionsAPI(rest, webhooksAPI);
if (interaction.type === InteractionType.Ping) {
return {
statusCode: 200,
body: JSON.stringify({ type: InteractionType.Ping })
};
}
const response = await interactionsAPI.reply(interaction.id, interaction.token, { content: 'Pong!' });
return {
statusCode: 200,
body: JSON.stringify(response)
};
};const mainHandler = async (
_event: APIGatewayProxyEvent,
context: InteractionContext
): Promise<APIGatewayProxyResult> => {
const rest = new REST({ version: '10' }).setToken(context.clientSecret);
const interaction = context.interaction;
const webhooksAPI = new WebhooksAPI(rest);
const interactionsAPI = new InteractionsAPI(rest, webhooksAPI);
if (interaction.type === InteractionType.Ping) {
return {
statusCode: 200,
body: JSON.stringify({ type: InteractionType.Ping })
};
}
const response = await interactionsAPI.reply(interaction.id, interaction.token, { content: 'Pong!' });
return {
statusCode: 200,
body: JSON.stringify(response)
};
};In the above, I'm creating the apis from a custom context being passed in, and attempting to just respond to any non-ping interaction with 'Pong!', but every time the function is invoked, I get the following error:
{
"errorType": "DiscordAPIError[10062]",
"errorMessage": "Unknown interaction",
"code": 10062,
"requestBody": {
"json": {
"type": 4,
"data": {
"content": "Pong!"
}
}
},
"rawError": {
"message": "Unknown interaction",
"code": 10062
},
"status": 404,
"method": "POST",
"url": "https://discord.com/api/v10/interactions/.../callback",
"stack": [
"DiscordAPIError[10062]: Unknown interaction",
" at handleErrors (/var/task/node_modules/@discordjs/rest/dist/index.js:687:13)",
" at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
" at async BurstHandler.runRequest (/var/task/node_modules/@discordjs/rest/dist/index.js:786:23)",
" at async _REST.request (/var/task/node_modules/@discordjs/rest/dist/index.js:1218:22)",
" at async InteractionsAPI.reply (/var/task/node_modules/@discordjs/core/dist/index.js:1602:5)",
" at async mainHandler (/var/task/index.js:18:22)",
" at async Runtime.handler (/var/task/middleware/verify.js:36:12)"
]
}{
"errorType": "DiscordAPIError[10062]",
"errorMessage": "Unknown interaction",
"code": 10062,
"requestBody": {
"json": {
"type": 4,
"data": {
"content": "Pong!"
}
}
},
"rawError": {
"message": "Unknown interaction",
"code": 10062
},
"status": 404,
"method": "POST",
"url": "https://discord.com/api/v10/interactions/.../callback",
"stack": [
"DiscordAPIError[10062]: Unknown interaction",
" at handleErrors (/var/task/node_modules/@discordjs/rest/dist/index.js:687:13)",
" at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
" at async BurstHandler.runRequest (/var/task/node_modules/@discordjs/rest/dist/index.js:786:23)",
" at async _REST.request (/var/task/node_modules/@discordjs/rest/dist/index.js:1218:22)",
" at async InteractionsAPI.reply (/var/task/node_modules/@discordjs/core/dist/index.js:1602:5)",
" at async mainHandler (/var/task/index.js:18:22)",
" at async Runtime.handler (/var/task/middleware/verify.js:36:12)"
]
}Any idea what's going on?