aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moderation/unlockdown.ts
blob: db1a09d6c3d9f1042538f39fb89c0787c2495909 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { LockdownCommand } from '#commands';
import {
	Arg,
	BushCommand,
	clientSendAndPermCheck,
	type ArgType,
	type CommandMessage,
	type OptArgType,
	type SlashMessage
} from '#lib';
import { ApplicationCommandOptionType, ChannelType, PermissionFlagsBits } from 'discord.js';

export default class UnlockdownCommand extends BushCommand {
	public constructor() {
		super('unlockdown', {
			aliases: ['unlockdown', 'unlock', 'lockup'],
			category: 'moderation',
			description: 'Allows you to unlockdown a channel or all configured channels.',
			usage: ['unlockdown [channel] [reason] [--all]'],
			examples: ['unlockdown', 'unlockdown raid is over --all'],
			args: [
				{
					id: 'channel',
					description: 'Specify a different channel to unlockdown instead of the one you trigger the command in.',
					type: Arg.union('textChannel', 'newsChannel', 'threadChannel', 'voiceChannel'),
					prompt: 'What channel would you like to unlockdown?',
					slashType: ApplicationCommandOptionType.Channel,
					channelTypes: [
						ChannelType.GuildText,
						ChannelType.GuildNews,
						ChannelType.GuildNewsThread,
						ChannelType.GuildPublicThread,
						ChannelType.GuildPrivateThread,
						ChannelType.GuildVoice
					],
					optional: true
				},
				{
					id: 'reason',
					description: 'The reason for the unlock.',
					type: 'string',
					match: 'rest',
					prompt: 'What is the reason for the unlock?',
					slashType: ApplicationCommandOptionType.String,
					optional: true
				},
				{
					id: 'all',
					description: 'Whether or not to unlock all configured channels.',
					match: 'flag',
					flag: '--all',
					prompt: 'Would you like to unlockdown all configured channels?',
					slashType: ApplicationCommandOptionType.Boolean,
					optional: true
				}
			],
			slash: true,
			channel: 'guild',
			clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]),
			userPermissions: [PermissionFlagsBits.ManageChannels]
		});
	}

	public override async exec(
		message: CommandMessage | SlashMessage,
		args: {
			channel: OptArgType<'textChannel' | 'newsChannel' | 'threadChannel' | 'voiceChannel'>;
			reason: OptArgType<'string'>;
			all: ArgType<'flag'>;
		}
	) {
		return await LockdownCommand.lockdownOrUnlockdown(message, args, 'unlockdown');
	}
}