Apxitector
Apxitector
DIAdiscord.js - Imagine an app
Created by Apxitector on 8/24/2024 in #djs-questions
Problem with rights and logical code separation
I really hope for your help
5 replies
DIAdiscord.js - Imagine an app
Created by Apxitector on 8/24/2024 in #djs-questions
Problem with rights and logical code separation
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]
});
};
5 replies
DIAdiscord.js - Imagine an app
Created by Apxitector on 8/24/2024 in #djs-questions
Problem with rights and logical code separation
index.js
5 replies