2024-02-05 21:57:08 +00:00
|
|
|
import {
|
2024-02-05 22:26:49 +00:00
|
|
|
ModalBuilder,
|
2024-02-11 01:04:12 +00:00
|
|
|
TextInputStyle,
|
2024-02-05 21:57:08 +00:00
|
|
|
ActionRowBuilder,
|
2024-02-11 01:04:12 +00:00
|
|
|
TextInputBuilder,
|
|
|
|
PermissionFlagsBits,
|
|
|
|
ModalSubmitInteraction,
|
2024-02-05 21:57:08 +00:00
|
|
|
ApplicationCommandType,
|
2024-02-11 01:04:12 +00:00
|
|
|
ContextMenuCommandBuilder,
|
|
|
|
ContextMenuCommandInteraction
|
2024-02-05 21:57:08 +00:00
|
|
|
} from 'discord.js';
|
2024-04-05 08:30:41 +00:00
|
|
|
import { addSelfRoles } from '../../../shared.js';
|
2024-02-05 21:57:08 +00:00
|
|
|
|
|
|
|
export const data = new ContextMenuCommandBuilder()
|
|
|
|
.setDMPermission(false)
|
|
|
|
.setName('Add role emoji pair')
|
2024-02-09 21:41:58 +00:00
|
|
|
.setType(ApplicationCommandType.Message)
|
|
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles);
|
2024-02-11 01:04:12 +00:00
|
|
|
/** @param {ModalSubmitInteraction} interaction */
|
2024-02-05 21:57:08 +00:00
|
|
|
export async function modalSubmit(interaction) {
|
2024-02-05 22:07:19 +00:00
|
|
|
const { fields, guild } = interaction;
|
|
|
|
// Get text inputs from modal
|
|
|
|
const message = fields.getTextInputValue('message');
|
|
|
|
const roleID = fields.getTextInputValue('role');
|
|
|
|
const emoji = fields.getTextInputValue('emoji');
|
|
|
|
|
|
|
|
// Fetch role from guild
|
|
|
|
const role = await guild.roles.fetch(roleID);
|
|
|
|
// Role not found
|
|
|
|
if (role === null) {
|
|
|
|
await interaction.reply({
|
|
|
|
content: 'Could not fetch role! Please contact server staff.',
|
2024-02-06 15:18:06 +00:00
|
|
|
ephemeral: true
|
2024-02-05 22:07:19 +00:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
2024-02-05 21:57:08 +00:00
|
|
|
|
2024-02-05 22:26:49 +00:00
|
|
|
await addSelfRoles(interaction, message, role, emoji);
|
2024-02-05 21:57:08 +00:00
|
|
|
}
|
2024-02-11 01:04:12 +00:00
|
|
|
/** @param {ContextMenuCommandInteraction} interaction */
|
2024-02-05 21:57:08 +00:00
|
|
|
export async function execute(interaction) {
|
|
|
|
const modal = new ModalBuilder()
|
|
|
|
.setCustomId('Add role emoji pair-pair')
|
|
|
|
.setTitle('Role Emoji Pair');
|
|
|
|
|
2024-02-05 22:07:19 +00:00
|
|
|
const id = interaction.targetMessage.id;
|
|
|
|
const message = new ActionRowBuilder().addComponents(
|
|
|
|
new TextInputBuilder()
|
|
|
|
.setLabel('The message ID this command is run on.')
|
|
|
|
.setStyle(TextInputStyle.Short)
|
|
|
|
.setCustomId('message')
|
|
|
|
.setRequired(true)
|
2024-02-06 15:18:06 +00:00
|
|
|
.setValue(id)
|
|
|
|
);
|
2024-02-05 22:07:19 +00:00
|
|
|
|
|
|
|
const role = new ActionRowBuilder().addComponents(
|
2024-02-05 21:57:08 +00:00
|
|
|
new TextInputBuilder()
|
|
|
|
.setLabel('Enter exactly one role ID.')
|
|
|
|
.setStyle(TextInputStyle.Short)
|
|
|
|
.setCustomId('role')
|
2024-02-06 15:18:06 +00:00
|
|
|
.setRequired(true)
|
|
|
|
);
|
2024-02-05 21:57:08 +00:00
|
|
|
|
2024-02-05 22:07:19 +00:00
|
|
|
const emoji = new ActionRowBuilder().addComponents(
|
2024-02-05 21:57:08 +00:00
|
|
|
new TextInputBuilder()
|
|
|
|
.setLabel('Enter exactly one emoji.')
|
|
|
|
.setStyle(TextInputStyle.Short)
|
|
|
|
.setCustomId('emoji')
|
2024-02-06 15:18:06 +00:00
|
|
|
.setRequired(true)
|
|
|
|
);
|
2024-02-05 21:57:08 +00:00
|
|
|
|
2024-02-05 22:07:19 +00:00
|
|
|
modal.addComponents(message, role, emoji);
|
2024-02-05 21:57:08 +00:00
|
|
|
|
|
|
|
await interaction.showModal(modal);
|
|
|
|
}
|