Skip to content

Commit

Permalink
docs(CommandPermissions): jsdoc for guildIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaaz committed Feb 20, 2020
1 parent 3bafc6f commit 22610d8
Showing 1 changed file with 37 additions and 5 deletions.
42 changes: 37 additions & 5 deletions src/Structures/Command/CommandPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AxonError from '../../Errors/AxonError';
* bot?: Array<String>, serverMod?: Boolean, serverManager?: Boolean, serverAdmin?: Boolean, serverOwner?: Boolean,
* user?: {needed?: Array<String>, bypass?: Array<String>}, userIDs?: {needed?: Array<String>, bypass?: Array<String>},
* rolesIDs?: {needed?: Array<String>, bypass?: Array<String>}, channelsIDs?: {needed?: Array<String>, bypass?: Array<String>},
* staff?: {needed?: Array<String>, bypass?: Array<String>}, custom?: (i: Message) => boolean
* guildIDs?: {needed?: Array<String>, bypass?: Array<String>}, staff?: {needed?: Array<String>, bypass?: Array<String>}, custom?: (i: Message) => boolean
* }} CommandPerms
* @typedef {import('../../AxonClient').default} AxonClient
* @typedef {import('../../Utility/Utils').default} Utils
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -114,6 +116,9 @@ class CommandPermissions {
needed: (base.channelIDs && base.channelIDs.needed) || [],
bypass: (base.channelIDs && base.channelIDs.bypass) || [],
};
/**
* @type {{needed: Array<String>, bypass: Array<String>}}
*/
this.guildIDs = {
needed: (base.guildIDs && base.guildIDs.needed) || [],
bypass: (base.guildIDs && base.guildIDs.bypass) || [],
Expand Down Expand Up @@ -414,6 +419,33 @@ class CommandPermissions {
return this;
}

/**
* Set the channel IDs needed to be in to execute this command.

This comment has been minimized.

Copy link
@bsian03

bsian03 Feb 23, 2020

Contributor

guild IDs

This comment has been minimized.

Copy link
@Khaaz

Khaaz Feb 24, 2020

Author Owner

fixed in 16c70d3

*
* @param {{needed: Array<String>, bypass: Array<String>}} [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.
*
Expand Down Expand Up @@ -595,9 +627,9 @@ class CommandPermissions {
}

/**
* Check channelIDs [bypass]
* Check guildIDs [bypass]
*
* @param {Channel} channel
* @param {Guild} guild
* @returns {Boolean}
* @memberof CommandPermissions
*/
Expand All @@ -609,9 +641,9 @@ class CommandPermissions {
}

/**
* Check channelIDs [needed]
* Check guildIDs [needed]
*
* @param {Channel} channel
* @param {Guild} guild
* @returns {Boolean}
* @memberof CommandPermissions
*/
Expand Down

0 comments on commit 22610d8

Please sign in to comment.