implement modal submit interaction logic
This commit is contained in:
parent
095ad012ff
commit
86091f5eee
@ -1,9 +1,7 @@
|
|||||||
import { TextInputBuilder, TextInputStyle } from 'discord.js';
|
import { TextInputBuilder, TextInputStyle } from 'discord.js';
|
||||||
import { RoleEmojiPair } from '../../database.js';
|
import { RoleEmojiPair } from '../../database.js';
|
||||||
import {
|
import {
|
||||||
ComponentType,
|
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
RoleSelectMenuBuilder,
|
|
||||||
ApplicationCommandType,
|
ApplicationCommandType,
|
||||||
ContextMenuCommandBuilder
|
ContextMenuCommandBuilder
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
@ -68,41 +66,54 @@ export const data = new ContextMenuCommandBuilder()
|
|||||||
.setName('Add role emoji pair')
|
.setName('Add role emoji pair')
|
||||||
.setType(ApplicationCommandType.Message);
|
.setType(ApplicationCommandType.Message);
|
||||||
export async function modalSubmit(interaction) {
|
export async function modalSubmit(interaction) {
|
||||||
console.log(interaction);
|
const { fields, guild } = interaction;
|
||||||
|
// Get text inputs from modal
|
||||||
|
const message = fields.getTextInputValue('message');
|
||||||
|
const roleID = fields.getTextInputValue('role');
|
||||||
|
const emoji = fields.getTextInputValue('emoji');
|
||||||
|
|
||||||
// await interaction.reply({
|
// Fetch role from guild
|
||||||
// content: 'Successfully submitted Form!',
|
const role = await guild.roles.fetch(roleID);
|
||||||
// ephemeral: true
|
// Role not found
|
||||||
// });
|
if (role === null) {
|
||||||
|
await interaction.reply({
|
||||||
|
content: 'Could not fetch role! Please contact server staff.',
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await addSelfRoles(interaction, message, emoji, role);
|
||||||
}
|
}
|
||||||
export async function execute(interaction) {
|
export async function execute(interaction) {
|
||||||
const modal = new ModalBuilder()
|
const modal = new ModalBuilder()
|
||||||
.setCustomId('Add role emoji pair-pair')
|
.setCustomId('Add role emoji pair-pair')
|
||||||
.setTitle('Role Emoji Pair');
|
.setTitle('Role Emoji Pair');
|
||||||
|
|
||||||
const roleSelector = new ActionRowBuilder().addComponents(
|
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)
|
||||||
|
.setValue(id));
|
||||||
|
|
||||||
|
const role = new ActionRowBuilder().addComponents(
|
||||||
new TextInputBuilder()
|
new TextInputBuilder()
|
||||||
.setLabel('Enter exactly one role ID.')
|
.setLabel('Enter exactly one role ID.')
|
||||||
.setStyle(TextInputStyle.Short)
|
.setStyle(TextInputStyle.Short)
|
||||||
.setCustomId('role')
|
.setCustomId('role')
|
||||||
.setRequired(true));
|
.setRequired(true));
|
||||||
|
|
||||||
// const roles = await interaction.guild.roles.fetch();
|
const emoji = new ActionRowBuilder().addComponents(
|
||||||
// const selection = roles.find((r) =>
|
|
||||||
// roleInteraction.values.includes(r.id)
|
|
||||||
// );
|
|
||||||
|
|
||||||
const emojiTextInput = new ActionRowBuilder().addComponents(
|
|
||||||
new TextInputBuilder()
|
new TextInputBuilder()
|
||||||
.setLabel('Enter exactly one emoji.')
|
.setLabel('Enter exactly one emoji.')
|
||||||
.setStyle(TextInputStyle.Short)
|
.setStyle(TextInputStyle.Short)
|
||||||
.setCustomId('emoji')
|
.setCustomId('emoji')
|
||||||
.setRequired(true));
|
.setRequired(true));
|
||||||
|
|
||||||
// const id = interaction.targetMessage.id;
|
modal.addComponents(message, role, emoji);
|
||||||
// await addSelfRoles(interaction, id, emoji, role);
|
|
||||||
|
|
||||||
modal.addComponents(roleSelector, emojiTextInput);
|
|
||||||
|
|
||||||
await interaction.showModal(modal);
|
await interaction.showModal(modal);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user