mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +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
40 lines
1.6 KiB
TypeScript
40 lines
1.6 KiB
TypeScript
import { ModerationCommand } from '$/classes/Command'
|
|
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
|
import { appliedPresets } from '$/database/schemas'
|
|
import { createModerationActionEmbed } from '$/utils/discord/embeds'
|
|
import { sendModerationReplyAndLogs } from '$/utils/discord/moderation'
|
|
import { removeRolePreset } from '$/utils/discord/rolePresets'
|
|
import { and, eq } from 'drizzle-orm'
|
|
|
|
export default new ModerationCommand({
|
|
name: 'unmute',
|
|
description: 'Unmute a member',
|
|
options: {
|
|
member: {
|
|
description: 'The member to unmute',
|
|
required: true,
|
|
type: ModerationCommand.OptionType.User,
|
|
},
|
|
},
|
|
async execute({ logger, database, executor }, interaction, { member: user }) {
|
|
const member = await interaction.guild!.members.fetch(user.id)
|
|
if (!member)
|
|
throw new CommandError(
|
|
CommandErrorType.InvalidUser,
|
|
'The provided member is not in the server or does not exist.',
|
|
)
|
|
|
|
if (
|
|
!(await database.query.appliedPresets.findFirst({
|
|
where: and(eq(appliedPresets.memberId, member.id), eq(appliedPresets.preset, 'mute')),
|
|
}))
|
|
)
|
|
throw new CommandError(CommandErrorType.Generic, 'This user is not muted.')
|
|
|
|
await removeRolePreset(member, 'mute')
|
|
await sendModerationReplyAndLogs(interaction, createModerationActionEmbed('Unmuted', user, executor.user))
|
|
|
|
logger.info(`Moderator ${executor.user.tag} (${executor.id}) unmuted ${user.tag} (${user.id})`)
|
|
},
|
|
})
|