Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: default values for setX boolean methods #6619

Merged
merged 1 commit into from Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/structures/BaseGuildTextChannel.js
Expand Up @@ -99,11 +99,11 @@ class BaseGuildTextChannel extends GuildChannel {

/**
* Sets whether this channel is flagged as NSFW.
* @param {boolean} nsfw Whether the channel should be considered NSFW
* @param {boolean} [nsfw=true] Whether the channel should be considered NSFW
* @param {string} [reason] Reason for changing the channel's NSFW flag
* @returns {Promise<TextChannel>}
*/
setNSFW(nsfw, reason) {
setNSFW(nsfw = true, reason) {
return this.edit({ nsfw }, reason);
}

Expand Down
4 changes: 2 additions & 2 deletions src/structures/ClientUser.js
Expand Up @@ -168,11 +168,11 @@ class ClientUser extends User {

/**
* Sets/removes the AFK flag for the client user.
* @param {boolean} afk Whether or not the user is AFK
* @param {boolean} [afk=true] Whether or not the user is AFK
* @param {number|number[]} [shardId] Shard Id(s) to have the AFK flag set on
* @returns {ClientPresence}
*/
setAFK(afk, shardId) {
setAFK(afk = true, shardId) {
return this.setPresence({ afk, shardId });
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/structures/Role.js
Expand Up @@ -244,7 +244,7 @@ class Role extends Base {

/**
* Sets whether or not the role should be hoisted.
* @param {boolean} hoist Whether or not to hoist the role
* @param {boolean} [hoist=true] Whether or not to hoist the role
* @param {string} [reason] Reason for setting whether or not the role should be hoisted
* @returns {Promise<Role>}
* @example
Expand All @@ -253,7 +253,7 @@ class Role extends Base {
* .then(updated => console.log(`Role hoisted: ${updated.hoist}`))
* .catch(console.error);
*/
setHoist(hoist, reason) {
setHoist(hoist = true, reason) {
return this.edit({ hoist }, reason);
}

Expand All @@ -279,7 +279,7 @@ class Role extends Base {

/**
* Sets whether this role is mentionable.
* @param {boolean} mentionable Whether this role should be mentionable
* @param {boolean} [mentionable=true] Whether this role should be mentionable
* @param {string} [reason] Reason for setting whether or not this role should be mentionable
* @returns {Promise<Role>}
* @example
Expand All @@ -288,7 +288,7 @@ class Role extends Base {
* .then(updated => console.log(`Role updated ${updated.name}`))
* .catch(console.error);
*/
setMentionable(mentionable, reason) {
setMentionable(mentionable = true, reason) {
return this.edit({ mentionable }, reason);
}

Expand Down
16 changes: 8 additions & 8 deletions src/structures/VoiceState.js
Expand Up @@ -120,21 +120,21 @@ class VoiceState extends Base {

/**
* Mutes/unmutes the member of this voice state.
* @param {boolean} mute Whether or not the member should be muted
* @param {boolean} [mute=true] Whether or not the member should be muted
* @param {string} [reason] Reason for muting or unmuting
* @returns {Promise<GuildMember>}
*/
setMute(mute, reason) {
setMute(mute = true, reason) {
return this.member?.edit({ mute }, reason) ?? Promise.reject(new Error('VOICE_STATE_UNCACHED_MEMBER'));
}

/**
* Deafens/undeafens the member of this voice state.
* @param {boolean} deaf Whether or not the member should be deafened
* @param {boolean} [deaf=true] Whether or not the member should be deafened
* @param {string} [reason] Reason for deafening or undeafening
* @returns {Promise<GuildMember>}
*/
setDeaf(deaf, reason) {
setDeaf(deaf = true, reason) {
return this.member?.edit({ deaf }, reason) ?? Promise.reject(new Error('VOICE_STATE_UNCACHED_MEMBER'));
}

Expand All @@ -161,7 +161,7 @@ class VoiceState extends Base {
/**
* Toggles the request to speak in the channel.
* Only applicable for stage channels and for the client's own voice state.
* @param {boolean} request Whether or not the client is requesting to become a speaker.
* @param {boolean} [request=true] Whether or not the client is requesting to become a speaker.
* @example
* // Making the client request to speak in a stage channel (raise its hand)
* guild.me.voice.setRequestToSpeak(true);
Expand All @@ -170,7 +170,7 @@ class VoiceState extends Base {
* guild.me.voice.setRequestToSpeak(false);
* @returns {Promise<void>}
*/
async setRequestToSpeak(request) {
async setRequestToSpeak(request = true) {
if (this.channel?.type !== 'GUILD_STAGE_VOICE') throw new Error('VOICE_NOT_STAGE_CHANNEL');

if (this.client.user.id !== this.id) throw new Error('VOICE_STATE_NOT_OWN');
Expand All @@ -185,7 +185,7 @@ class VoiceState extends Base {

/**
* Suppress/unsuppress the user. Only applicable for stage channels.
* @param {boolean} suppressed - Whether or not the user should be suppressed.
* @param {boolean} [suppressed=true] Whether or not the user should be suppressed.
* @example
* // Making the client a speaker
* guild.me.voice.setSuppressed(false);
Expand All @@ -200,7 +200,7 @@ class VoiceState extends Base {
* voiceState.setSuppressed(true);
* @returns {Promise<void>}
*/
async setSuppressed(suppressed) {
async setSuppressed(suppressed = true) {
if (typeof suppressed !== 'boolean') throw new TypeError('VOICE_STATE_INVALID_TYPE', 'suppressed');

if (this.channel?.type !== 'GUILD_STAGE_VOICE') throw new Error('VOICE_NOT_STAGE_CHANNEL');
Expand Down
16 changes: 8 additions & 8 deletions typings/index.d.ts
Expand Up @@ -330,7 +330,7 @@ export class BaseGuildTextChannel extends TextBasedChannel(GuildChannel) {
defaultAutoArchiveDuration: ThreadAutoArchiveDuration,
reason?: string,
): Promise<this>;
public setNSFW(nsfw: boolean, reason?: string): Promise<this>;
public setNSFW(nsfw?: boolean, reason?: string): Promise<this>;
public setTopic(topic: string | null, reason?: string): Promise<this>;
public setType(type: Pick<typeof ChannelTypes, 'GUILD_TEXT'>, reason?: string): Promise<TextChannel>;
public setType(type: Pick<typeof ChannelTypes, 'GUILD_NEWS'>, reason?: string): Promise<NewsChannel>;
Expand Down Expand Up @@ -498,7 +498,7 @@ export class ClientUser extends User {
public edit(data: ClientUserEditData): Promise<this>;
public setActivity(options?: ActivityOptions): ClientPresence;
public setActivity(name: string, options?: ActivityOptions): ClientPresence;
public setAFK(afk: boolean, shardId?: number | number[]): ClientPresence;
public setAFK(afk?: boolean, shardId?: number | number[]): ClientPresence;
public setAvatar(avatar: BufferResolvable | Base64Resolvable): Promise<this>;
public setPresence(data: PresenceData): ClientPresence;
public setStatus(status: PresenceStatusData, shardId?: number | number[]): ClientPresence;
Expand Down Expand Up @@ -1613,8 +1613,8 @@ export class Role extends Base {
public equals(role: Role): boolean;
public permissionsIn(channel: GuildChannel | Snowflake): Readonly<Permissions>;
public setColor(color: ColorResolvable, reason?: string): Promise<Role>;
public setHoist(hoist: boolean, reason?: string): Promise<Role>;
public setMentionable(mentionable: boolean, reason?: string): Promise<Role>;
public setHoist(hoist?: boolean, reason?: string): Promise<Role>;
public setMentionable(mentionable?: boolean, reason?: string): Promise<Role>;
public setName(name: string, reason?: string): Promise<Role>;
public setPermissions(permissions: PermissionResolvable, reason?: string): Promise<Role>;
public setPosition(position: number, options?: SetRolePositionOptions): Promise<Role>;
Expand Down Expand Up @@ -2072,12 +2072,12 @@ export class VoiceState extends Base {
public suppress: boolean;
public requestToSpeakTimestamp: number | null;

public setDeaf(deaf: boolean, reason?: string): Promise<GuildMember>;
public setMute(mute: boolean, reason?: string): Promise<GuildMember>;
public setDeaf(deaf?: boolean, reason?: string): Promise<GuildMember>;
public setMute(mute?: boolean, reason?: string): Promise<GuildMember>;
public disconnect(reason?: string): Promise<GuildMember>;
public setChannel(channel: VoiceChannelResolvable | null, reason?: string): Promise<GuildMember>;
public setRequestToSpeak(request: boolean): Promise<void>;
public setSuppressed(suppressed: boolean): Promise<void>;
public setRequestToSpeak(request?: boolean): Promise<void>;
public setSuppressed(suppressed?: boolean): Promise<void>;
}

export class Webhook extends WebhookMixin() {
Expand Down