mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-27 21:21:03 +00:00
feat(bots/discord): framework changes and new features
- 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
This commit is contained in:
34
bots/discord/src/commands/admin/eval.ts
Normal file
34
bots/discord/src/commands/admin/eval.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
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 })}\`\`\``,
|
||||
}),
|
||||
],
|
||||
})
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user