Unable to use updateMessage() on a message that has already used updateMessage()

So I have this modal that when it is submitted, it modifies the message that had the button to show the modal to say "Loading..." while I have some stuff running, but then if I want to use updateMessage() on that message it wont work and would give me this:
DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (C:\Users\mt\Documents\me stuff\prog\Visual Studio Code\genshinBot\node_modules\@discordjs\rest\dist\index.js:687:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\mt\Documents\me stuff\prog\Visual Studio Code\genshinBot\node_modules\@discordjs\rest\dist\index.js:786:23)
at async _REST.request (C:\Users\mt\Documents\me stuff\prog\Visual Studio Code\genshinBot\node_modules\@discordjs\rest\dist\index.js:1218:22)
at async InteractionsAPI.reply (C:\Users\mt\Documents\me stuff\prog\Visual Studio Code\genshinBot\node_modules\@discordjs\core\dist\index.js:1602:5)
at async Object.runModal (C:\Users\mt\Documents\me stuff\prog\Visual Studio Code\genshinBot\commands\login.js:62:17)
at async Client.<anonymous> (C:\Users\mt\Documents\me stuff\prog\Visual Studio Code\genshinBot\handler.js:93:17) {
requestBody: { files: undefined, json: { type: 4, data: [Object] } },
rawError: {
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/ blah blah blah
}
DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (C:\Users\mt\Documents\me stuff\prog\Visual Studio Code\genshinBot\node_modules\@discordjs\rest\dist\index.js:687:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\mt\Documents\me stuff\prog\Visual Studio Code\genshinBot\node_modules\@discordjs\rest\dist\index.js:786:23)
at async _REST.request (C:\Users\mt\Documents\me stuff\prog\Visual Studio Code\genshinBot\node_modules\@discordjs\rest\dist\index.js:1218:22)
at async InteractionsAPI.reply (C:\Users\mt\Documents\me stuff\prog\Visual Studio Code\genshinBot\node_modules\@discordjs\core\dist\index.js:1602:5)
at async Object.runModal (C:\Users\mt\Documents\me stuff\prog\Visual Studio Code\genshinBot\commands\login.js:62:17)
at async Client.<anonymous> (C:\Users\mt\Documents\me stuff\prog\Visual Studio Code\genshinBot\handler.js:93:17) {
requestBody: { files: undefined, json: { type: 4, data: [Object] } },
rawError: {
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/ blah blah blah
}
5 Replies
d.js toolkit
d.js toolkitβ€’16mo 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!
treble/luna
treble/lunaβ€’16mo ago
Show your code
aa battery
aa batteryOPβ€’16mo ago
here
async runModal(interaction, api) {
if (interaction.data.custom_id === "cookieModal") {
await api.interactions.updateMessage(interaction.id, interaction.token, { content: "Loading...", embeds: [], components: [] })

const cookieString = interaction.data.components[0].components[0].value;

const uids = await initialiser.getUids(cookieString);

if (uids.length > 1) {
const selectRows = []
for (item in uids) {
switch (item.region) {
case "os_usa":
selectRows.push({ label: "American server", value: "1", emoji: { id: null, name: "πŸ‡ΊπŸ‡Έ" } });
break;
case "os_euro":
selectRows.push({ label: "Europian server", value: "2", emoji: { id: null, name: "πŸ‡ͺπŸ‡Ί" } });
break;
case "os_asia":
selectRows.push({ label: "Asian server", value: "3", emoji: { id: null, name: "🏳️" } });
break;
case "os_cht":
selectRows.push({ label: "HW/TW/MO server", value: "4", emoji: { id: null, name: "πŸ‘Ž" } });
break;
}
}
await api.interactions.updateMessage(interaction.id, interaction.token, { content: "", embeds: [loginEmbeds.moreThanOneUid], components: [loginEmbeds.serverField(selectRows)]});
}
await api.interactions.updateMessage(interaction.id, interaction.token, { content: "bleh"});
}
}
async runModal(interaction, api) {
if (interaction.data.custom_id === "cookieModal") {
await api.interactions.updateMessage(interaction.id, interaction.token, { content: "Loading...", embeds: [], components: [] })

const cookieString = interaction.data.components[0].components[0].value;

const uids = await initialiser.getUids(cookieString);

if (uids.length > 1) {
const selectRows = []
for (item in uids) {
switch (item.region) {
case "os_usa":
selectRows.push({ label: "American server", value: "1", emoji: { id: null, name: "πŸ‡ΊπŸ‡Έ" } });
break;
case "os_euro":
selectRows.push({ label: "Europian server", value: "2", emoji: { id: null, name: "πŸ‡ͺπŸ‡Ί" } });
break;
case "os_asia":
selectRows.push({ label: "Asian server", value: "3", emoji: { id: null, name: "🏳️" } });
break;
case "os_cht":
selectRows.push({ label: "HW/TW/MO server", value: "4", emoji: { id: null, name: "πŸ‘Ž" } });
break;
}
}
await api.interactions.updateMessage(interaction.id, interaction.token, { content: "", embeds: [loginEmbeds.moreThanOneUid], components: [loginEmbeds.serverField(selectRows)]});
}
await api.interactions.updateMessage(interaction.id, interaction.token, { content: "bleh"});
}
}
this is the serverfields function if needed
static serverField(arr) {
return new ActionRowBuilder(
{
components: [
new StringSelectMenuBuilder({
custom_id: "serverPicker",
max_values: 1,
options: arr
})
]
}
)
}
static serverField(arr) {
return new ActionRowBuilder(
{
components: [
new StringSelectMenuBuilder({
custom_id: "serverPicker",
max_values: 1,
options: arr
})
]
}
)
}
treble/luna
treble/lunaβ€’16mo ago
I'm not too familiar witt rest but you're replying multiple times to the same interaction
aa battery
aa batteryOPβ€’16mo ago
right i see i think im gonna try to defer the message instead cause maybe it works better idk
Want results from more Discord servers?
Add your server