JaBa/commands/General/suggest.js

98 lines
2.6 KiB
JavaScript
Raw Normal View History

const { SlashCommandBuilder, EmbedBuilder, parseEmoji } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Suggest extends BaseCommand {
/**
*
* @param {import("../base/JaBa")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("suggest")
.setDescription(client.translate("general/suggest:DESCRIPTION"))
.setDescriptionLocalizations({
2023-07-05 00:58:06 +05:00
uk: client.translate("general/suggest:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/suggest:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(false)
2023-07-05 00:58:06 +05:00
.addStringOption(option =>
option
.setName("message")
.setDescription(client.translate("common:MESSAGE"))
.setDescriptionLocalizations({
uk: client.translate("common:MESSAGE", null, "uk-UA"),
ru: client.translate("common:MESSAGE", null, "ru-RU"),
})
.setRequired(true),
),
aliases: [],
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
* @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
2022-08-09 23:48:33 +05:00
* @param {Object} data
*/
2023-06-27 21:19:55 +05:00
async execute(client, interaction, data) {
const suggChannel = interaction.guild.channels.cache.get(data.guildData.plugins.suggestions);
if (!suggChannel) return interaction.error("general/suggest:MISSING_CHANNEL");
2023-06-27 21:19:55 +05:00
const suggestion = interaction.options.getString("message");
const embed = new EmbedBuilder()
.setAuthor({
name: interaction.translate("general/suggest:TITLE", {
user: interaction.user.getUsername(),
}),
iconURL: interaction.member.displayAvatarURL(),
})
.addFields([
{
name: interaction.translate("common:DATE"),
2023-05-30 15:28:41 +05:00
value: client.functions.printDate(client, new Date(Date.now())),
},
{
name: interaction.translate("common:AUTHOR"),
value: interaction.user.toString(),
inline: true,
},
{
name: interaction.translate("common:CONTENT"),
value: suggestion,
inline: true,
},
])
.setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
});
const success = parseEmoji(client.customEmojis.cool).id;
const error = parseEmoji(client.customEmojis.notcool).id;
suggChannel.send({
embeds: [embed],
}).then(async m => {
await m.react(success);
await m.react(error);
});
interaction.success("general/suggest:SUCCESS", {
channel: suggChannel.toString(),
}, { ephemeral: true });
}
}
2023-07-05 00:58:06 +05:00
module.exports = Suggest;