materwelon
materwelon
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by materwelon on 8/1/2024 in #djs-questions
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' }
5 replies