diff options
| author | Andrew Lee <andrew@alee14.me> | 2025-03-04 10:05:14 -0500 |
|---|---|---|
| committer | Andrew Lee <andrew@alee14.me> | 2025-03-04 10:05:14 -0500 |
| commit | cc06b8ed4e4e0aef02dfd8ab15df22a57a177a0a (patch) | |
| tree | deffb57bee9fe24a8d1b8143fba603774544ee00 /bot/src/commands/suggest.js | |
| parent | 11bb9ab6b30314d91209bc9888d95783cc247e98 (diff) | |
| download | AleeBot-cc06b8ed4e4e0aef02dfd8ab15df22a57a177a0a.tar.gz AleeBot-cc06b8ed4e4e0aef02dfd8ab15df22a57a177a0a.tar.bz2 AleeBot-cc06b8ed4e4e0aef02dfd8ab15df22a57a177a0a.zip | |
Readme change; Docker; Logging
Diffstat (limited to 'bot/src/commands/suggest.js')
| -rw-r--r-- | bot/src/commands/suggest.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/bot/src/commands/suggest.js b/bot/src/commands/suggest.js new file mode 100644 index 0000000..8f75915 --- /dev/null +++ b/bot/src/commands/suggest.js @@ -0,0 +1,66 @@ +import { + ActionRowBuilder, + MessageFlags, + ModalBuilder, + SlashCommandBuilder, + TextInputBuilder, + TextInputStyle, + EmbedBuilder +} from 'discord.js'; +import { abEmbedColour, featureSuggestChannel } from '../storage/consts.js'; + +export default { + data: new SlashCommandBuilder() + .setName('suggest') + .setDescription('Suggest something either for AleeBot or this server.') + .addSubcommand(subcommand => + subcommand + .setName('feature') + .setDescription('Suggest a feature in AleeBot.')) + .addSubcommand(subcommand => + subcommand + .setName('guild') + .setDescription('Suggest something for this server.')), + async execute(interaction) { + if (interaction.options.getSubcommand() === 'feature') { + const modal = new ModalBuilder() + .setCustomId(`suggest-${interaction.user.id}`) + .setTitle('Suggest a feature for AleeBot'); + + const featureText = new TextInputBuilder() + .setCustomId('feature') + .setLabel('Suggest the feature you want') + .setMaxLength(200) + .setPlaceholder('Feature') + .setStyle(TextInputStyle.Paragraph); + + const firstActionRow = new ActionRowBuilder().addComponents(featureText); + + modal.addComponents(firstActionRow); + + await interaction.showModal(modal); + + const filter = (interaction) => interaction.customId === `suggest-${interaction.user.id}`; + + interaction.awaitModalSubmit({ filter, time: 1000 * 1200 }) + .then(async (modalInteraction) => { + const feature = modalInteraction.fields.getTextInputValue('feature'); + + modalInteraction.client.channels.cache.get(featureSuggestChannel).send({ embeds: [ + new EmbedBuilder() + .setTitle('AleeBot Feature Suggestion') + .setDescription(`This is an AleeBot feature suggested from ${modalInteraction.user.username}.`) + .addFields({ name: 'Suggestion Contents', value: feature }) + .setColor(abEmbedColour) + .setFooter({ text: `Sending from ${modalInteraction.guild.name}`, iconURL: modalInteraction.guild.iconURL() }) + ]}); + + return modalInteraction.reply({content: 'Your suggestion has been sent.', flags: MessageFlags.Ephemeral}); + }) + .catch((err) => { + console.error(err); + }); + + } + } +}; |
