From 22610d8b1774df49c9a940a3e1cacc79b9ea6d09 Mon Sep 17 00:00:00 2001 From: Khaazz Date: Thu, 20 Feb 2020 18:08:11 +0100 Subject: [PATCH] docs(CommandPermissions): jsdoc for guildIDs --- src/Structures/Command/CommandPermissions.js | 42 +++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/src/Structures/Command/CommandPermissions.js b/src/Structures/Command/CommandPermissions.js index 6ca79e13..125ac613 100644 --- a/src/Structures/Command/CommandPermissions.js +++ b/src/Structures/Command/CommandPermissions.js @@ -9,7 +9,7 @@ import AxonError from '../../Errors/AxonError'; * bot?: Array, serverMod?: Boolean, serverManager?: Boolean, serverAdmin?: Boolean, serverOwner?: Boolean, * user?: {needed?: Array, bypass?: Array}, userIDs?: {needed?: Array, bypass?: Array}, * rolesIDs?: {needed?: Array, bypass?: Array}, channelsIDs?: {needed?: Array, bypass?: Array}, - * staff?: {needed?: Array, bypass?: Array}, custom?: (i: Message) => boolean + * guildIDs?: {needed?: Array, bypass?: Array}, staff?: {needed?: Array, bypass?: Array}, custom?: (i: Message) => boolean * }} CommandPerms * @typedef {import('../../AxonClient').default} AxonClient * @typedef {import('../../Utility/Utils').default} Utils @@ -42,6 +42,8 @@ import AxonError from '../../Errors/AxonError'; * @prop {Array} [roleIDs.bypass=[]] - Discord role ids that will allow the user to execute the command no matter what * @prop {Array} [channelIDs.needed=[]] - Discord channel ids that the user needs to have in order to execute the command * @prop {Array} [channelIDs.bypass=[]] - Discord channel ids that will allow the user to execute the command no matter what + * @prop {Array} [guildIDs.needed=[]] - Discord guild ids that the user needs to have in order to execute the command + * @prop {Array} [guildIDs.bypass=[]] - Discord guild ids that will allow the user to execute the command no matter what * @prop {Array} [staff.needed=[]] - Axoncore staff ids that the user needs to have in order to execute the command * @prop {Array} [staff.bypass=[]] - Axoncore staff ids that will allow the user to execute the command no matter what * @prop {Function} [custom=()=>true] Custom function that returns a boolean. True will let the command execute, False will prevent the command from executing @@ -114,6 +116,9 @@ class CommandPermissions { needed: (base.channelIDs && base.channelIDs.needed) || [], bypass: (base.channelIDs && base.channelIDs.bypass) || [], }; + /** + * @type {{needed: Array, bypass: Array}} + */ this.guildIDs = { needed: (base.guildIDs && base.guildIDs.needed) || [], bypass: (base.guildIDs && base.guildIDs.bypass) || [], @@ -414,6 +419,33 @@ class CommandPermissions { return this; } + /** + * Set the channel IDs needed to be in to execute this command. + * + * @param {{needed: Array, bypass: Array}} [object={ bypass: [], needed: [] }] - Object of permissions + * @param {Boolean} [toAdd=false] - Whether to add the permissions to the existing permissions + * @returns {CommandPermissions} + * @memberof CommandPermissions + */ + setGuildlIDs(object = { bypass: [], needed: [] }, toAdd = false) { + if (toAdd) { + if (object.bypass.length > 0) { + this.guildIDs.bypass = [...this.guildIDs.bypass, ...object.bypass]; + } + if (object.needed.length > 0) { + this.guildIDs.needed = [...this.guildIDs.needed, ...object.needed]; + } + } else { + if (object.bypass.length > 0) { + this.guildIDs.bypass = object.bypass; + } + if (object.needed.length > 0) { + this.guildIDs.needed = object.needed; + } + } + return this; + } + /** * Set the AxonCore staff members that can execute this command. * @@ -595,9 +627,9 @@ class CommandPermissions { } /** - * Check channelIDs [bypass] + * Check guildIDs [bypass] * - * @param {Channel} channel + * @param {Guild} guild * @returns {Boolean} * @memberof CommandPermissions */ @@ -609,9 +641,9 @@ class CommandPermissions { } /** - * Check channelIDs [needed] + * Check guildIDs [needed] * - * @param {Channel} channel + * @param {Guild} guild * @returns {Boolean} * @memberof CommandPermissions */