aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.d.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-12-26 17:16:32 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-12-26 17:16:32 -0500
commitfc390ffc300334c396d9d06b0feaf8fbc6ed2814 (patch)
treea6282a74cf99033291ac7bc9de123ae273d528d2 /src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.d.ts
parent062435590980b87f5b054418ed88604e26358ae9 (diff)
downloadtanzanite-fc390ffc300334c396d9d06b0feaf8fbc6ed2814.tar.gz
tanzanite-fc390ffc300334c396d9d06b0feaf8fbc6ed2814.tar.bz2
tanzanite-fc390ffc300334c396d9d06b0feaf8fbc6ed2814.zip
documentation, bug fixes etc
Diffstat (limited to 'src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.d.ts')
-rw-r--r--src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.d.ts123
1 files changed, 123 insertions, 0 deletions
diff --git a/src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.d.ts b/src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.d.ts
index 5f2e4da..ff32be4 100644
--- a/src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.d.ts
+++ b/src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.d.ts
@@ -13,6 +13,9 @@ import {
} from 'discord.js';
import type { ApplicationCommandPermissionTypes } from 'discord.js/typings/enums';
+/**
+ * Manages API methods for permissions of Application Commands.
+ */
export class BushApplicationCommandPermissionsManager<
BaseOptions,
FetchSingleOptions,
@@ -21,18 +24,95 @@ export class BushApplicationCommandPermissionsManager<
CommandIdType
> extends BaseManager {
public constructor(manager: ApplicationCommandManager | GuildApplicationCommandManager | ApplicationCommand);
+
+ /**
+ * The manager or command that this manager belongs to
+ */
private manager: ApplicationCommandManager | GuildApplicationCommandManager | ApplicationCommand;
+ /**
+ * The client that instantiated this Manager
+ */
public client: BushClient;
+
+ /**
+ * The id of the command this manager acts on
+ */
public commandId: CommandIdType;
+
+ /**
+ * The guild that this manager acts on
+ */
public guild: GuildType;
+
+ /**
+ * The id of the guild that this manager acts on
+ */
public guildId: Snowflake | null;
+
+ /**
+ * Add permissions to a command.
+ * @param options Options used to add permissions
+ * @example
+ * // Block a role from the command permissions
+ * guild.commands.permissions.add({ command: '123456789012345678', permissions: [
+ * {
+ * id: '876543211234567890',
+ * type: 'ROLE',
+ * permission: false
+ * },
+ * ]})
+ * .then(console.log)
+ * .catch(console.error);
+ */
public add(
options: FetchSingleOptions & { permissions: ApplicationCommandPermissionData[] }
): Promise<ApplicationCommandPermissions[]>;
+
+ /**
+ * Check whether a permission exists for a user or role
+ * @param options Options used to check permissions
+ * @example
+ * // Check whether a user has permission to use a command
+ * guild.commands.permissions.has({ command: '123456789012345678', permissionId: '876543210123456789' })
+ * .then(console.log)
+ * .catch(console.error);
+ */
public has(options: FetchSingleOptions & { permissionId: BushUserResolvable | BushRoleResolvable }): Promise<boolean>;
+
+ /**
+ * Fetches the permissions for one or multiple commands.
+ * @param options Options used to fetch permissions
+ * @example
+ * // Fetch permissions for one command
+ * guild.commands.permissions.fetch({ command: '123456789012345678' })
+ * .then(perms => console.log(`Fetched permissions for ${perms.length} users`))
+ * .catch(console.error);
+ * @example
+ * // Fetch permissions for all commands in a guild
+ * client.application.commands.permissions.fetch({ guild: '123456789012345678' })
+ * .then(perms => console.log(`Fetched permissions for ${perms.size} commands`))
+ * .catch(console.error);
+ */
public fetch(options: FetchSingleOptions): Promise<ApplicationCommandPermissions[]>;
public fetch(options: BaseOptions): Promise<Collection<Snowflake, ApplicationCommandPermissions[]>>;
+
+ /**
+ * Remove permissions from a command.
+ * @param options Options used to remove permissions
+ * @example
+ * // Remove a user permission from this command
+ * guild.commands.permissions.remove({ command: '123456789012345678', users: '876543210123456789' })
+ * .then(console.log)
+ * .catch(console.error);
+ * @example
+ * // Remove multiple roles from this command
+ * guild.commands.permissions.remove({
+ * command: '123456789012345678', roles: ['876543210123456789', '765432101234567890']
+ * })
+ * .then(console.log)
+ * .catch(console.error);
+ */
public remove(
options:
| (FetchSingleOptions & {
@@ -44,6 +124,37 @@ export class BushApplicationCommandPermissionsManager<
roles: BushRoleResolvable | BushRoleResolvable[];
})
): Promise<ApplicationCommandPermissions[]>;
+
+ /**
+ * Sets the permissions for one or more commands.
+ * @param options Options used to set permissions
+ * @example
+ * // Set the permissions for one command
+ * client.application.commands.permissions.set({ guild: '892455839386304532', command: '123456789012345678',
+ * permissions: [
+ * {
+ * id: '876543210987654321',
+ * type: 'USER',
+ * permission: false,
+ * },
+ * ]})
+ * .then(console.log)
+ * .catch(console.error);
+ * @example
+ * // Set the permissions for all commands
+ * guild.commands.permissions.set({ fullPermissions: [
+ * {
+ * id: '123456789012345678',
+ * permissions: [{
+ * id: '876543210987654321',
+ * type: 'USER',
+ * permission: false,
+ * }],
+ * },
+ * ]})
+ * .then(console.log)
+ * .catch(console.error);
+ */
public set(
options: FetchSingleOptions & { permissions: ApplicationCommandPermissionData[] }
): Promise<ApplicationCommandPermissions[]>;
@@ -52,7 +163,19 @@ export class BushApplicationCommandPermissionsManager<
fullPermissions: GuildApplicationCommandPermissionData[];
}
): Promise<Collection<Snowflake, ApplicationCommandPermissions[]>>;
+
+ /**
+ * The APIRouter path to the commands
+ * @param guildId The guild's id to use in the path,
+ * @param commandId The application command's id
+ */
private permissionsPath(guildId: Snowflake, commandId?: Snowflake): unknown;
+
+ /**
+ * Transforms an {@link ApplicationCommandPermissionData} object into something that can be used with the API.
+ * @param permissions The permissions to transform
+ * @param received Whether these permissions have been received from Discord
+ */
private static transformPermissions(
permissions: ApplicationCommandPermissionData,
received: true