PiggyPlex
PiggyPlex
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
I reckon I'll just refactor as that's probably part of what makes it so difficult to debug
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
same, I'm a bit confused
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
Yeah, that's true, that makes more sense
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
Yep
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
I can send a gist of the command file
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
it is, but it is in a private repo at the moment
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
Command is from Sapphire
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
type InitialInteraction = Command.ChatInputCommandInteraction | Command.ContextMenuCommandInteraction;
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
I know that the best way is to abstract it out into an event listener, however I was just wondering if there's a way to fix this as it is
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
thus this.handleComponentInteraction is called from a collector
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
private async manage(interaction: InitialInteraction, targetOrNull: GuildMember | null) {
if (!interaction.inGuild()) {
interaction.reply('This command can only be used in the staff server.');
return;
}
if (!targetOrNull) {
interaction.reply({
embeds: [createErrorEmbed('User not found.')],
});
return;
}
const target: GuildMember = targetOrNull;
if (target.user.bot) {
interaction.reply({
embeds: [createErrorEmbed('You cannot manage roles for a bot.')],
});
return;
}
const reply = await interaction.deferReply();
const roles = await this.fetchRoles(target);
const rolesInThisGuild = this.getRolesWithinThisGuild(interaction, roles);
await reply.edit({
embeds: [
this.createDefaultManageEmbed(target)
.addFields([
{
name: `Roles (${roles.length})`,
value: this.sortInternalRoleIds(roles).map(inlineCode).join(', '),
},
{
name: `Server Roles (${rolesInThisGuild.length})`,
value: (await this.sortRoleIdsByPosition(interaction, rolesInThisGuild)).map(roleMention).join(' '),
},
]),
],
components: [this.createStaffCategoriesRow(), this.createStaffActionsRow()],
});
const collector = reply.createMessageComponentCollector({
filter: (componentInteraction) => componentInteraction.user.id === interaction.user.id,
time: 10 * 60 * 1000,
});
collector.on('collect', async (componentInteraction) => {
await this.handleComponentInteraction(target, interaction, componentInteraction);
});
collector.on('end', async () => {
await reply.edit({
components: [],
});
});
}
private async manage(interaction: InitialInteraction, targetOrNull: GuildMember | null) {
if (!interaction.inGuild()) {
interaction.reply('This command can only be used in the staff server.');
return;
}
if (!targetOrNull) {
interaction.reply({
embeds: [createErrorEmbed('User not found.')],
});
return;
}
const target: GuildMember = targetOrNull;
if (target.user.bot) {
interaction.reply({
embeds: [createErrorEmbed('You cannot manage roles for a bot.')],
});
return;
}
const reply = await interaction.deferReply();
const roles = await this.fetchRoles(target);
const rolesInThisGuild = this.getRolesWithinThisGuild(interaction, roles);
await reply.edit({
embeds: [
this.createDefaultManageEmbed(target)
.addFields([
{
name: `Roles (${roles.length})`,
value: this.sortInternalRoleIds(roles).map(inlineCode).join(', '),
},
{
name: `Server Roles (${rolesInThisGuild.length})`,
value: (await this.sortRoleIdsByPosition(interaction, rolesInThisGuild)).map(roleMention).join(' '),
},
]),
],
components: [this.createStaffCategoriesRow(), this.createStaffActionsRow()],
});
const collector = reply.createMessageComponentCollector({
filter: (componentInteraction) => componentInteraction.user.id === interaction.user.id,
time: 10 * 60 * 1000,
});
collector.on('collect', async (componentInteraction) => {
await this.handleComponentInteraction(target, interaction, componentInteraction);
});
collector.on('end', async () => {
await reply.edit({
components: [],
});
});
}
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
lastly, as you can see here ^^, the final interaction involves a confirmation button saying Yes, demote them
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
the next interaction is involved when a user presses the Demote button
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
the first interaction is the slash command, /manage <@user>
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
so am I listening to the wrong message or am I doing something stupid like that?
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
I also tried logging the filter, nothing gets passed through to the filter
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
however pressing the button does not go through to 2 / 3
24 replies
DIAdiscord.js - Imagine an app
Created by PiggyPlex on 5/11/2024 in #djs-questions
Nested message component collector not firing
0 and 1 log, and 2 correctly logs after 30 seconds
24 replies