const {
MessageActionRow,
MessageButton,
ActionRowBuilder,
EmbedBuilder,
ButtonStyle,
ButtonBuilder,
MessageSelectMenu,
User,
MessageComponentInteraction,
InteractionCollector,
GuildMember,
Channel,
SlashCommandBuilder
} = require('discord.js');
const mysql = require('mysql');
module.exports = {
data: new SlashCommandBuilder()
.setName('rules')
.setDescription('Sendet das Regelwerk.')
.setDefaultPermission(false)
.setDMPermission(false),
async execute(interaction) {
const verify = new ButtonBuilder()
.setCustomId('verify')
.setLabel('Verifizieren')
.setStyle(ButtonStyle.Primary)
.setEmoji('1126993747809419295');
const row = new ActionRowBuilder()
.addComponents(verify);
const embed = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle('Web Users')
.setURL('https://discord.js.org/')
.setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' })
.setDescription('TEST')
.setThumbnail('https://i.imgur.com/AfFp7pu.png')
.addFields(
{ name: 'Regular field title', value: 'Some value here' },
{ name: '\u200B', value: '\u200B' },
{ name: 'Inline field title', value: 'Some value here', inline: true },
{ name: 'Inline field title', value: 'Some value here', inline: true },
)
.addFields({ name: 'Inline field title', value: 'Some value here', inline: true })
.setImage('https://i.imgur.com/AfFp7pu.png')
.setTimestamp()
.setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });
interaction.channel.send({ embeds: [embed], ephemeral: false, components: [row] });
const collector = interaction.channel.createMessageComponentCollector({
componentType: 'BUTTON',
});
collector.on('collect', async (buttonInteraction) => {
if (buttonInteraction.customId === 'verify') {
const user = buttonInteraction.user;
const member = await buttonInteraction.guild.members.fetch(user);
const roleId = '1126996899497517158';
const role = buttonInteraction.guild.roles.cache.get(roleId);
if (role) {
await member.roles.add(role);
await buttonInteraction.reply('Role assigned successfully!', { ephemeral: true});
} else {
await buttonInteraction.reply('Role not found.', { ephemeral: true});
}
}
});
}
};