JaBa/commands/Administration/stealemoji.js
Jonny_Bro (Nikita) 2ab201e1c1 fix permissions
2023-07-03 21:13:08 +05:00

66 lines
No EOL
1.9 KiB
JavaScript

const { SlashCommandBuilder, parseEmoji, PermissionsBitField } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Stealemoji extends BaseCommand {
/**
*
* @param {import("../../base/JaBa")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("stealemoji")
.setDescription(client.translate("administration/stealemoji:DESCRIPTION"))
.setDescriptionLocalizations({
"uk": client.translate("administration/stealemoji:DESCRIPTION", null, "uk-UA"),
"ru": client.translate("administration/stealemoji:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
.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)),
aliases: [],
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
* @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
const parsedEmoji = parseEmoji(interaction.options.getString("emoji")),
ext = parsedEmoji.animated ? "gif" : "png";
interaction.guild.emojis
.create({
name: parsedEmoji.name,
attachment: `https://cdn.discordapp.com/emojis/${parsedEmoji.id}.${ext}`,
})
.then(emoji => interaction.success("administration/stealemoji:SUCCESS", {
emoji: emoji.name,
}, { ephemeral: true }))
.catch(e => {
interaction.error("administration/stealemoji:ERROR", {
emoji: parsedEmoji.name,
e,
}, { ephemeral: true });
});
}
}
module.exports = Stealemoji;