mirror of
https://github.com/SrIzan10/ezbd.git
synced 2026-06-06 00:56:57 +00:00
feat: add feedback modal
This commit is contained in:
25
src/commands/feedback-modal.ts
Normal file
25
src/commands/feedback-modal.ts
Normal file
@@ -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.' });
|
||||
}
|
||||
},
|
||||
});
|
||||
24
src/commands/feedback.ts
Normal file
24
src/commands/feedback.ts
Normal file
@@ -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<ModalActionRowComponentBuilder>().addComponents(messageInput);
|
||||
modal.addComponents(firstActionRow);
|
||||
|
||||
await ctx.interaction.showModal(modal);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user