mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
refactor(*): make typedefs for all options params (#5785)
Co-authored-by: Rodry <38259440+ImRodry@users.noreply.github.com> Co-authored-by: Antonio Román <kyradiscord@gmail.com> Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
This commit is contained in:
@@ -119,10 +119,10 @@ class GuildBanManager extends BaseManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for banning a user.
|
||||
* Options used to ban a user from a guild.
|
||||
* @typedef {Object} BanOptions
|
||||
* @property {number} [days] Number of days of messages to delete, must be between 0 and 7, inclusive
|
||||
* @property {string} [reason] Reason for banning
|
||||
* @property {number} [days=0] Number of days of messages to delete, must be between 0 and 7, inclusive
|
||||
* @property {string} [reason] The reason for the ban
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,22 +59,27 @@ class GuildChannelManager extends BaseManager {
|
||||
* @returns {?Snowflake}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Options used to create a new channel in a guild.
|
||||
* @typedef {Object} GuildChannelCreateOptions
|
||||
* @property {string} [type='text'] The type of the new channel, either `text`, `voice`, `category`, `news`,
|
||||
* `store`, or `stage`
|
||||
* @property {string} [topic] The topic for the new channel
|
||||
* @property {boolean} [nsfw] Whether the new channel is nsfw
|
||||
* @property {number} [bitrate] Bitrate of the new channel in bits (only voice)
|
||||
* @property {number} [userLimit] Maximum amount of users allowed in the new channel (only voice)
|
||||
* @property {ChannelResolvable} [parent] Parent of the new channel
|
||||
* @property {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} [permissionOverwrites]
|
||||
* Permission overwrites of the new channel
|
||||
* @property {number} [position] Position of the new channel
|
||||
* @property {number} [rateLimitPerUser] The ratelimit per user for the new channel
|
||||
* @property {string} [reason] Reason for creating the new channel
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new channel in the guild.
|
||||
* @param {string} name The name of the new channel
|
||||
* @param {Object} [options] Options
|
||||
* @param {string} [options.type='text'] The type of the new channel, either `text`, `voice`, `category`, `news`,
|
||||
* `store`, or `stage`
|
||||
* @param {string} [options.topic] The topic for the new channel
|
||||
* @param {boolean} [options.nsfw] Whether the new channel is nsfw
|
||||
* @param {number} [options.bitrate] Bitrate of the new channel in bits (only voice)
|
||||
* @param {number} [options.userLimit] Maximum amount of users allowed in the new channel (only voice)
|
||||
* @param {ChannelResolvable} [options.parent] Parent of the new channel
|
||||
* @param {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} [options.permissionOverwrites]
|
||||
* Permission overwrites of the new channel
|
||||
* @param {number} [options.position] Position of the new channel
|
||||
* @param {number} [options.rateLimitPerUser] The ratelimit per user for the channel
|
||||
* @param {string} [options.reason] Reason for creating the channel
|
||||
* @param {GuildChannelCreateOptions} [options={}] Options for creating the new channel
|
||||
* @returns {Promise<GuildChannel>}
|
||||
* @example
|
||||
* // Create a new text channel
|
||||
|
||||
@@ -24,13 +24,18 @@ class GuildEmojiManager extends BaseGuildEmojiManager {
|
||||
return super.add(data, cache, { extras: [this.guild] });
|
||||
}
|
||||
|
||||
/**
|
||||
* Options used for creating an emoji in a guild.
|
||||
* @typedef {Object} GuildEmojiCreateOptions
|
||||
* @property {Collection<Snowflake, Role>|RoleResolvable[]} [roles] The roles to limit the emoji to
|
||||
* @property {string} [reason] The reason for creating the emoji
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new custom emoji in the guild.
|
||||
* @param {BufferResolvable|Base64Resolvable} attachment The image for the emoji
|
||||
* @param {string} name The name for the emoji
|
||||
* @param {Object} [options] Options
|
||||
* @param {Collection<Snowflake, Role>|RoleResolvable[]} [options.roles] Roles to limit the emoji to
|
||||
* @param {string} [options.reason] Reason for creating the emoji
|
||||
* @param {GuildEmojiCreateOptions} [options] Options for creating the emoji
|
||||
* @returns {Promise<Emoji>} The created emoji
|
||||
* @example
|
||||
* // Create a new emoji from a url
|
||||
|
||||
@@ -50,7 +50,7 @@ class GuildManager extends BaseManager {
|
||||
/**
|
||||
* Partial data for a Role.
|
||||
* @typedef {Object} PartialRoleData
|
||||
* @property {number} [id] The ID for this role, used to set channel overrides,
|
||||
* @property {Snowflake|number} [id] The ID for this role, used to set channel overrides,
|
||||
* this is a placeholder and will be replaced by the API after consumption
|
||||
* @property {string} [name] The name of the role
|
||||
* @property {ColorResolvable} [color] The color of the role, either a hex string or a base 10 number
|
||||
@@ -63,7 +63,7 @@ class GuildManager extends BaseManager {
|
||||
/**
|
||||
* Partial overwrite data.
|
||||
* @typedef {Object} PartialOverwriteData
|
||||
* @property {number|Snowflake} id The Role or User ID for this overwrite
|
||||
* @property {Snowflake|number} id The Role or User ID for this overwrite
|
||||
* @property {string} [type] The type of this overwrite
|
||||
* @property {PermissionResolvable} [allow] The permissions to allow
|
||||
* @property {PermissionResolvable} [deny] The permissions to deny
|
||||
@@ -72,16 +72,16 @@ class GuildManager extends BaseManager {
|
||||
/**
|
||||
* Partial data for a Channel.
|
||||
* @typedef {Object} PartialChannelData
|
||||
* @property {number} [id] The ID for this channel, used to set its parent,
|
||||
* @property {Snowflake|number} [id] The ID for this channel, used to set its parent,
|
||||
* this is a placeholder and will be replaced by the API after consumption
|
||||
* @property {number} [parentID] The parent ID for this channel
|
||||
* @property {Snowflake|number} [parentID] The parent ID for this channel
|
||||
* @property {string} [type] The type of the channel
|
||||
* @property {string} name The name of the channel
|
||||
* @property {string} [topic] The topic of the text channel
|
||||
* @property {boolean} [nsfw] Whether the channel is NSFW
|
||||
* @property {number} [bitrate] The bitrate of the voice channel
|
||||
* @property {number} [userLimit] The user limit of the channel
|
||||
* @property {PartialOverwriteData} [permissionOverwrites]
|
||||
* @property {PartialOverwriteData[]} [permissionOverwrites]
|
||||
* Overwrites of the channel
|
||||
* @property {number} [rateLimitPerUser] The rate limit per user of the channel in seconds
|
||||
*/
|
||||
@@ -128,23 +128,28 @@ class GuildManager extends BaseManager {
|
||||
return super.resolveID(guild);
|
||||
}
|
||||
|
||||
/**
|
||||
* Options used to create a guild.
|
||||
* @typedef {Object} GuildCreateOptions
|
||||
* @property {Snowflake|number} [afkChannelID] The ID of the AFK channel
|
||||
* @property {number} [afkTimeout] The AFK timeout in seconds
|
||||
* @property {PartialChannelData[]} [channels=[]] The channels for this guild
|
||||
* @property {DefaultMessageNotifications} [defaultMessageNotifications] The default message notifications
|
||||
* for the guild
|
||||
* @property {ExplicitContentFilterLevel} [explicitContentFilter] The explicit content filter level for the guild
|
||||
* @property {BufferResolvable|Base64Resolvable} [icon=null] The icon for the guild
|
||||
* @property {PartialRoleData[]} [roles=[]] The roles for this guild,
|
||||
* the first element of this array is used to change properties of the guild's everyone role.
|
||||
* @property {Snowflake|number} [systemChannelID] The ID of the system channel
|
||||
* @property {SystemChannelFlagsResolvable} [systemChannelFlags] The flags of the system channel
|
||||
* @property {VerificationLevel} [verificationLevel] The verification level for the guild
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a guild.
|
||||
* <warn>This is only available to bots in fewer than 10 guilds.</warn>
|
||||
* @param {string} name The name of the guild
|
||||
* @param {Object} [options] Options for the creating
|
||||
* @param {number} [options.afkChannelID] The ID of the AFK channel
|
||||
* @param {number} [options.afkTimeout] The AFK timeout in seconds
|
||||
* @param {PartialChannelData[]} [options.channels] The channels for this guild
|
||||
* @param {DefaultMessageNotifications} [options.defaultMessageNotifications] The default message notifications
|
||||
* for the guild
|
||||
* @param {ExplicitContentFilterLevel} [options.explicitContentFilter] The explicit content filter level for the guild
|
||||
* @param {BufferResolvable|Base64Resolvable} [options.icon=null] The icon for the guild
|
||||
* @param {PartialRoleData[]} [options.roles] The roles for this guild,
|
||||
* the first element of this array is used to change properties of the guild's everyone role.
|
||||
* @param {number} [options.systemChannelID] The ID of the system channel
|
||||
* @param {SystemChannelFlagsResolvable} [options.systemChannelFlags] The flags of the system channel
|
||||
* @param {VerificationLevel} [options.verificationLevel] The verification level for the guild
|
||||
* @param {GuildCreateOptions} [options] Options for creating the guild
|
||||
* @returns {Promise<Guild>} The guild that was created
|
||||
*/
|
||||
async create(
|
||||
|
||||
@@ -137,16 +137,16 @@ class GuildMemberManager extends BaseManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for searching for guild members.
|
||||
* Options used for searching guild members.
|
||||
* @typedef {Object} GuildSearchMembersOptions
|
||||
* @property {string} query Filter members whose username or nickname start with this query
|
||||
* @property {number} [limit] Maximum number of members to search
|
||||
* @property {boolean} [cache] Whether or not to cache the fetched member(s)
|
||||
* @property {number} [limit=1] Maximum number of members to search
|
||||
* @property {boolean} [cache=true] Whether or not to cache the fetched member(s)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Search for members in the guild based on a query.
|
||||
* @param {GuildSearchMembersOptions} options Search options
|
||||
* Searches for members in the guild based on a query.
|
||||
* @param {GuildSearchMembersOptions} options Options for searching members
|
||||
* @returns {Promise<Collection<Snowflake, GuildMember>>}
|
||||
*/
|
||||
async search({ query, limit = 1, cache = true } = {}) {
|
||||
@@ -196,19 +196,19 @@ class GuildMemberManager extends BaseManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for pruning guild members.
|
||||
* Options used for pruning guild members.
|
||||
* @typedef {Object} GuildPruneMembersOptions
|
||||
* @property {number} [days] Number of days of inactivity required to kick
|
||||
* @property {boolean} [dry] Get number of users that will be kicked, without actually kicking them
|
||||
* @property {boolean} [count] Whether or not to return the number of users that have been kicked.
|
||||
* @property {number} [days=7] Number of days of inactivity required to kick
|
||||
* @property {boolean} [dry=false] Get the number of users that will be kicked, without actually kicking them
|
||||
* @property {boolean} [count=true] Whether or not to return the number of users that have been kicked.
|
||||
* @property {RoleResolvable[]} [roles] Array of roles to bypass the "...and no roles" constraint when pruning
|
||||
* @property {string} [reason] Reason for this prune
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prunes members from the guild based on how long they have been inactive.
|
||||
* <info>It's recommended to set options.count to `false` for large guilds.</info>
|
||||
* @param {GuildPruneMembersOptions} [options] Prune options
|
||||
* <info>It's recommended to set `options.count` to `false` for large guilds.</info>
|
||||
* @param {GuildPruneMembersOptions} [options] Options for pruning
|
||||
* @returns {Promise<number|null>} The number of members that were/will be kicked
|
||||
* @example
|
||||
* // See how many members will be pruned
|
||||
|
||||
@@ -24,11 +24,16 @@ class ReactionUserManager extends BaseManager {
|
||||
* @name ReactionUserManager#cache
|
||||
*/
|
||||
|
||||
/**
|
||||
* Options used to fetch users who gave a reaction.
|
||||
* @typedef {Object} FetchReactionUsersOptions
|
||||
* @property {number} [limit=100] The maximum amount of users to fetch, defaults to `100`
|
||||
* @property {Snowflake} [after] Limit fetching users to those with an id greater than the supplied id
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fetches all the users that gave this reaction. Resolves with a collection of users, mapped by their IDs.
|
||||
* @param {Object} [options] Options for fetching the users
|
||||
* @param {number} [options.limit=100] The maximum amount of users to fetch, defaults to 100
|
||||
* @param {Snowflake} [options.after] Limit fetching users to those with an id greater than the supplied id
|
||||
* @param {FetchReactionUsersOptions} [options] Options for fetching the users
|
||||
* @returns {Promise<Collection<Snowflake, User>>}
|
||||
*/
|
||||
async fetch({ limit = 100, after } = {}) {
|
||||
|
||||
@@ -84,17 +84,22 @@ class RoleManager extends BaseManager {
|
||||
* @returns {?Snowflake}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Options used to create a new role.
|
||||
* @typedef {Object} CreateRoleOptions
|
||||
* @property {string} [name] The name of the new role
|
||||
* @property {ColorResolvable} [color] The data to create the role with
|
||||
* @property {boolean} [hoist] Whether or not the new role should be hoisted
|
||||
* @property {PermissionResolvable} [permissions] The permissions for the new role
|
||||
* @property {number} [position] The position of the new role
|
||||
* @property {boolean} [mentionable] Whether or not the new role should be mentionable
|
||||
* @property {string} [reason] The reason for creating this role
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new role in the guild with given information.
|
||||
* <warn>The position will silently reset to 1 if an invalid one is provided, or none.</warn>
|
||||
* @param {Object} [options] Options
|
||||
* @param {string} [options.name] The name of the new role
|
||||
* @param {ColorResolvable} [options.color] The data to create the role with
|
||||
* @param {boolean} [options.hoist] Whether or not the new role should be hoisted.
|
||||
* @param {PermissionResolvable} [options.permissions] The permissions for the new role
|
||||
* @param {number} [options.position] The position of the new role
|
||||
* @param {boolean} [options.mentionable] Whether or not the new role should be mentionable.
|
||||
* @param {string} [options.reason] Reason for creating this role
|
||||
* @param {CreateRoleOptions} [options] Options for creating the new role
|
||||
* @returns {Promise<Role>}
|
||||
* @example
|
||||
* // Create a new role
|
||||
|
||||
Reference in New Issue
Block a user