Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DiscordAPIError[10062]: Unknown interaction (AutoComplete) #10236

Closed
MrDieselGR opened this issue Apr 27, 2024 · 0 comments
Closed

DiscordAPIError[10062]: Unknown interaction (AutoComplete) #10236

MrDieselGR opened this issue Apr 27, 2024 · 0 comments

Comments

@MrDieselGR
Copy link

MrDieselGR commented Apr 27, 2024

Which package is this bug report for?

discord.js

Issue description

When I start the bot and use after it the command with autocomplete it shows me Unknown Interaction error and somehow after 3 mins this message disappears and after like 10 mins again the same problem

Logs:

DiscordAPIError[10062]: Unknown interaction
    at handleErrors (/root/tangolima/node_modules/@discordjs/rest/dist/index.js:722:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async BurstHandler.runRequest (/root/tangolima/node_modules/@discordjs/rest/dist/index.js:826:23)
    at async _REST.request (/root/tangolima/node_modules/@discordjs/rest/dist/index.js:1266:22)
    at async AutocompleteInteraction.respond (/root/tangolima/node_modules/discord.js/src/structures/AutocompleteInteraction.js:86:5)
    at async module.exports (/root/tangolima/events/guild/interactionCreate.js:104:22) {
  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/1233883928402722876/aW50ZXJhY3Rpb246MTIzMzg4MzkyODQwMjcyMjg3NjpkcXdQc01RUlJJRnF0R3FEV2xJcVNuVHJlM3ltYTBlM2d4OWk2TmlmZ29BdHkxTnhKY3RqRVRHNzVNMjJ6UHJtNmowcDJSYmU2R0JocExsMXpQeXc1R0tQUFZBVmhIbkNwMmkxdlhzSmNnT0t2N0VGTlhkQ2doemlxdVY5ZVBGSg/callback'
}

Code sample

const searchKey = url || Random;

        try {
          const cachedResults = await redisClient.get(`search_results:${searchKey}`);
  
          if (cachedResults) {
              const searchResults = JSON.parse(cachedResults);
              const choice = searchResults.map(track => {
                  let truncatedName = track.name;
                  if (track.artists.length > 0) {
                      const artists = track.artists.join(' • ');
                      const maxLength = 100 - artists.length - 3; // Subtracting length of artists' names and separator
                      truncatedName = truncatedName.length > maxLength ? `${truncatedName.slice(0, maxLength - 3)}...` : truncatedName;
                  }
                  return {
                      name: `${truncatedName} ${track.artists.length > 0 ? '• ' + track.artists.join(' • ') : ''}`,
                      value: track.external_urls && track.external_urls.spotify ? track.external_urls.spotify : null
                  };
              });
  
             ///////////THE PROBLEM IS HERE return await interaction.respond(choice.filter(choice => choice.value !== null)).catch(console.error);
          } else {
              const searchResults = await client.spotifyApi.searchTracks(searchKey, { limit: 6 });
  
              await redisClient.set(`search_results:${searchKey}`, JSON.stringify(searchResults.body.tracks.items.map(track => ({
                  name: track.name,
                  artists: track.artists.map(artist => artist.name),
                  external_urls: track.external_urls
              }))));
  
              let choice = [];
  
              if (searchResults.body.tracks.items.length === 0) {
                  choice.push({ name: "No results found.", value: null });
              } else {
                  searchResults.body.tracks.items.forEach(track => {
                      choice.push({ name: `${track.name}${track.artists.map(artist => artist.name).join(' • ')}`, value: track.external_urls.spotify });
                  });
              }
  
              return await interaction.respond(choice).catch(() => { });
          }
      } catch (error) {
          console.error(error);
      }

Versions

  • discord.js 14.15.0
  • Node.js 21.7.1
  • Ubuntu 20.04.6 LTS

Issue priority

High (immediate attention needed)

Which partials do you have configured?

User

Which gateway intents are you subscribing to?

Guilds, GuildVoiceStates, GuildMessages

I have tested this issue on a development release

discord.js@14.15.0-dev.1713658222-4ad285804

@discordjs discordjs locked and limited conversation to collaborators Apr 27, 2024
@Jiralite Jiralite converted this issue into discussion #10237 Apr 27, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants