From 0d87396461833b23aaaf733aaa6f03e4889f4224 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Thu, 2 Jun 2022 18:08:43 -0400 Subject: fix: allow vc channels to be locked --- src/commands/moderation/lockdown.ts | 30 ++++++++++++++++++++++-------- src/lib/extensions/discord.js/BushGuild.ts | 5 +++-- 2 files changed, 25 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/commands/moderation/lockdown.ts b/src/commands/moderation/lockdown.ts index f298ec9..d10a5d4 100644 --- a/src/commands/moderation/lockdown.ts +++ b/src/commands/moderation/lockdown.ts @@ -1,9 +1,6 @@ import { AllowedMentions, BushCommand, - BushNewsChannel, - BushTextChannel, - BushThreadChannel, ConfirmationPrompt, type ArgType, type BushMessage, @@ -11,7 +8,16 @@ import { type OptArgType } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, ChannelType, Collection, PermissionFlagsBits } from 'discord.js'; +import { + ApplicationCommandOptionType, + ChannelType, + Collection, + NewsChannel, + PermissionFlagsBits, + TextChannel, + ThreadChannel, + VoiceChannel +} from 'discord.js'; export default class LockdownCommand extends BushCommand { public constructor() { @@ -25,7 +31,7 @@ export default class LockdownCommand extends BushCommand { { id: 'channel', description: 'Specify a different channel to lockdown instead of the one you trigger the command in.', - type: util.arg.union('textChannel', 'newsChannel', 'threadChannel'), + type: util.arg.union('textChannel', 'newsChannel', 'threadChannel', 'voiceChannel'), prompt: 'What channel would you like to lockdown?', slashType: ApplicationCommandOptionType.Channel, channelTypes: [ @@ -33,7 +39,8 @@ export default class LockdownCommand extends BushCommand { ChannelType.GuildNews, ChannelType.GuildNewsThread, ChannelType.GuildPublicThread, - ChannelType.GuildPrivateThread + ChannelType.GuildPrivateThread, + ChannelType.GuildVoice ], optional: true }, @@ -78,7 +85,7 @@ export default class LockdownCommand extends BushCommand { public static async lockdownOrUnlockdown( message: BushMessage | BushSlashMessage, args: { - channel: OptArgType<'textChannel'> | OptArgType<'newsChannel'> | OptArgType<'threadChannel'>; + channel: OptArgType<'textChannel'> | OptArgType<'newsChannel'> | OptArgType<'threadChannel'> | OptArgType<'voiceChannel'>; reason: OptArgType<'string'>; all: ArgType<'boolean'>; }, @@ -92,7 +99,14 @@ export default class LockdownCommand extends BushCommand { const channel = args.channel ?? message.channel; - if (!(channel instanceof BushTextChannel || channel instanceof BushNewsChannel || channel instanceof BushThreadChannel)) + if ( + !( + channel instanceof TextChannel || + channel instanceof NewsChannel || + channel instanceof ThreadChannel || + channel instanceof VoiceChannel + ) + ) return await message.util.reply( `${util.emojis.error} You can only ${action} text channels, news channels, and thread channels.` ); diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts index 80755bc..a93e35f 100644 --- a/src/lib/extensions/discord.js/BushGuild.ts +++ b/src/lib/extensions/discord.js/BushGuild.ts @@ -4,6 +4,7 @@ import { BushGuildChannelManager, BushGuildMemberManager, BushMessage, + BushVoiceChannel, dmResponse, permissionsResponse, punishmentEntryRemove, @@ -408,7 +409,7 @@ export class BushGuild extends Guild { const ret = await (async (): Promise => { for (const _channel of mappedChannels) { const channel = _channel!; - if (!channel.isText() && !channel.isThread()) { + if (!channel.isTextBased()) { errors.set(channel.id, new Error('wrong channel type')); success.set(channel.id, false); continue; @@ -761,7 +762,7 @@ export interface LockdownOptions { /** * A specific channel to lockdown */ - channel?: BushThreadChannel | BushNewsChannel | BushTextChannel; + channel?: BushThreadChannel | BushNewsChannel | BushTextChannel | BushVoiceChannel; /** * Whether or not to unlock the channel(s) instead of locking them -- cgit