1
0
Fork 0
mirror of https://github.com/JonnyBro/JaBa.git synced 2024-12-23 03:43:03 +05:00
JaBa/commands/General/suggest.js

89 lines
2.5 KiB
JavaScript
Raw Normal View History

2024-09-19 23:58:06 +05:00
const { SlashCommandBuilder, parseEmoji, InteractionContextType, ApplicationIntegrationType } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Suggest extends BaseCommand {
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../base/Client")} 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"),
})
2024-09-19 23:58:06 +05:00
.setIntegrationTypes([ApplicationIntegrationType.GuildInstall])
2024-09-14 19:52:56 +05:00
.setContexts([InteractionContextType.Guild])
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),
),
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
* @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);
if (!channel) return interaction.error("general/suggest:MISSING_CHANNEL");
2023-06-27 21:19:55 +05:00
const suggestion = interaction.options.getString("message");
const embed = client.embed({
author: {
name: interaction.translate("general/suggest:TITLE", {
user: interaction.user.getUsername(),
}),
iconURL: interaction.member.displayAvatarURL(),
},
fields: [
{
name: interaction.translate("common:DATE"),
value: `<t:${Math.floor(Date.now() / 1000)}:D>`,
},
{
name: interaction.translate("common:AUTHOR"),
value: interaction.user.toString(),
inline: true,
},
{
name: interaction.translate("common:CONTENT"),
value: suggestion,
inline: true,
},
],
});
const success = parseEmoji(client.customEmojis.cool).id;
const error = parseEmoji(client.customEmojis.notcool).id;
channel.send({
embeds: [embed],
}).then(async m => {
await m.react(success);
await m.react(error);
});
interaction.success("general/suggest:SUCCESS", {
channel: channel.toString(),
}, { ephemeral: true });
}
}
2023-07-05 00:58:06 +05:00
module.exports = Suggest;