diff --git a/src/commands/feedback-modal.ts b/src/commands/feedback-modal.ts new file mode 100644 index 0000000..45e0faf --- /dev/null +++ b/src/commands/feedback-modal.ts @@ -0,0 +1,25 @@ +import { commandModule, CommandType } from '@sern/handler'; +import { EmbedBuilder } from 'discord.js'; + +export default commandModule({ + type: CommandType.Modal, + async execute(modal) { + try { + const value = modal.fields.getTextInputValue('message'); + const feedbackChannel = await modal.client.channels.fetch(process.env.FEEDBACK_CHANNEL_ID); + const embed = new EmbedBuilder({ + description: value, + color: 0x00ff00, + }); + feedbackChannel!.isSendable() && + (await feedbackChannel.send({ + content: `Feedback from ${modal.user.username}`, + embeds: [embed], + })); + modal.reply({ ephemeral: true, content: 'Sent! Thanks for the feedback!' }); + } catch (error) { + console.error(error); + modal.reply({ ephemeral: true, content: 'An error occurred while sending your feedback. Please try again later.' }); + } + }, +}); diff --git a/src/commands/feedback.ts b/src/commands/feedback.ts new file mode 100644 index 0000000..21c204c --- /dev/null +++ b/src/commands/feedback.ts @@ -0,0 +1,24 @@ +import { commandModule, CommandType } from '@sern/handler'; +import { ActionRowBuilder, ModalActionRowComponentBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } from 'discord.js'; + +export default commandModule({ + type: CommandType.Slash, + plugins: [], + description: 'Feedback always welcome!', + options: [], + execute: async (ctx) => { + const modal = new ModalBuilder() + .setCustomId('feedback-modal') + .setTitle('ezbd Feedback'); + + const messageInput = new TextInputBuilder() + .setCustomId('message') + .setLabel('anything to fix? add?') + .setStyle(TextInputStyle.Paragraph); + + const firstActionRow = new ActionRowBuilder().addComponents(messageInput); + modal.addComponents(firstActionRow); + + await ctx.interaction.showModal(modal); + }, +});