2024-02-06 21:45:53 +05:00
|
|
|
const { SlashCommandBuilder, parseEmoji } = require("discord.js");
|
2022-08-04 19:26:17 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Suggest extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../base/Client")} client
|
2022-08-04 19:26:17 +05:00
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("suggest")
|
|
|
|
.setDescription(client.translate("general/suggest:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.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"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2022-10-13 00:05:36 +05:00
|
|
|
.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),
|
|
|
|
),
|
2022-08-04 19:26:17 +05:00
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-04 19:26:17 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-08-04 19:26:17 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-04 19:26:17 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
|
|
|
*/
|
2024-02-09 23:26:57 +05:00
|
|
|
async execute(client, interaction) {
|
|
|
|
const guildData = interaction.data.guild,
|
|
|
|
channel = interaction.guild.channels.cache.get(guildData.plugins.suggestions);
|
2024-02-06 21:45:53 +05:00
|
|
|
if (!channel) return interaction.error("general/suggest:MISSING_CHANNEL");
|
2023-06-27 21:19:55 +05:00
|
|
|
|
2022-08-04 19:26:17 +05:00
|
|
|
const suggestion = interaction.options.getString("message");
|
|
|
|
|
2024-02-06 21:45:53 +05:00
|
|
|
const embed = client.embed({
|
|
|
|
author: {
|
2022-08-04 19:26:17 +05:00
|
|
|
name: interaction.translate("general/suggest:TITLE", {
|
2023-07-03 14:25:25 +05:00
|
|
|
user: interaction.user.getUsername(),
|
2022-08-04 19:26:17 +05:00
|
|
|
}),
|
2022-12-15 21:02:38 +05:00
|
|
|
iconURL: interaction.member.displayAvatarURL(),
|
2024-02-06 21:45:53 +05:00
|
|
|
},
|
|
|
|
fields: [
|
2022-08-04 19:26:17 +05:00
|
|
|
{
|
|
|
|
name: interaction.translate("common:DATE"),
|
2024-02-06 21:45:53 +05:00
|
|
|
value: `<t:${Math.floor(Date.now() / 1000)}:D>`,
|
2022-08-04 19:26:17 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: interaction.translate("common:AUTHOR"),
|
|
|
|
value: interaction.user.toString(),
|
2022-12-15 21:02:38 +05:00
|
|
|
inline: true,
|
2022-08-04 19:26:17 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: interaction.translate("common:CONTENT"),
|
|
|
|
value: suggestion,
|
2022-12-15 21:02:38 +05:00
|
|
|
inline: true,
|
|
|
|
},
|
2024-02-06 21:45:53 +05:00
|
|
|
],
|
|
|
|
});
|
2022-08-04 19:26:17 +05:00
|
|
|
|
|
|
|
const success = parseEmoji(client.customEmojis.cool).id;
|
|
|
|
const error = parseEmoji(client.customEmojis.notcool).id;
|
|
|
|
|
2024-02-06 21:45:53 +05:00
|
|
|
channel.send({
|
2022-12-15 21:02:38 +05:00
|
|
|
embeds: [embed],
|
2022-08-06 20:47:47 +05:00
|
|
|
}).then(async m => {
|
2022-08-04 19:26:17 +05:00
|
|
|
await m.react(success);
|
|
|
|
await m.react(error);
|
|
|
|
});
|
|
|
|
|
|
|
|
interaction.success("general/suggest:SUCCESS", {
|
2024-02-06 21:45:53 +05:00
|
|
|
channel: channel.toString(),
|
2023-01-09 01:39:13 +05:00
|
|
|
}, { ephemeral: true });
|
2022-08-04 19:26:17 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Suggest;
|