JaBa/commands/Administration/stealemoji.js

63 lines
1.8 KiB
JavaScript
Raw Permalink Normal View History

2023-07-03 21:13:08 +05:00
const { SlashCommandBuilder, parseEmoji, PermissionsBitField } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Stealemoji extends BaseCommand {
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("stealemoji")
.setDescription(client.translate("administration/stealemoji:DESCRIPTION"))
.setDescriptionLocalizations({
2023-07-05 00:58:06 +05:00
uk: client.translate("administration/stealemoji:DESCRIPTION", null, "uk-UA"),
ru: client.translate("administration/stealemoji:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(false)
2023-07-03 21:13:08 +05:00
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
2023-07-05 00:58:06 +05:00
.addStringOption(option =>
option
.setName("emoji")
.setDescription(client.translate("common:EMOJI"))
.setDescriptionLocalizations({
uk: client.translate("common:EMOJI", null, "uk-UA"),
ru: client.translate("common:EMOJI", 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
*/
async execute(client, interaction) {
2024-02-09 23:26:57 +05:00
const parsedEmoji = parseEmoji(interaction.options.getString("emoji"));
interaction.guild.emojis
.create({
name: parsedEmoji.name,
2024-02-09 23:26:57 +05:00
attachment: `https://cdn.discordapp.com/emojis/${parsedEmoji.id}.${parsedEmoji.animated ? "gif" : "png"}`,
})
2023-07-05 00:58:06 +05:00
.then(emoji =>
interaction.success("administration/stealemoji:SUCCESS", {
emoji: emoji.name,
}, { ephemeral: true }),
)
.catch(e => {
interaction.error("administration/stealemoji:ERROR", {
2022-08-09 23:48:33 +05:00
emoji: parsedEmoji.name,
e,
}, { ephemeral: true });
});
}
}
2023-07-05 00:58:06 +05:00
module.exports = Stealemoji;