mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-18 16:53: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
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
|
import { ApplicationCommandOptionType, Message } from 'discord.js'
|
|
import { ModerationCommand } from '../../classes/Command'
|
|
|
|
export default new ModerationCommand({
|
|
name: 'reply',
|
|
description: 'Send a message as the bot',
|
|
options: {
|
|
message: {
|
|
description: 'The message to send',
|
|
required: true,
|
|
type: ApplicationCommandOptionType.String,
|
|
},
|
|
reference: {
|
|
description: 'The message ID to reply to (use `latest` to reply to the latest message)',
|
|
required: false,
|
|
type: ApplicationCommandOptionType.String,
|
|
},
|
|
},
|
|
allowMessageCommand: false,
|
|
async execute({ logger, executor }, trigger, { reference: ref, message: msg }) {
|
|
if (trigger instanceof Message) return
|
|
|
|
const channel = await trigger.guild!.channels.fetch(trigger.channelId)
|
|
if (!channel?.isTextBased())
|
|
throw new CommandError(
|
|
CommandErrorType.InvalidArgument,
|
|
'This command can only be used in or on text channels',
|
|
)
|
|
const refMsg = ref?.startsWith('latest')
|
|
? await channel.messages.fetch({ limit: 1 }).then(it => it.first())
|
|
: ref
|
|
|
|
await channel.send({
|
|
content: msg,
|
|
reply: refMsg ? { messageReference: refMsg, failIfNotExists: true } : undefined,
|
|
})
|
|
|
|
logger.info(`User ${executor.user.tag} made the bot say: ${msg}`)
|
|
|
|
await trigger.reply({
|
|
content: 'OK!',
|
|
ephemeral: true,
|
|
})
|
|
},
|
|
})
|