import { CacheType, ChatInputCommandInteraction, Message, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js'; import ConfigManager from '../controller/ConfigManager'; import EcoManager from '../controller/EcoManager'; // const adminPermissions = new PermissionsBitField('Administrator'); export default { data: new SlashCommandBuilder() .setName('exec') .setDescription('Exec command') .addStringOption(opt => opt.setName("command").setDescription("Command").setRequired(true)) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), async execute(interaction: ChatInputCommandInteraction, config: ConfigManager) { const ecoManager = new EcoManager(config) const command = interaction.options.getString('command') await interaction.deferReply({ ephemeral: true }) try { if (!command) { await interaction.followUp(`Ошибка выполнения команды.`); return } const status = await ecoManager.Exec(command) if (!!status && !status.Errored) { if (status.CommandMessages.filter(e => e.Type === "Notifications-Chat").length > 0) { await interaction.followUp(status.CommandMessages.filter(e => e.Type === "Notifications-Chat")[0].Message) } else await interaction.followUp("Команда выполнена.\n" + JSON.stringify(status)) } else { await interaction.followUp("Ошибка выполнения команды.\n" + JSON.stringify(status)) } return } catch (error) { await interaction.followUp("Ошибка выполнения команды.") console.log(error) } }, };