Problem with rights and logical code separation

In general, the problem I have is that I have a main directory ├── buttonHandlers\ ├────── yesBanAction.js ├────── banAction.js ├────── cancelBanAction.js ├────── yesKickAction.js ├────── KickAction.js ├────── cancelKickAction.js ├────── girlGender.js ├────── maleGender.js ├────── verifyAction.js ├──────nonAdmissions.js ├── commands\utility ├──────action.js ├──────ping.js ├──────server.js ├──────user.js ├── events/ ├──────interactionButton.js ├──────interactionCommand.js ├──────ready.js ├── modalHandler/ ├──────modalNonAdmissions.js config.json deploy-commands.js index.js package-lock.json package.json and it turns out that I want all the command files in the buttonHandlers directory to be also internally divided into folders like 3 files related to ban were in the ban folder, but the problem is that I can’t register them in the collection in index.js below I’ll also post the code index.js There is also a secondary problem, let’s say in the banAction file, I need to check that the button is not pressed by someone else, but I can’t do this, I’ll also post the banAction code below
3 Replies
d.js toolkit
d.js toolkit5mo 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!
Apxitector
ApxitectorOP5mo ago
index.js
Apxitector
ApxitectorOP4mo ago
banAction
const { ButtonBuilder, EmbedBuilder, ButtonStyle, ActionRowBuilder } = require('discord.js');
const { execute } = require('../commands/utility/action');

module.exports = async (interaction) => {
const targetId = interaction.message.content.match(/<@!?(\d+)>/)[1];
const targetMember = await interaction.guild.members.fetch(targetId);
const [action, senderId] = interaction.customId.split('_');

if(interaction.user.id !== senderId) {
interaction.reply({content: 'Вы не можете использовать эту кнопку', ephemeral: true})
return
}

const yesBanAction = new ButtonBuilder() // КНОПКА ОДОБРЕНИЯ БАНА
.setCustomId('yesBanAction')
.setLabel('да')
.setStyle(ButtonStyle.Primary);

const cancelBanAction = new ButtonBuilder() // КНОПКА ОТКЛОНЕНИЯ БАНА
.setCustomId('cancelBanAction')
.setLabel('нет')
.setStyle(ButtonStyle.Success);

const menuAction = new ButtonBuilder() // ОСНОВНОЕ МЕНЮ
.setCustomId('menuAction')
.setLabel('меню')
.setStyle(ButtonStyle.Secondary);

const row = new ActionRowBuilder()
.addComponents(yesBanAction, cancelBanAction, menuAction);

const embed = new EmbedBuilder()
.setDescription(`Вы точно хотите забанить ${targetMember.user.tag}?`);

await interaction.update({
content: `${targetMember}`,
components: [row],
embeds: [embed]
});
};
const { ButtonBuilder, EmbedBuilder, ButtonStyle, ActionRowBuilder } = require('discord.js');
const { execute } = require('../commands/utility/action');

module.exports = async (interaction) => {
const targetId = interaction.message.content.match(/<@!?(\d+)>/)[1];
const targetMember = await interaction.guild.members.fetch(targetId);
const [action, senderId] = interaction.customId.split('_');

if(interaction.user.id !== senderId) {
interaction.reply({content: 'Вы не можете использовать эту кнопку', ephemeral: true})
return
}

const yesBanAction = new ButtonBuilder() // КНОПКА ОДОБРЕНИЯ БАНА
.setCustomId('yesBanAction')
.setLabel('да')
.setStyle(ButtonStyle.Primary);

const cancelBanAction = new ButtonBuilder() // КНОПКА ОТКЛОНЕНИЯ БАНА
.setCustomId('cancelBanAction')
.setLabel('нет')
.setStyle(ButtonStyle.Success);

const menuAction = new ButtonBuilder() // ОСНОВНОЕ МЕНЮ
.setCustomId('menuAction')
.setLabel('меню')
.setStyle(ButtonStyle.Secondary);

const row = new ActionRowBuilder()
.addComponents(yesBanAction, cancelBanAction, menuAction);

const embed = new EmbedBuilder()
.setDescription(`Вы точно хотите забанить ${targetMember.user.tag}?`);

await interaction.update({
content: `${targetMember}`,
components: [row],
embeds: [embed]
});
};
I really hope for your help
Want results from more Discord servers?
Add your server