Message vs InteractionResponse IDs

I'm setting the reply ID as a key in Code 1. edit that reply in code 2. and then try to find the key in the Map in code three. The same code works for a different flow that doesn't have the Code 2 step and has deferReply and editReply instead of reply. Is the ID of the message somehow changing after editReply? Because that doesn't make sense to me. Or what exactly is happening. How can I get the ID of the reply in code 1 in code 3? FYI, Code 3 is a ModalSubmitInteraction, Code 2 is a UserSelectMenuInteraction and Code 1 is a ChatInputCommandInteraction. Code 1
const res = await this.event.reply({
ephemeral: true,
components: [new PostMenuRow().getComponent]
});

this.separate ? MakeThreads.separateThreads.set(res.id, true) : null;
const res = await this.event.reply({
ephemeral: true,
components: [new PostMenuRow().getComponent]
});

this.separate ? MakeThreads.separateThreads.set(res.id, true) : null;
Code 2
if (!this.event.inCachedGuild()) return;

await this.event.deferUpdate();

const users = this.getUsersFromMenu();

await this.event.editReply({
embeds: new SelectedUsersEmbed(users).embeds,
components: [new PostButtonRow().getComponent]
});
if (!this.event.inCachedGuild()) return;

await this.event.deferUpdate();

const users = this.getUsersFromMenu();

await this.event.editReply({
embeds: new SelectedUsersEmbed(users).embeds,
components: [new PostButtonRow().getComponent]
});
Code 3
constructor(interaction: ModalSubmitInteraction) {
super(interaction);

this.userIds = StringUtils.extractIds(this.event.message?.embeds[1]);
this.threadName = this.event.fields.getTextInputValue('thread');
this.embedTitle = this.event.fields.getTextInputValue('title');
this.embedDescription = this.event.fields.getTextInputValue('description');

this.separate = MakeThreads.separateThreads.has(this.event.message!.id);

console.log(this.separate);
console.log(this.event.message!.id);
console.log(this.event.id);
console.log(MakeThreads.separateThreads.keys());
constructor(interaction: ModalSubmitInteraction) {
super(interaction);

this.userIds = StringUtils.extractIds(this.event.message?.embeds[1]);
this.threadName = this.event.fields.getTextInputValue('thread');
this.embedTitle = this.event.fields.getTextInputValue('title');
this.embedDescription = this.event.fields.getTextInputValue('description');

this.separate = MakeThreads.separateThreads.has(this.event.message!.id);

console.log(this.separate);
console.log(this.event.message!.id);
console.log(this.event.id);
console.log(MakeThreads.separateThreads.keys());
Logs
false
1268505839384133679
1268505886020861984
[Map Iterator] { '1268505836993515603' }
false
1268505839384133679
1268505886020861984
[Map Iterator] { '1268505836993515603' }
3 Replies
d.js toolkit
d.js toolkit4mo 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!
materwelon
materwelonOP4mo ago
Update 1 I tried to replace res.id with this.event.id (this.event is the interaction) and then use .has(this.event.id); instead. No luck. maybe I'm not getting any IDs because code 1's reply doesnt have an embed? I don't think that's how it works though... Update 2 I fixed the issue by using deferReply and editReply in code 1. I still don't know what the problem is or why the IDs for the reply are different if I edit it. Update 3 So .reply returns an InteractionResponse and .editReply returns a Message. Makes sense why the IDs would be different. Learned that .deferReply returns InteractionResponse. that also has an ID. If I were to use the if for that, how can I retrieve it in Code 3? I know it won't be the ID of the ModalSubmitInteraction. and neither will it be the ID of Message.
Mark
Mark4mo ago
Add fetchReply: true to your reply options Without it, you get an InteractionResponse, adding it will return the message instead
Want results from more Discord servers?
Add your server