Skip to content

Commit

Permalink
refactor!: remove redundant API defaults (#7449)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImRodry committed Feb 13, 2022
1 parent 94bf727 commit 532846b
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/discord.js/src/managers/GuildBanManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class GuildBanManager extends CachedManager {
/**
* Options used to ban a user from a guild.
* @typedef {Object} BanOptions
* @property {number} [days=0] Number of days of messages to delete, must be between 0 and 7, inclusive
* @property {number} [days] Number of days of messages to delete, must be between 0 and 7, inclusive
* @property {string} [reason] The reason for the ban
*/

Expand All @@ -137,7 +137,7 @@ class GuildBanManager extends CachedManager {
* .then(banInfo => console.log(`Banned ${banInfo.user?.tag ?? banInfo.tag ?? banInfo}`))
* .catch(console.error);
*/
async create(user, options = { days: 0 }) {
async create(user, options = {}) {
if (typeof options !== 'object') throw new TypeError('INVALID_TYPE', 'options', 'object', true);
const id = this.client.users.resolveId(user);
if (!id) throw new Error('BAN_RESOLVE_ID', true);
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/managers/GuildInviteManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class GuildInviteManager extends CachedManager {
*/
async create(
channel,
{ temporary = false, maxAge = 86400, maxUses = 0, unique, targetUser, targetApplication, targetType, reason } = {},
{ temporary, maxAge, maxUses, unique, targetUser, targetApplication, targetType, reason } = {},
) {
const id = this.guild.channels.resolveId(channel);
if (!id) throw new Error('GUILD_CHANNEL_RESOLVE');
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/managers/GuildManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class GuildManager extends CachedManager {
* @typedef {Object} FetchGuildsOptions
* @property {Snowflake} [before] Get guilds before this guild id
* @property {Snowflake} [after] Get guilds after this guild id
* @property {number} [limit=200] Maximum number of guilds to request (1-200)
* @property {number} [limit] Maximum number of guilds to request (1-200)
*/

/**
Expand Down
14 changes: 7 additions & 7 deletions packages/discord.js/src/managers/GuildMemberManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class GuildMemberManager extends CachedManager {
* 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=1] Maximum number of members to search
* @property {number} [limit] Maximum number of members to search
* @property {boolean} [cache=true] Whether or not to cache the fetched member(s)
*/

Expand All @@ -203,7 +203,7 @@ class GuildMemberManager extends CachedManager {
* @param {GuildSearchMembersOptions} options Options for searching members
* @returns {Promise<Collection<Snowflake, GuildMember>>}
*/
async search({ query, limit = 1, cache = true } = {}) {
async search({ query, limit, cache = true } = {}) {
const data = await this.client.rest.get(Routes.guildMembersSearch(this.guild.id), {
query: new URLSearchParams({ query, limit }),
});
Expand All @@ -214,7 +214,7 @@ class GuildMemberManager extends CachedManager {
* Options used for listing guild members.
* @typedef {Object} GuildListMembersOptions
* @property {Snowflake} [after] Limit fetching members to those with an id greater than the supplied id
* @property {number} [limit=1] Maximum number of members to list
* @property {number} [limit] Maximum number of members to list
* @property {boolean} [cache=true] Whether or not to cache the fetched member(s)
*/

Expand All @@ -223,7 +223,7 @@ class GuildMemberManager extends CachedManager {
* @param {GuildListMembersOptions} [options] Options for listing members
* @returns {Promise<Collection<Snowflake, GuildMember>>}
*/
async list({ after, limit = 1, cache = true } = {}) {
async list({ after, limit, cache = true } = {}) {
const query = new URLSearchParams({ limit });
if (after) {
query.set('after', after);
Expand Down Expand Up @@ -298,9 +298,9 @@ class GuildMemberManager extends CachedManager {
* <info>It's recommended to set {@link GuildPruneMembersOptions#count options.count}
* to `false` for large guilds.</info>
* @typedef {Object} GuildPruneMembersOptions
* @property {number} [days=7] Number of days of inactivity required to kick
* @property {number} [days] 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 {boolean} [count] 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
*/
Expand All @@ -325,7 +325,7 @@ class GuildMemberManager extends CachedManager {
* .then(pruned => console.log(`I just pruned ${pruned} people!`))
* .catch(console.error);
*/
async prune({ days = 7, dry = false, count: compute_prune_count = true, roles = [], reason } = {}) {
async prune({ days, dry = false, count: compute_prune_count, roles = [], reason } = {}) {
if (typeof days !== 'number') throw new TypeError('PRUNE_DAYS_TYPE');

const query = { days };
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/managers/MessageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MessageManager extends CachedManager {
* The parameters to pass in when requesting previous messages from a channel. `around`, `before` and
* `after` are mutually exclusive. All the parameters are optional.
* @typedef {Object} ChannelLogsQueryOptions
* @property {number} [limit=50] Number of messages to acquire
* @property {number} [limit] Number of messages to acquire
* @property {Snowflake} [before] The message's id to get the messages that were posted before it
* @property {Snowflake} [after] The message's id to get the messages that were posted after it
* @property {Snowflake} [around] The message's id to get the messages that were posted around it
Expand Down
8 changes: 4 additions & 4 deletions packages/discord.js/src/structures/BaseGuildTextChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ class BaseGuildTextChannel extends GuildChannel {
/**
* Options used to create an invite to a guild channel.
* @typedef {Object} CreateInviteOptions
* @property {boolean} [temporary=false] Whether members that joined via the invite should be automatically
* @property {boolean} [temporary] Whether members that joined via the invite should be automatically
* kicked after 24 hours if they have not yet received a role
* @property {number} [maxAge=86400] How long the invite should last (in seconds, 0 for forever)
* @property {number} [maxUses=0] Maximum number of uses
* @property {boolean} [unique=false] Create a unique invite, or use an existing one with similar settings
* @property {number} [maxAge] How long the invite should last (in seconds, 0 for forever)
* @property {number} [maxUses] Maximum number of uses
* @property {boolean} [unique] Create a unique invite, or use an existing one with similar settings
* @property {UserResolvable} [targetUser] The user whose stream to display for this invite,
* required if `targetType` is {@link InviteTargetType.Stream}, the user must be streaming in the channel
* @property {ApplicationResolvable} [targetApplication] The embedded application to open for this invite,
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,8 @@ class Message extends Base {
/**
* Options provided when sending a message as an inline reply.
* @typedef {BaseMessageOptions} ReplyMessageOptions
* @property {boolean} [failIfNotExists=true] Whether to error if the referenced message
* does not exist (creates a standard message in this case when false)
* @property {boolean} [failIfNotExists=this.client.options.failIfNotExists] Whether to error if the referenced
* message does not exist (creates a standard message in this case when false)
* @property {StickerResolvable[]} [stickers=[]] Stickers to send in the message
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ class TextBasedChannel {
* Options for sending a message with a reply.
* @typedef {Object} ReplyOptions
* @property {MessageResolvable} messageReference The message to reply to (must be in the same channel and not system)
* @property {boolean} [failIfNotExists=true] Whether to error if the referenced message
* does not exist (creates a standard message in this case when false)
* @property {boolean} [failIfNotExists=this.client.options.failIfNotExists] Whether to error if the referenced
* message does not exist (creates a standard message in this case when false)
*/

/**
Expand Down

0 comments on commit 532846b

Please sign in to comment.