diff options
Diffstat (limited to 'src/commands/dev/sh.ts')
-rw-r--r-- | src/commands/dev/sh.ts | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts index 8c62f5d..f7c17bd 100644 --- a/src/commands/dev/sh.ts +++ b/src/commands/dev/sh.ts @@ -1,8 +1,18 @@ -import { ArgType, BushCommand, type CommandMessage, type SlashMessage } from '#lib'; +import { + ArgType, + BushCommand, + clientSendAndPermCheck, + codeblock, + colors, + emojis, + formatError, + type CommandMessage, + type SlashMessage +} from '#lib'; import assert from 'assert'; import chalk from 'chalk'; import { exec } from 'child_process'; -import { ApplicationCommandOptionType, EmbedBuilder, Util } from 'discord.js'; +import { ApplicationCommandOptionType, cleanCodeBlockContent, EmbedBuilder } from 'discord.js'; import { promisify } from 'util'; assert(chalk); @@ -11,7 +21,7 @@ const sh = promisify(exec); const clean = (text: string | any) => { chalk.toString; if (typeof text === 'string') { - return (text = Util.cleanCodeBlockContent(text)); + return (text = cleanCodeBlockContent(text)); } else return text; }; @@ -35,24 +45,24 @@ export default class ShCommand extends BushCommand { } ], ownerOnly: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m), + clientPermissions: (m) => clientSendAndPermCheck(m), userPermissions: [] }); } public override async exec(message: CommandMessage | SlashMessage, args: { command: ArgType<'string'> }) { if (!client.config.owners.includes(message.author.id)) - return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`); + return await message.util.reply(`${emojis.error} Only my developers can run this command.`); const input = clean(args.command); const embed = new EmbedBuilder() - .setColor(util.colors.gray) + .setColor(colors.gray) .setFooter({ text: message.author.tag, iconURL: message.author.avatarURL() ?? undefined }) .setTimestamp() .setTitle('Shell Command') .addFields([ - { name: '📥 Input', value: await util.codeblock(input, 1024, 'sh', true) }, - { name: 'Running', value: util.emojis.loading } + { name: '📥 Input', value: await codeblock(input, 1024, 'sh', true) }, + { name: 'Running', value: emojis.loading } ]); await message.util.reply({ embeds: [embed] }); @@ -69,20 +79,14 @@ export default class ShCommand extends BushCommand { const stdout = /* strip( */ clean(output.stdout); /* ) */ const stderr = /* strip( */ clean(output.stderr); /* ) */ - embed - .setTitle(`${util.emojis.successFull} Executed command successfully.`) - .setColor(util.colors.success) - .spliceFields(1, 1); + embed.setTitle(`${emojis.successFull} Executed command successfully.`).setColor(colors.success).spliceFields(1, 1); - if (stdout) embed.addFields([{ name: '📤 stdout', value: await util.codeblock(stdout, 1024, 'ansi', true) }]); - if (stderr) embed.addFields([{ name: '📤 stderr', value: await util.codeblock(stderr, 1024, 'ansi', true) }]); + if (stdout) embed.addFields([{ name: '📤 stdout', value: await codeblock(stdout, 1024, 'ansi', true) }]); + if (stderr) embed.addFields([{ name: '📤 stderr', value: await codeblock(stderr, 1024, 'ansi', true) }]); } catch (e) { - embed - .setTitle(`${util.emojis.errorFull} An error occurred while executing.`) - .setColor(util.colors.error) - .spliceFields(1, 1); + embed.setTitle(`${emojis.errorFull} An error occurred while executing.`).setColor(colors.error).spliceFields(1, 1); - embed.addFields([{ name: '📤 Output', value: await util.codeblock(util.formatError(e, true), 1024, 'ansi', true) }]); + embed.addFields([{ name: '📤 Output', value: await codeblock(formatError(e, true), 1024, 'ansi', true) }]); } await message.util.edit({ embeds: [embed] }); } |