aw0k3n
aw0k3n
DIAdiscord.js - Imagine an app
Created by aw0k3n on 11/7/2024 in #djs-questions
AuditLogEvent.ChannelUpdate getting logs for only 1 channel and not all channels
const guild_channel_update_audit_logs = await new_channel.guild.fetchAuditLogs({ type: AuditLogEvent.ChannelUpdate, limit: 1 });
const guild_channel_update_audit_logs = await new_channel.guild.fetchAuditLogs({ type: AuditLogEvent.ChannelUpdate, limit: 1 });
If I have two TextChannels called secret and secret2, why does the above code only get the logs for secret and not also secret2? Is this suppose to happen?
6 replies
DIAdiscord.js - Imagine an app
Created by aw0k3n on 6/28/2024 in #djs-questions
The reply to this interaction has already been sent or deferred (Use interaction.update > once)
Hello, to start this off:
} else if (interaction.isStringSelectMenu()) {

await interaction.update({ embeds: [rankbinds_database_embeds[0]], components: [button_action_row, interaction.message.components[0]] });
} else if (interaction.isStringSelectMenu()) {

await interaction.update({ embeds: [rankbinds_database_embeds[0]], components: [button_action_row, interaction.message.components[0]] });
I'm already updating this interaction for the first time, and if the user presses on a button, I was doing this:
await interaction.update({ embeds: [rankbinds_database_embeds[current_page]] });
await interaction.update({ embeds: [rankbinds_database_embeds[current_page]] });
But I get an error that says Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred. which I understood what it meant, so I used .editReply instead but the problem with using .editReply is that after you interact with a button it says This interaction failed. Is there any way around this?
10 replies
DIAdiscord.js - Imagine an app
Created by aw0k3n on 6/25/2024 in #djs-questions
This interaction failed (StringSelectMenuBuilder)
command.js
let rankbind_database_embed_select_menu = new StringSelectMenuBuilder()
.setCustomId('rankbinds')
.setPlaceholder('Choose the group rankbind to view.')

for (const database_group_id of guild_rankbinds_database.__v) {
const guild_rankbinds_database_group = await noblox.getGroup(database_group_id);

rankbind_database_embed_select_menu.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel(guild_rankbinds_database_group.name)
.setValue(`${database_group_id}_${guild_rankbinds_database_group.name}`)
);
};

const rankbind_database_embed_action_row = new ActionRowBuilder()
.addComponents(rankbind_database_embed_select_menu);

await interaction.editReply({ content: 'Interact with the select menu.', components: [rankbind_database_embed_action_row] });
break;
let rankbind_database_embed_select_menu = new StringSelectMenuBuilder()
.setCustomId('rankbinds')
.setPlaceholder('Choose the group rankbind to view.')

for (const database_group_id of guild_rankbinds_database.__v) {
const guild_rankbinds_database_group = await noblox.getGroup(database_group_id);

rankbind_database_embed_select_menu.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel(guild_rankbinds_database_group.name)
.setValue(`${database_group_id}_${guild_rankbinds_database_group.name}`)
);
};

const rankbind_database_embed_action_row = new ActionRowBuilder()
.addComponents(rankbind_database_embed_select_menu);

await interaction.editReply({ content: 'Interact with the select menu.', components: [rankbind_database_embed_action_row] });
break;
13 replies
DIAdiscord.js - Imagine an app
Created by aw0k3n on 4/28/2024 in #djs-questions
Objects not getting pushed to collection.
const removed_roles = [];
if (added_roles && added_roles.length && previous_rankbind[0] > account_group_rank) {
previous_rankbind[1].roles.forEach(async (role_id) => {
if (member.roles.cache.find((member_role) => member_role.id == role_id) && !next_rankbind[1].roles.find((next_role_id) => next_role_id == role_id)) {
const rankbind_role = await guild.roles.fetch(role_id);

if (rankbind_role) {
await member.roles.remove(rankbind_role);

removed_roles.push(rankbind_role);

console.log(removed_roles); /** FULL COLLECTION */
console.log(removed_roles.length); /** 2 */
};
};
});
};

console.log(removed_roles); /** EMPTY COLLECTION */
console.log(removed_roles.length); /** 0 */
const removed_roles = [];
if (added_roles && added_roles.length && previous_rankbind[0] > account_group_rank) {
previous_rankbind[1].roles.forEach(async (role_id) => {
if (member.roles.cache.find((member_role) => member_role.id == role_id) && !next_rankbind[1].roles.find((next_role_id) => next_role_id == role_id)) {
const rankbind_role = await guild.roles.fetch(role_id);

if (rankbind_role) {
await member.roles.remove(rankbind_role);

removed_roles.push(rankbind_role);

console.log(removed_roles); /** FULL COLLECTION */
console.log(removed_roles.length); /** 2 */
};
};
});
};

console.log(removed_roles); /** EMPTY COLLECTION */
console.log(removed_roles.length); /** 0 */
This check will detect if a user's roles has been updated, and if they have their old position roles, then it gets removed. For example, detecting if an administrator demoted to a moderator still has the administrator role. I added the role that was removed to a collection so I can add it to an embed to send to the user, but the only problem is that the collection is always empty.
4 replies