aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-13 15:17:00 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-13 15:17:00 -0500
commit6a7386a181e788927a4c04e5b39ac2a4275918b6 (patch)
tree0902ef3c60e146e28b10e09c452f5c46c5cd224f
parent87e7ba3784f02d2e146051e59a08412648c6ff79 (diff)
downloadtanzanite-6a7386a181e788927a4c04e5b39ac2a4275918b6.tar.gz
tanzanite-6a7386a181e788927a4c04e5b39ac2a4275918b6.tar.bz2
tanzanite-6a7386a181e788927a4c04e5b39ac2a4275918b6.zip
fix: permission handler showing numbers
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index c4a5e79..41d16f7 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -28,6 +28,7 @@ import {
Message,
PermissionFlagsBits,
PermissionsBitField,
+ PermissionsString,
ThreadMember,
User,
Util as DiscordUtil,
@@ -798,10 +799,13 @@ export class BushClientUtil extends ClientUtil {
* @param permissions The permissions to check for.
* @returns The missing permissions or null if none are missing.
*/
- public userGuildPermCheck(message: BushMessage | BushSlashMessage, permissions: bigint[]) {
+ public userGuildPermCheck(
+ message: BushMessage | BushSlashMessage,
+ permissions: typeof PermissionFlagsBits[keyof typeof PermissionFlagsBits][]
+ ): PermissionsString[] | null {
const missing = message.member?.permissions.missing(permissions) ?? [];
- return missing.length ? missing.map((p) => PermissionFlagsBits[p]) : null;
+ return missing.length ? missing : null;
}
/**
@@ -810,10 +814,10 @@ export class BushClientUtil extends ClientUtil {
* @param permissions The permissions to check for.
* @returns The missing permissions or null if none are missing.
*/
- public clientGuildPermCheck(message: BushMessage | BushSlashMessage, permissions: bigint[]) {
+ public clientGuildPermCheck(message: BushMessage | BushSlashMessage, permissions: bigint[]): PermissionsString[] | null {
const missing = message.guild?.me?.permissions.missing(permissions) ?? [];
- return missing.length ? missing.map((p) => PermissionFlagsBits[p]) : null;
+ return missing.length ? missing : null;
}
/**
@@ -824,19 +828,20 @@ export class BushClientUtil extends ClientUtil {
* @param checkChannel Whether to check the channel permissions instead of the guild permissions.
* @returns The missing permissions or null if none are missing.
*/
- public clientSendAndPermCheck(message: BushMessage | BushSlashMessage, permissions: bigint[] = [], checkChannel = false) {
- const missing = [];
- const sendPerm = message.channel!.isThread() ? PermissionFlagsBits.SendMessages : PermissionFlagsBits.SendMessagesInThreads;
+ public clientSendAndPermCheck(
+ message: BushMessage | BushSlashMessage,
+ permissions: bigint[] = [],
+ checkChannel = false
+ ): PermissionsString[] | null {
+ const missing: PermissionsString[] = [];
+ const sendPerm = message.channel!.isThread() ? 'SendMessages' : 'SendMessagesInThreads';
if (!message.inGuild()) return null;
if (!message.guild.me!.permissionsIn(message.channel.id).has(sendPerm)) missing.push(sendPerm);
missing.push(
...(checkChannel
- ? message
- .guild!.me!.permissionsIn(message.channel!.id!)
- .missing(permissions)
- .map((p) => PermissionFlagsBits[p])
+ ? message.guild!.me!.permissionsIn(message.channel!.id!).missing(permissions)
: this.clientGuildPermCheck(message, permissions) ?? [])
);