From 0c961df89bf08d021f1fd7ce05cdad0b9f934ed5 Mon Sep 17 00:00:00 2001 From: supositware Date: Fri, 17 Jun 2022 12:50:07 +0200 Subject: [PATCH] feedback command --- commands/utility/feedback.js | 32 ++++++++++++++++++++++++++++++++ deploy-commands.cjs | 8 ++++++++ 2 files changed, 40 insertions(+) create mode 100644 commands/utility/feedback.js diff --git a/commands/utility/feedback.js b/commands/utility/feedback.js new file mode 100644 index 0000000..4a7bb10 --- /dev/null +++ b/commands/utility/feedback.js @@ -0,0 +1,32 @@ +import { SlashCommandBuilder } from '@discordjs/builders'; +import { MessageEmbed } from 'discord.js'; + +const { feedbackChannelId } = process.env; + +export default { + data: new SlashCommandBuilder() + .setName('feedback') + .setDescription('Send a feedback to the developer.') + .addStringOption(option => + option.setName('feedback') + .setDescription('The message you want to send me.') + .setRequired(true)), + async execute(interaction) { + const Embed = new MessageEmbed() + .setAuthor({ name: `${interaction.member.displayName} (${interaction.member.id})`, iconURL: interaction.member.displayAvatarURL() }) + .setTimestamp(); + + if (interaction.guild) Embed.addField('Guild', `${interaction.guild.name} (${interaction.guild.id})`, true); + Embed.addField('Feedback', interaction.options.getString('feedback')); + + // Don't let new account use this command to prevent spam + const date = new Date(); + if (interaction.user.createdAt > date.setDate(date.getDate() - 7)) { + return interaction.reply({ content: 'Your account is too new to be able to use this command!', ephemeral: true }); + } + + const channel = interaction.client.channels.resolve(feedbackChannelId); + channel.send({ embeds: [Embed] }); + await interaction.reply({ content: 'Your feedback has been sent! Don\'t forget to have dm open if you want to get an answer from the dev!', ephemeral: true }); + }, +}; diff --git a/deploy-commands.cjs b/deploy-commands.cjs index b45255b..90cded6 100644 --- a/deploy-commands.cjs +++ b/deploy-commands.cjs @@ -37,6 +37,14 @@ const commands = [ option.setName('url') .setDescription('URL of the video you want to convert') .setRequired(true)), + + new SlashCommandBuilder() + .setName('feedback') + .setDescription('Send a feedback to the developer.') + .addStringOption(option => + option.setName('feedback') + .setDescription('The message you want to send me.') + .setRequired(true)), ] .map(command => command.toJSON());