mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 20:43:30 +01:00
fix: allow null to be passed in order to reset icon/avatar (#6646)
This commit is contained in:
@@ -146,7 +146,7 @@ class GuildManager extends CachedManager {
|
|||||||
* @property {DefaultMessageNotificationLevel|number} [defaultMessageNotifications] The default message notifications
|
* @property {DefaultMessageNotificationLevel|number} [defaultMessageNotifications] The default message notifications
|
||||||
* for the guild
|
* for the guild
|
||||||
* @property {ExplicitContentFilterLevel} [explicitContentFilter] The explicit content filter level 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 {?(BufferResolvable|Base64Resolvable)} [icon=null] The icon for the guild
|
||||||
* @property {PartialRoleData[]} [roles=[]] The roles for this 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.
|
* the first element of this array is used to change properties of the guild's everyone role.
|
||||||
* @property {Snowflake|number} [systemChannelId] The system channel's id
|
* @property {Snowflake|number} [systemChannelId] The system channel's id
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class BaseGuildTextChannel extends GuildChannel {
|
|||||||
/**
|
/**
|
||||||
* Options used to create a {@link Webhook} for {@link TextChannel} and {@link NewsChannel}.
|
* Options used to create a {@link Webhook} for {@link TextChannel} and {@link NewsChannel}.
|
||||||
* @typedef {Object} ChannelWebhookCreateOptions
|
* @typedef {Object} ChannelWebhookCreateOptions
|
||||||
* @property {BufferResolvable|Base64Resolvable} [avatar] Avatar for the webhook
|
* @property {?(BufferResolvable|Base64Resolvable)} [avatar] Avatar for the webhook
|
||||||
* @property {string} [reason] Reason for creating the webhook
|
* @property {string} [reason] Reason for creating the webhook
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class ClientUser extends User {
|
|||||||
* Data used to edit the logged in client
|
* Data used to edit the logged in client
|
||||||
* @typedef {Object} ClientUserEditData
|
* @typedef {Object} ClientUserEditData
|
||||||
* @property {string} [username] The new username
|
* @property {string} [username] The new username
|
||||||
* @property {BufferResolvable|Base64Resolvable} [avatar] The new avatar
|
* @property {?(BufferResolvable|Base64Resolvable)} [avatar] The new avatar
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,6 +54,7 @@ class ClientUser extends User {
|
|||||||
* @returns {Promise<ClientUser>}
|
* @returns {Promise<ClientUser>}
|
||||||
*/
|
*/
|
||||||
async edit(data) {
|
async edit(data) {
|
||||||
|
if (typeof data.avatar !== 'undefined') data.avatar = await DataResolver.resolveImage(data.avatar);
|
||||||
const newData = await this.client.api.users('@me').patch({ data });
|
const newData = await this.client.api.users('@me').patch({ data });
|
||||||
this.client.token = newData.token;
|
this.client.token = newData.token;
|
||||||
const { updated } = this.client.actions.UserUpdate.handle(newData);
|
const { updated } = this.client.actions.UserUpdate.handle(newData);
|
||||||
@@ -78,7 +79,7 @@ class ClientUser extends User {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the avatar of the logged in client.
|
* Sets the avatar of the logged in client.
|
||||||
* @param {BufferResolvable|Base64Resolvable} avatar The new avatar
|
* @param {?(BufferResolvable|Base64Resolvable)} avatar The new avatar
|
||||||
* @returns {Promise<ClientUser>}
|
* @returns {Promise<ClientUser>}
|
||||||
* @example
|
* @example
|
||||||
* // Set avatar
|
* // Set avatar
|
||||||
@@ -86,8 +87,8 @@ class ClientUser extends User {
|
|||||||
* .then(user => console.log(`New avatar set!`))
|
* .then(user => console.log(`New avatar set!`))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
async setAvatar(avatar) {
|
setAvatar(avatar) {
|
||||||
return this.edit({ avatar: await DataResolver.resolveImage(avatar) });
|
return this.edit({ avatar });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -748,11 +748,11 @@ class Guild extends AnonymousGuild {
|
|||||||
* @property {VoiceChannelResolvable} [afkChannel] The AFK channel of the guild
|
* @property {VoiceChannelResolvable} [afkChannel] The AFK channel of the guild
|
||||||
* @property {TextChannelResolvable} [systemChannel] The system channel of the guild
|
* @property {TextChannelResolvable} [systemChannel] The system channel of the guild
|
||||||
* @property {number} [afkTimeout] The AFK timeout of the guild
|
* @property {number} [afkTimeout] The AFK timeout of the guild
|
||||||
* @property {Base64Resolvable} [icon] The icon of the guild
|
* @property {?(BufferResolvable|Base64Resolvable)} [icon] The icon of the guild
|
||||||
* @property {GuildMemberResolvable} [owner] The owner of the guild
|
* @property {GuildMemberResolvable} [owner] The owner of the guild
|
||||||
* @property {Base64Resolvable} [splash] The invite splash image of the guild
|
* @property {?(BufferResolvable|Base64Resolvable)} [splash] The invite splash image of the guild
|
||||||
* @property {Base64Resolvable} [discoverySplash] The discovery splash image of the guild
|
* @property {?(BufferResolvable|Base64Resolvable)} [discoverySplash] The discovery splash image of the guild
|
||||||
* @property {Base64Resolvable} [banner] The banner of the guild
|
* @property {?(BufferResolvable|Base64Resolvable)} [banner] The banner of the guild
|
||||||
* @property {DefaultMessageNotificationLevel|number} [defaultMessageNotifications] The default message notification
|
* @property {DefaultMessageNotificationLevel|number} [defaultMessageNotifications] The default message notification
|
||||||
* level of the guild
|
* level of the guild
|
||||||
* @property {SystemChannelFlagsResolvable} [systemChannelFlags] The system channel flags of the guild
|
* @property {SystemChannelFlagsResolvable} [systemChannelFlags] The system channel flags of the guild
|
||||||
@@ -806,11 +806,13 @@ class Guild extends AnonymousGuild {
|
|||||||
_data.system_channel_id = this.client.channels.resolveId(data.systemChannel);
|
_data.system_channel_id = this.client.channels.resolveId(data.systemChannel);
|
||||||
}
|
}
|
||||||
if (data.afkTimeout) _data.afk_timeout = Number(data.afkTimeout);
|
if (data.afkTimeout) _data.afk_timeout = Number(data.afkTimeout);
|
||||||
if (typeof data.icon !== 'undefined') _data.icon = data.icon;
|
if (typeof data.icon !== 'undefined') _data.icon = await DataResolver.resolveImage(data.icon);
|
||||||
if (data.owner) _data.owner_id = this.client.users.resolveId(data.owner);
|
if (data.owner) _data.owner_id = this.client.users.resolveId(data.owner);
|
||||||
if (data.splash) _data.splash = data.splash;
|
if (typeof data.splash !== 'undefined') _data.splash = await DataResolver.resolveImage(data.splash);
|
||||||
if (data.discoverySplash) _data.discovery_splash = data.discoverySplash;
|
if (typeof data.discoverySplash !== 'undefined') {
|
||||||
if (data.banner) _data.banner = data.banner;
|
_data.discovery_splash = await DataResolver.resolveImage(data.discoverySplash);
|
||||||
|
}
|
||||||
|
if (typeof data.banner !== 'undefined') _data.banner = await DataResolver.resolveImage(data.banner);
|
||||||
if (typeof data.explicitContentFilter !== 'undefined') {
|
if (typeof data.explicitContentFilter !== 'undefined') {
|
||||||
_data.explicit_content_filter =
|
_data.explicit_content_filter =
|
||||||
typeof data.explicitContentFilter === 'number'
|
typeof data.explicitContentFilter === 'number'
|
||||||
@@ -1022,7 +1024,7 @@ class Guild extends AnonymousGuild {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a new guild icon.
|
* Sets a new guild icon.
|
||||||
* @param {Base64Resolvable|BufferResolvable} icon The new icon of the guild
|
* @param {?(Base64Resolvable|BufferResolvable)} icon The new icon of the guild
|
||||||
* @param {string} [reason] Reason for changing the guild's icon
|
* @param {string} [reason] Reason for changing the guild's icon
|
||||||
* @returns {Promise<Guild>}
|
* @returns {Promise<Guild>}
|
||||||
* @example
|
* @example
|
||||||
@@ -1031,8 +1033,8 @@ class Guild extends AnonymousGuild {
|
|||||||
* .then(updated => console.log('Updated the guild icon'))
|
* .then(updated => console.log('Updated the guild icon'))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
async setIcon(icon, reason) {
|
setIcon(icon, reason) {
|
||||||
return this.edit({ icon: await DataResolver.resolveImage(icon) }, reason);
|
return this.edit({ icon }, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1052,7 +1054,7 @@ class Guild extends AnonymousGuild {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a new guild invite splash image.
|
* Sets a new guild invite splash image.
|
||||||
* @param {Base64Resolvable|BufferResolvable} splash The new invite splash image of the guild
|
* @param {?(Base64Resolvable|BufferResolvable)} splash The new invite splash image of the guild
|
||||||
* @param {string} [reason] Reason for changing the guild's invite splash image
|
* @param {string} [reason] Reason for changing the guild's invite splash image
|
||||||
* @returns {Promise<Guild>}
|
* @returns {Promise<Guild>}
|
||||||
* @example
|
* @example
|
||||||
@@ -1061,13 +1063,13 @@ class Guild extends AnonymousGuild {
|
|||||||
* .then(updated => console.log('Updated the guild splash'))
|
* .then(updated => console.log('Updated the guild splash'))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
async setSplash(splash, reason) {
|
setSplash(splash, reason) {
|
||||||
return this.edit({ splash: await DataResolver.resolveImage(splash) }, reason);
|
return this.edit({ splash }, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a new guild discovery splash image.
|
* Sets a new guild discovery splash image.
|
||||||
* @param {Base64Resolvable|BufferResolvable} discoverySplash The new discovery splash image of the guild
|
* @param {?(Base64Resolvable|BufferResolvable)} discoverySplash The new discovery splash image of the guild
|
||||||
* @param {string} [reason] Reason for changing the guild's discovery splash image
|
* @param {string} [reason] Reason for changing the guild's discovery splash image
|
||||||
* @returns {Promise<Guild>}
|
* @returns {Promise<Guild>}
|
||||||
* @example
|
* @example
|
||||||
@@ -1076,13 +1078,13 @@ class Guild extends AnonymousGuild {
|
|||||||
* .then(updated => console.log('Updated the guild discovery splash'))
|
* .then(updated => console.log('Updated the guild discovery splash'))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
async setDiscoverySplash(discoverySplash, reason) {
|
setDiscoverySplash(discoverySplash, reason) {
|
||||||
return this.edit({ discoverySplash: await DataResolver.resolveImage(discoverySplash) }, reason);
|
return this.edit({ discoverySplash }, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a new guild banner.
|
* Sets a new guild banner.
|
||||||
* @param {Base64Resolvable|BufferResolvable} banner The new banner of the guild
|
* @param {?(Base64Resolvable|BufferResolvable)} banner The new banner of the guild
|
||||||
* @param {string} [reason] Reason for changing the guild's banner
|
* @param {string} [reason] Reason for changing the guild's banner
|
||||||
* @returns {Promise<Guild>}
|
* @returns {Promise<Guild>}
|
||||||
* @example
|
* @example
|
||||||
@@ -1090,8 +1092,8 @@ class Guild extends AnonymousGuild {
|
|||||||
* .then(updated => console.log('Updated the guild banner'))
|
* .then(updated => console.log('Updated the guild banner'))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
async setBanner(banner, reason) {
|
setBanner(banner, reason) {
|
||||||
return this.edit({ banner: await DataResolver.resolveImage(banner) }, reason);
|
return this.edit({ banner }, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ class Webhook {
|
|||||||
* Options used to edit a {@link Webhook}.
|
* Options used to edit a {@link Webhook}.
|
||||||
* @typedef {Object} WebhookEditData
|
* @typedef {Object} WebhookEditData
|
||||||
* @property {string} [name=this.name] The new name for the webhook
|
* @property {string} [name=this.name] The new name for the webhook
|
||||||
* @property {BufferResolvable} [avatar] The new avatar for the webhook
|
* @property {?(BufferResolvable)} [avatar] The new avatar for the webhook
|
||||||
* @property {GuildTextChannelResolvable} [channel] The new channel for the webhook
|
* @property {GuildTextChannelResolvable} [channel] The new channel for the webhook
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
27
typings/index.d.ts
vendored
27
typings/index.d.ts
vendored
@@ -500,7 +500,7 @@ export class ClientUser extends User {
|
|||||||
public setActivity(options?: ActivityOptions): ClientPresence;
|
public setActivity(options?: ActivityOptions): ClientPresence;
|
||||||
public setActivity(name: string, 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 setAvatar(avatar: BufferResolvable | Base64Resolvable | null): Promise<this>;
|
||||||
public setPresence(data: PresenceData): ClientPresence;
|
public setPresence(data: PresenceData): ClientPresence;
|
||||||
public setStatus(status: PresenceStatusData, shardId?: number | number[]): ClientPresence;
|
public setStatus(status: PresenceStatusData, shardId?: number | number[]): ClientPresence;
|
||||||
public setUsername(username: string): Promise<this>;
|
public setUsername(username: string): Promise<this>;
|
||||||
@@ -737,25 +737,28 @@ export class Guild extends AnonymousGuild {
|
|||||||
public leave(): Promise<Guild>;
|
public leave(): Promise<Guild>;
|
||||||
public setAFKChannel(afkChannel: VoiceChannelResolvable | null, reason?: string): Promise<Guild>;
|
public setAFKChannel(afkChannel: VoiceChannelResolvable | null, reason?: string): Promise<Guild>;
|
||||||
public setAFKTimeout(afkTimeout: number, reason?: string): Promise<Guild>;
|
public setAFKTimeout(afkTimeout: number, reason?: string): Promise<Guild>;
|
||||||
public setBanner(banner: Base64Resolvable | null, reason?: string): Promise<Guild>;
|
public setBanner(banner: BufferResolvable | Base64Resolvable | null, reason?: string): Promise<Guild>;
|
||||||
public setChannelPositions(channelPositions: readonly ChannelPosition[]): Promise<Guild>;
|
public setChannelPositions(channelPositions: readonly ChannelPosition[]): Promise<Guild>;
|
||||||
public setDefaultMessageNotifications(
|
public setDefaultMessageNotifications(
|
||||||
defaultMessageNotifications: DefaultMessageNotificationLevel | number,
|
defaultMessageNotifications: DefaultMessageNotificationLevel | number,
|
||||||
reason?: string,
|
reason?: string,
|
||||||
): Promise<Guild>;
|
): Promise<Guild>;
|
||||||
public setDiscoverySplash(discoverySplash: Base64Resolvable | null, reason?: string): Promise<Guild>;
|
public setDiscoverySplash(
|
||||||
|
discoverySplash: BufferResolvable | Base64Resolvable | null,
|
||||||
|
reason?: string,
|
||||||
|
): Promise<Guild>;
|
||||||
public setExplicitContentFilter(
|
public setExplicitContentFilter(
|
||||||
explicitContentFilter: ExplicitContentFilterLevel | number,
|
explicitContentFilter: ExplicitContentFilterLevel | number,
|
||||||
reason?: string,
|
reason?: string,
|
||||||
): Promise<Guild>;
|
): Promise<Guild>;
|
||||||
public setIcon(icon: Base64Resolvable | null, reason?: string): Promise<Guild>;
|
public setIcon(icon: BufferResolvable | Base64Resolvable | null, reason?: string): Promise<Guild>;
|
||||||
public setName(name: string, reason?: string): Promise<Guild>;
|
public setName(name: string, reason?: string): Promise<Guild>;
|
||||||
public setOwner(owner: GuildMemberResolvable, reason?: string): Promise<Guild>;
|
public setOwner(owner: GuildMemberResolvable, reason?: string): Promise<Guild>;
|
||||||
public setPreferredLocale(preferredLocale: string, reason?: string): Promise<Guild>;
|
public setPreferredLocale(preferredLocale: string, reason?: string): Promise<Guild>;
|
||||||
public setPublicUpdatesChannel(publicUpdatesChannel: TextChannelResolvable | null, reason?: string): Promise<Guild>;
|
public setPublicUpdatesChannel(publicUpdatesChannel: TextChannelResolvable | null, reason?: string): Promise<Guild>;
|
||||||
public setRolePositions(rolePositions: readonly RolePosition[]): Promise<Guild>;
|
public setRolePositions(rolePositions: readonly RolePosition[]): Promise<Guild>;
|
||||||
public setRulesChannel(rulesChannel: TextChannelResolvable | null, reason?: string): Promise<Guild>;
|
public setRulesChannel(rulesChannel: TextChannelResolvable | null, reason?: string): Promise<Guild>;
|
||||||
public setSplash(splash: Base64Resolvable | null, reason?: string): Promise<Guild>;
|
public setSplash(splash: BufferResolvable | Base64Resolvable | null, reason?: string): Promise<Guild>;
|
||||||
public setSystemChannel(systemChannel: TextChannelResolvable | null, reason?: string): Promise<Guild>;
|
public setSystemChannel(systemChannel: TextChannelResolvable | null, reason?: string): Promise<Guild>;
|
||||||
public setSystemChannelFlags(systemChannelFlags: SystemChannelFlagsResolvable, reason?: string): Promise<Guild>;
|
public setSystemChannelFlags(systemChannelFlags: SystemChannelFlagsResolvable, reason?: string): Promise<Guild>;
|
||||||
public setVerificationLevel(verificationLevel: VerificationLevel | number, reason?: string): Promise<Guild>;
|
public setVerificationLevel(verificationLevel: VerificationLevel | number, reason?: string): Promise<Guild>;
|
||||||
@@ -3246,7 +3249,7 @@ export type GuildTextChannelResolvable = TextChannel | NewsChannel | Snowflake;
|
|||||||
export type ChannelResolvable = Channel | Snowflake;
|
export type ChannelResolvable = Channel | Snowflake;
|
||||||
|
|
||||||
export interface ChannelWebhookCreateOptions {
|
export interface ChannelWebhookCreateOptions {
|
||||||
avatar?: BufferResolvable | Base64Resolvable;
|
avatar?: BufferResolvable | Base64Resolvable | null;
|
||||||
reason?: string;
|
reason?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3368,7 +3371,7 @@ export interface ClientPresenceStatusData {
|
|||||||
|
|
||||||
export interface ClientUserEditData {
|
export interface ClientUserEditData {
|
||||||
username?: string;
|
username?: string;
|
||||||
avatar?: BufferResolvable | Base64Resolvable;
|
avatar?: BufferResolvable | Base64Resolvable | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CloseEvent {
|
export interface CloseEvent {
|
||||||
@@ -3893,11 +3896,11 @@ export interface GuildEditData {
|
|||||||
systemChannel?: TextChannelResolvable;
|
systemChannel?: TextChannelResolvable;
|
||||||
systemChannelFlags?: SystemChannelFlagsResolvable;
|
systemChannelFlags?: SystemChannelFlagsResolvable;
|
||||||
afkTimeout?: number;
|
afkTimeout?: number;
|
||||||
icon?: Base64Resolvable;
|
icon?: BufferResolvable | Base64Resolvable | null;
|
||||||
owner?: GuildMemberResolvable;
|
owner?: GuildMemberResolvable;
|
||||||
splash?: Base64Resolvable;
|
splash?: BufferResolvable | Base64Resolvable | null;
|
||||||
discoverySplash?: Base64Resolvable;
|
discoverySplash?: BufferResolvable | Base64Resolvable | null;
|
||||||
banner?: Base64Resolvable;
|
banner?: BufferResolvable | Base64Resolvable | null;
|
||||||
rulesChannel?: TextChannelResolvable;
|
rulesChannel?: TextChannelResolvable;
|
||||||
publicUpdatesChannel?: TextChannelResolvable;
|
publicUpdatesChannel?: TextChannelResolvable;
|
||||||
preferredLocale?: string;
|
preferredLocale?: string;
|
||||||
@@ -4759,7 +4762,7 @@ export type WebhookClientOptions = Pick<
|
|||||||
|
|
||||||
export interface WebhookEditData {
|
export interface WebhookEditData {
|
||||||
name?: string;
|
name?: string;
|
||||||
avatar?: BufferResolvable;
|
avatar?: BufferResolvable | null;
|
||||||
channel?: GuildTextChannelResolvable;
|
channel?: GuildTextChannelResolvable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user