Autocomplete Unknown Interaction

Whenever I paste a url into my autocomplete command I get Unknown Interaction, even though the command still runs. error:
DiscordAPIError[10062]: Unknown interaction
at handleErrors (C:\Users\wc250\Documents\Github Repos\Mythical-Bot\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async BurstHandler.runRequest (C:\Users\wc250\Documents\Github Repos\Mythical-Bot\node_modules\@discordjs\rest\dist\index.js:831:23)
at async _REST.request (C:\Users\wc250\Documents\Github Repos\Mythical-Bot\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async AutocompleteInteraction.respond (C:\Users\wc250\Documents\Github Repos\Mythical-Bot\node_modules\discord.js\src\structures\AutocompleteInteraction.js:86:5) {
requestBody: { files: undefined, json: { type: 8, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1330328475424526478/aW50ZXJhY3Rpb246MTMzMDMyODQ3NTQyNDUyNjQ3ODp1MktGdXhjU2E3blBTS0tRNlRmeGNHQ3lkU3BJaEh2akFWcFFjUDdvQjcwRnpUQmFpWXVTMlluWmEzQXJqYUtwMTNYTkNtaHV1ZDFRcjU2ZzM4MWdodERac01WcDlJRDl5dmplSXA5UUFtcTJLa2pUWHVGWjBlTWRCaFBLenpsMw/callback'
}
DiscordAPIError[10062]: Unknown interaction
at handleErrors (C:\Users\wc250\Documents\Github Repos\Mythical-Bot\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async BurstHandler.runRequest (C:\Users\wc250\Documents\Github Repos\Mythical-Bot\node_modules\@discordjs\rest\dist\index.js:831:23)
at async _REST.request (C:\Users\wc250\Documents\Github Repos\Mythical-Bot\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async AutocompleteInteraction.respond (C:\Users\wc250\Documents\Github Repos\Mythical-Bot\node_modules\discord.js\src\structures\AutocompleteInteraction.js:86:5) {
requestBody: { files: undefined, json: { type: 8, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1330328475424526478/aW50ZXJhY3Rpb246MTMzMDMyODQ3NTQyNDUyNjQ3ODp1MktGdXhjU2E3blBTS0tRNlRmeGNHQ3lkU3BJaEh2akFWcFFjUDdvQjcwRnpUQmFpWXVTMlluWmEzQXJqYUtwMTNYTkNtaHV1ZDFRcjU2ZzM4MWdodERac01WcDlJRDl5dmplSXA5UUFtcTJLa2pUWHVGWjBlTWRCaFBLenpsMw/callback'
}
25 Replies
d.js toolkit
d.js toolkit4d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
TheMonDon
TheMonDonOP4d ago
Autocomplete code:
exports.autoComplete = async (interaction) => {
try {
const song = interaction.options.getString('song');
if (!song || song.trim().length === 0) {
return interaction.respond([]);
}

const player = useMainPlayer();

const data = await player.search(song, { requestedBy: interaction.user });

if (!data.hasTracks()) {
return interaction.respond([]);
}

const results = data.tracks
.filter((track) => track.url.length < 100)
.slice(0, 10)
.map((track) => ({
name: track.title.slice(0, 100),
value: track.url,
}));

return interaction.respond(results);
} catch (error) {
interaction.client.logger.error('Error handling autocomplete:', error);

return interaction.respond([]).catch(() => {});
}
};
exports.autoComplete = async (interaction) => {
try {
const song = interaction.options.getString('song');
if (!song || song.trim().length === 0) {
return interaction.respond([]);
}

const player = useMainPlayer();

const data = await player.search(song, { requestedBy: interaction.user });

if (!data.hasTracks()) {
return interaction.respond([]);
}

const results = data.tracks
.filter((track) => track.url.length < 100)
.slice(0, 10)
.map((track) => ({
name: track.title.slice(0, 100),
value: track.url,
}));

return interaction.respond(results);
} catch (error) {
interaction.client.logger.error('Error handling autocomplete:', error);

return interaction.respond([]).catch(() => {});
}
};
music code:
case 'play': {
if (!interaction.member.voice.channel) {
return interaction.editReply('You must be in a voice channel to play music.');
}
if (
interaction.guild.members.me.voice.channel &&
interaction.member.voice.channel.id !== interaction.guild.members.me.voice.channel.id
) {
return interaction.editReply('You have to be in the same voice channel as the bot to play music');
}

const query = interaction.options.get('song').value;

try {
const { track } = await player.play(interaction.member.voice.channel, query, {
requestedBy: interaction.user,
nodeOptions: {
metadata: interaction,
selfDead: true,
leaveOnStop: true,
leaveOnEnd: false,
leaveOnEmpty: false,
},
});

if (!track) return interaction.editReply('No tracks found.');

return interaction.editReply('Music Started');
} catch (e) {
return interaction.editReply(`Something went wrong: ${e}`);
}
}
case 'play': {
if (!interaction.member.voice.channel) {
return interaction.editReply('You must be in a voice channel to play music.');
}
if (
interaction.guild.members.me.voice.channel &&
interaction.member.voice.channel.id !== interaction.guild.members.me.voice.channel.id
) {
return interaction.editReply('You have to be in the same voice channel as the bot to play music');
}

const query = interaction.options.get('song').value;

try {
const { track } = await player.play(interaction.member.voice.channel, query, {
requestedBy: interaction.user,
nodeOptions: {
metadata: interaction,
selfDead: true,
leaveOnStop: true,
leaveOnEnd: false,
leaveOnEmpty: false,
},
});

if (!track) return interaction.editReply('No tracks found.');

return interaction.editReply('Music Started');
} catch (e) {
return interaction.editReply(`Something went wrong: ${e}`);
}
}
kawaibunga08
kawaibunga084d ago
use interaction.reply() in place of interaction.respond() in the autoComplete
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
kawaibunga08
kawaibunga084d ago
interaction.respond() is also an issue though? Maybe not the only one, as that method doesn't exist
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
kawaibunga08
kawaibunga084d ago
oh, my apologies for that. Though, if it were the app timing out, you would get an ephemeral response indicating so?
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
TheMonDon
TheMonDonOP4d ago
discord-player
kawaibunga08
kawaibunga084d ago
understood. I haven't experimented with autocomplete yet and didn't realize it behaved a bit differently before chiming in 😞
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
TheMonDon
TheMonDonOP4d ago
yeah
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
TheMonDon
TheMonDonOP4d ago
Okay thanks
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
kawaibunga08
kawaibunga084d ago
basically, responding before the searching and filtering that would be causing the app to timeout?
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
kawaibunga08
kawaibunga084d ago
makes sense
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
sphere
sphere4d ago
Similar
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
sphere
sphere4d ago
Oops Nvm Maybe I should have read the thing 😭😭
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
TheMonDon
TheMonDonOP4d ago
I think this is the actual answer to my question, I timed the autocomplete interaction and its taking up to 9 seconds to complete, im guessing my internet is the problem then

Did you find this page helpful?