mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-21 02:03:57 +00:00
- Migrated to a new command framework which looks better and works better - Fixed commands not being bundled correctly - Added message (prefix) commands with argument validation - Added a new CommandErrorType, for invalid arguments - `/eval` is now a bit safer - Corrected colors for the coinflip embed - `/stop` now works even when the bot is not connected to the API
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { inspect } from 'util'
|
|
import { runInNewContext } from 'vm'
|
|
import { ApplicationCommandOptionType } from 'discord.js'
|
|
|
|
import { AdminCommand } from '$/classes/Command'
|
|
import { createSuccessEmbed } from '$/utils/discord/embeds'
|
|
|
|
export default new AdminCommand({
|
|
name: 'eval',
|
|
description: 'Make the bot less sentient by evaluating code',
|
|
options: {
|
|
code: {
|
|
description: 'The code to evaluate',
|
|
type: ApplicationCommandOptionType.String,
|
|
required: true,
|
|
},
|
|
['show-hidden']: {
|
|
description: 'Show hidden properties',
|
|
type: ApplicationCommandOptionType.Boolean,
|
|
required: false,
|
|
},
|
|
},
|
|
async execute(context, trigger, { code, 'show-hidden': showHidden }) {
|
|
await trigger.reply({
|
|
ephemeral: true,
|
|
embeds: [
|
|
createSuccessEmbed('Evaluate', `\`\`\`js\n${code}\`\`\``).addFields({
|
|
name: 'Result',
|
|
value: `\`\`\`js\n${inspect(runInNewContext(code, { client: trigger.client, context, trigger }), { depth: 1, showHidden, getters: true, numericSeparator: true, showProxy: true })}\`\`\``,
|
|
}),
|
|
],
|
|
})
|
|
},
|
|
})
|