Zela
Zela
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
when I try to click the second body
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
requestBody: { files: undefined, json: { type: 6 } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1218688061605543946/aW50ZXJhY3Rpb246MTIxODY4ODA2MTYwNTU0Mzk0NjpmbHZWQzJCanFBbE5US0VuQTRLbmhwVjJpU0ZOTGZ6S0dTbGpLZXJNOEFucU1MRVVDWUtuS0Vabmd6UW5FNERCUHRST0ExTG1iU0M1THZPV1VHSGRJMlpKWGJjUW9vNGVLWG9vaEtEdXl4NDc4am5vWnFSWEFVOXdTd2RBcndmcQ/callback'
}
requestBody: { files: undefined, json: { type: 6 } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1218688061605543946/aW50ZXJhY3Rpb246MTIxODY4ODA2MTYwNTU0Mzk0NjpmbHZWQzJCanFBbE5US0VuQTRLbmhwVjJpU0ZOTGZ6S0dTbGpLZXJNOEFucU1MRVVDWUtuS0Vabmd6UW5FNERCUHRST0ExTG1iU0M1THZPV1VHSGRJMlpKWGJjUW9vNGVLWG9vaEtEdXl4NDc4am5vWnFSWEFVOXdTd2RBcndmcQ/callback'
}
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
Error thrown is:
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
So to put things together, the current state of the code is this:
for(const thing in arr) {
const response = await interaction.edit(...)
const filter = (i) => {
i.deferUpdate();
return i.user.id === interaction.user.id;
};
await response.awaitMessageComponent({filter, componentType: ComponentType.Button, time: 15_000})
.then(i => {
//stuff to do
i.editReply(reply);
})
.catch(err => {
// on time out
i.editReply(reply);
});
}

for(const thing in arr) {
const response = await interaction.edit(...)
const filter = (i) => {
i.deferUpdate();
return i.user.id === interaction.user.id;
};
await response.awaitMessageComponent({filter, componentType: ComponentType.Button, time: 15_000})
.then(i => {
//stuff to do
i.editReply(reply);
})
.catch(err => {
// on time out
i.editReply(reply);
});
}

And it runs the first iteration fine, but does not even look at the second iteration
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
When I interact with it instantly, the second loop comes through but cannot be interacted with but when I take a while, it doesn't come through at all
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
I have 0 clue how to approach that
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
the error seems to be because I am not deferring the message reply or update, so I cannot track it past the first loop
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
I put the await in front of the response.awaitMessageComponent(...)
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
ok new error, it waits but when I come to second iteration it simply says this interaction failed
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
nor does it use await itself
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
following the guide on the website it doesnt say where to put await
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
wait where do I even use await here
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
I might be slow
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
me changing it to awaitMessageComponent has caused the same issue
response.awaitMessageComponent({filter, componentType: ComponentType.Button, time: 15_000})
.then(i => {
const index = i.customId.split("-")[1];
battleState[player].swing = [battleState[player].colors[index], battleState[player].rolls[index]];
fs.writeFileSync(...);
interaction.editReply(...)
.catch(err => {
index = indexes[0];
battleState[player].swing = [battleState[player].colors[index], battleState[player].rolls[index]];
fs.writeFileSync(`...);
interaction.editReply(...);
});
response.awaitMessageComponent({filter, componentType: ComponentType.Button, time: 15_000})
.then(i => {
const index = i.customId.split("-")[1];
battleState[player].swing = [battleState[player].colors[index], battleState[player].rolls[index]];
fs.writeFileSync(...);
interaction.editReply(...)
.catch(err => {
index = indexes[0];
battleState[player].swing = [battleState[player].colors[index], battleState[player].rolls[index]];
fs.writeFileSync(`...);
interaction.editReply(...);
});
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
so instead of
const collector = response.createMessageComponentCollector({
componentType: ComponentType.Button,
filter,
time: 15_000,
});
const collector = response.createMessageComponentCollector({
componentType: ComponentType.Button,
filter,
time: 15_000,
});
I do something like
response.awaitMessageComponent({componentType: ComponentType.Button, filter, time: 15_000}).then(i => {
//do stuff
interaction.editReply(...)
}).catch(err => other stuff);
response.awaitMessageComponent({componentType: ComponentType.Button, filter, time: 15_000}).then(i => {
//do stuff
interaction.editReply(...)
}).catch(err => other stuff);
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
so I use awaitMessageComponent in place of createMessageComponentCollector?
25 replies
DIAdiscord.js - Imagine an app
Created by Zela on 3/16/2024 in #djs-questions
Looping through an array getting input each iteration
what does await message component do?
25 replies