This interaction failed

export default {
data: new SlashCommandBuilder()
.setName('generate')
.setDescription('Generate a card.')
.addStringOption((option) => option.setName('uid').setDescription('HSR UID')),
execute: async (interaction: ChatInputCommandInteraction) => {
const uid = interaction.options.getString('uid');

const select = new StringSelectMenuBuilder()
.setCustomId('starter')
.setPlaceholder('Make a selection!');

await interaction
.deferReply()
.then(async () => {
await interaction.followUp(`Getting characters for UID ${uid}`);
})
.then(async () => {
const { characters } = await getCharacter(uid ?? '', 'en');

characters.forEach(({ name }, index) => {
select.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel(name)
.setValue(index.toString())
.setDescription(name)
);
});

const row = new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents(select);
const response = await interaction.editReply({
content: 'Please select a character',
components: [row],
});

const collectorFilter = (i: any) => i.user.id === interaction.user.id;
await response
.awaitMessageComponent({
filter: collectorFilter,
time: 60_000,
})
.then(async (componentInteraction) => {
if (componentInteraction.isAnySelectMenu()) {
const c = characters[parseInt(componentInteraction.values[0])];
return await interaction.editReply({
content: 'Here is your card!',
files: [await imageGen(c)],
});
}
})
.catch(async (error) => {
console.error(error);
return interaction.editReply('No selection was made.');
})
.then(() => {
return interaction.deferReply();
});
});
},
});
export default {
data: new SlashCommandBuilder()
.setName('generate')
.setDescription('Generate a card.')
.addStringOption((option) => option.setName('uid').setDescription('HSR UID')),
execute: async (interaction: ChatInputCommandInteraction) => {
const uid = interaction.options.getString('uid');

const select = new StringSelectMenuBuilder()
.setCustomId('starter')
.setPlaceholder('Make a selection!');

await interaction
.deferReply()
.then(async () => {
await interaction.followUp(`Getting characters for UID ${uid}`);
})
.then(async () => {
const { characters } = await getCharacter(uid ?? '', 'en');

characters.forEach(({ name }, index) => {
select.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel(name)
.setValue(index.toString())
.setDescription(name)
);
});

const row = new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents(select);
const response = await interaction.editReply({
content: 'Please select a character',
components: [row],
});

const collectorFilter = (i: any) => i.user.id === interaction.user.id;
await response
.awaitMessageComponent({
filter: collectorFilter,
time: 60_000,
})
.then(async (componentInteraction) => {
if (componentInteraction.isAnySelectMenu()) {
const c = characters[parseInt(componentInteraction.values[0])];
return await interaction.editReply({
content: 'Here is your card!',
files: [await imageGen(c)],
});
}
})
.catch(async (error) => {
console.error(error);
return interaction.editReply('No selection was made.');
})
.then(() => {
return interaction.deferReply();
});
});
},
});
The code itself is working with no console errors but the "this interaction failed" prompt appears in the message.
2 Replies
d.js toolkit
d.js toolkit9mo 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
Hyproxen
Hyproxen9mo ago
Not sure, but i think you'd have to reply to componentInteraction as well @LemonadeFox | Open for comission
Want results from more Discord servers?
Add your server