From b689ea73277b14242d881afb5c88cd76e5252b17 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Mon, 13 Sep 2021 09:10:37 +0530 Subject: [PATCH 01/17] feat: add support for role icon --- src/managers/RoleManager.js | 7 ++++++- src/structures/Guild.js | 1 + src/structures/Role.js | 7 +++++++ typings/index.d.ts | 3 ++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/managers/RoleManager.js b/src/managers/RoleManager.js index b0c5b971c188..51570daa3fa8 100644 --- a/src/managers/RoleManager.js +++ b/src/managers/RoleManager.js @@ -4,6 +4,7 @@ const { Collection } = require('@discordjs/collection'); const CachedManager = require('./CachedManager'); const { TypeError } = require('../errors'); const Role = require('../structures/Role'); +const DataResolver = require('../util/DataResolver'); const Permissions = require('../util/Permissions'); const { resolveColor, setPosition } = require('../util/Util'); @@ -105,6 +106,7 @@ class RoleManager extends CachedManager { * @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 + * @property {BufferResolvable|Base64Resolvable} [icon] The icon for the role */ /** @@ -128,9 +130,10 @@ class RoleManager extends CachedManager { * .catch(console.error); */ async create(options = {}) { - let { name, color, hoist, permissions, position, mentionable, reason } = options; + let { name, color, hoist, permissions, position, mentionable, reason, icon } = options; color &&= resolveColor(color); if (typeof permissions !== 'undefined') permissions = new Permissions(permissions); + if (icon) icon = await DataResolver.resolveImage(icon); const data = await this.client.api.guilds(this.guild.id).roles.post({ data: { @@ -139,6 +142,7 @@ class RoleManager extends CachedManager { hoist, permissions, mentionable, + icon, }, reason, }); @@ -188,6 +192,7 @@ class RoleManager extends CachedManager { hoist: data.hoist, permissions: typeof data.permissions === 'undefined' ? undefined : new Permissions(data.permissions), mentionable: data.mentionable, + icon: typeof data.icon === 'undefined' ? undefined : await DataResolver.resolveImage(data.icon), }; const d = await this.client.api.guilds(this.guild.id).roles(role.id).patch({ data: _data, reason }); diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 3e565c91c70a..5f4abb7fef51 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -186,6 +186,7 @@ class Guild extends AnonymousGuild { * * THREE_DAY_THREAD_ARCHIVE * * SEVEN_DAY_THREAD_ARCHIVE * * PRIVATE_THREADS + * * ROLE_ICONS * @typedef {string} Features * @see {@link https://discord.com/developers/docs/resources/guild#guild-object-guild-features} */ diff --git a/src/structures/Role.js b/src/structures/Role.js index feea3a2a0ee7..3670273182a0 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -91,6 +91,12 @@ class Role extends Base { */ this.deleted = false; + /** + * The icon of the role + * @type {?string} + */ + this.icon = data.icon; + /** * The tags this role has * @type {?Object} @@ -191,6 +197,7 @@ class Role extends Base { * @property {number} [position] The position of the role * @property {PermissionResolvable} [permissions] The permissions of the role * @property {boolean} [mentionable] Whether or not the role should be mentionable + * @property {BufferResolvable|Base64Resolvable} [icon] The icon for the role */ /** diff --git a/typings/index.d.ts b/typings/index.d.ts index 2fc8b099d193..2e06e2d81884 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -4069,7 +4069,8 @@ export type GuildFeatures = | 'MORE_STICKERS' | 'THREE_DAY_THREAD_ARCHIVE' | 'SEVEN_DAY_THREAD_ARCHIVE' - | 'PRIVATE_THREADS'; + | 'PRIVATE_THREADS' + | 'ROLE_ICONS'; export interface GuildMemberEditData { nick?: string | null; From e5c9a6ddf0dbed9c3e035420dcf4cbb239436cf6 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Mon, 13 Sep 2021 09:19:23 +0530 Subject: [PATCH 02/17] feat(Role): add setIcon method and update #equals --- src/structures/Role.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/structures/Role.js b/src/structures/Role.js index 3670273182a0..8baac644a1a2 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -307,6 +307,15 @@ class Role extends Base { return this.edit({ mentionable }, reason); } + /** + * Sets a new icon for the role. + * @param {BufferResolvable|Base64Resolvable} icon The icon for the role + * @returns {Promise} + */ + setIcon(icon) { + return this.edit({ icon }); + } + /** * Options used to set position of a role. * @typedef {Object} SetRolePositionOptions @@ -373,7 +382,8 @@ class Role extends Base { this.hoist === role.hoist && this.position === role.position && this.permissions.bitfield === role.permissions.bitfield && - this.managed === role.managed + this.managed === role.managed && + this.icon === role.icon ); } From 3dc4055fe26d537d7fcc411dab1d6e26d77d47c7 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Mon, 13 Sep 2021 09:23:09 +0530 Subject: [PATCH 03/17] feat(Role): add option to set reason in #setIcon --- src/structures/Role.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/structures/Role.js b/src/structures/Role.js index 8baac644a1a2..678b6776ad8b 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -310,10 +310,11 @@ class Role extends Base { /** * Sets a new icon for the role. * @param {BufferResolvable|Base64Resolvable} icon The icon for the role + * @param {string} [reason] Reason for changing the role's icon * @returns {Promise} */ - setIcon(icon) { - return this.edit({ icon }); + setIcon(icon, reason) { + return this.edit({ icon }, reason); } /** From 1a57500d133b61fe4d7c8dcd098f33d95967a43a Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Mon, 13 Sep 2021 09:31:40 +0530 Subject: [PATCH 04/17] types: update typings to support role icons --- typings/index.d.ts | 78 +++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 2e06e2d81884..a41bc9b01815 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -996,7 +996,7 @@ export class HTTPError extends Error { } // tslint:disable-next-line:no-empty-interface - Merge RateLimitData into RateLimitError to not have to type it again -export interface RateLimitError extends RateLimitData {} +export interface RateLimitError extends RateLimitData { } export class RateLimitError extends Error { private constructor(data: RateLimitData); public name: 'RateLimitError'; @@ -1164,8 +1164,8 @@ type TaggedUnion = T extends Record ? T : T extends Record ? V extends U - ? T - : never + ? T + : never : never; // This creates a map of MessageComponentTypes to their respective `InteractionCollectorOptionsResolvable` variant. @@ -1177,8 +1177,8 @@ type CollectorOptionsTypeResolver` variant back. type ConditionalInteractionCollectorType = T extends InteractionCollectorOptions - ? InteractionCollector - : InteractionCollector; + ? InteractionCollector + : InteractionCollector; // This maps each componentType key to each variant. type MappedInteractionCollectorOptions = CollectorOptionsTypeResolver; @@ -1194,20 +1194,20 @@ type InteractionExtractor - ? Item - : never + ? Item + : never : MessageComponentInteraction; type MessageCollectorOptionsParams = | { - componentType?: T; - } & MessageComponentCollectorOptions>; + componentType?: T; + } & MessageComponentCollectorOptions>; type AwaitMessageCollectorOptionsParams = | { componentType?: T } & Pick< - InteractionCollectorOptions>, - keyof AwaitMessageComponentOptions - >; + InteractionCollectorOptions>, + keyof AwaitMessageComponentOptions + >; export class Message extends Base { private constructor(client: Client, data: RawMessageData); @@ -1255,12 +1255,12 @@ export class Message extends Base { public reference: MessageReference | null; public awaitMessageComponent< T extends MessageComponentType | MessageComponentTypes | undefined = MessageComponentTypes.ACTION_ROW, - >(options?: AwaitMessageCollectorOptionsParams): Promise>; + >(options?: AwaitMessageCollectorOptionsParams): Promise>; public awaitReactions(options?: AwaitReactionsOptions): Promise>; public createReactionCollector(options?: ReactionCollectorOptions): ReactionCollector; public createMessageComponentCollector< T extends MessageComponentType | MessageComponentTypes | undefined = undefined, - >(options?: MessageCollectorOptionsParams): InteractionCollectorReturnType; + >(options?: MessageCollectorOptionsParams): InteractionCollectorReturnType; public delete(): Promise; public edit(content: string | MessageEditOptions | MessagePayload): Promise; public equals(message: Message, rawData: unknown): boolean; @@ -1647,6 +1647,7 @@ export class Role extends Base { public rawPosition: number; public tags: RoleTagData | null; public comparePositionTo(role: RoleResolvable): number; + public icon: string | null; public delete(reason?: string): Promise; public edit(data: RoleData, reason?: string): Promise; public equals(role: Role): boolean; @@ -1656,6 +1657,7 @@ export class Role extends Base { public setMentionable(mentionable?: boolean, reason?: string): Promise; public setName(name: string, reason?: string): Promise; public setPermissions(permissions: PermissionResolvable, reason?: string): Promise; + public setIcon(icon: BufferResolvable | Base64Resolvable, reason?: string): Promise; public setPosition(position: number, options?: SetRolePositionOptions): Promise; public toJSON(): unknown; public toString(): RoleMention; @@ -2446,7 +2448,7 @@ export class ApplicationCommandManager< ApplicationCommandScope = ApplicationCommand<{ guild: GuildResolvable }>, PermissionsOptionsExtras = { guild: GuildResolvable }, PermissionsGuildType = null, -> extends CachedManager { + > extends CachedManager { protected constructor(client: Client, iterable?: Iterable); public permissions: ApplicationCommandPermissionsManager< { command?: ApplicationCommandResolvable } & PermissionsOptionsExtras, @@ -2493,8 +2495,13 @@ export class ApplicationCommandPermissionsManager< FullPermissionsOptions, GuildType, CommandIdType, -> extends BaseManager { +<<<<<<< HEAD + > extends BaseManager { private constructor(manager: ApplicationCommandManager | GuildApplicationCommandManager | ApplicationCommand); +======= + > extends BaseManager { + public constructor(manager: ApplicationCommandManager | GuildApplicationCommandManager | ApplicationCommand); +>>>>>>> 3693f438 (types: update typings to support role icons) private manager: ApplicationCommandManager | GuildApplicationCommandManager | ApplicationCommand; public client: Client; @@ -2510,13 +2517,13 @@ export class ApplicationCommandPermissionsManager< public remove( options: | (FetchSingleOptions & { - users: UserResolvable | UserResolvable[]; - roles?: RoleResolvable | RoleResolvable[]; - }) + users: UserResolvable | UserResolvable[]; + roles?: RoleResolvable | RoleResolvable[]; + }) | (FetchSingleOptions & { - users?: UserResolvable | UserResolvable[]; - roles: RoleResolvable | RoleResolvable[]; - }), + users?: UserResolvable | UserResolvable[]; + roles: RoleResolvable | RoleResolvable[]; + }), ): Promise; public set( options: FetchSingleOptions & { permissions: ApplicationCommandPermissionData[] }, @@ -3300,8 +3307,8 @@ export type CacheFactory = ( export type CacheWithLimitsOptions = { [K in keyof Caches]?: Caches[K][0]['prototype'] extends DataManager - ? LimitedCollectionOptions | number - : never; + ? LimitedCollectionOptions | number + : never; }; export interface CategoryCreateChannelOptions { @@ -4660,24 +4667,24 @@ export type Partialize< N extends keyof T | null = null, M extends keyof T | null = null, E extends keyof T | '' = '', -> = { - readonly client: Client; - id: Snowflake; - partial: true; -} & { - [K in keyof Omit]: K extends N ? null : K extends M ? T[K] | null : T[K]; -}; + > = { + readonly client: Client; + id: Snowflake; + partial: true; + } & { + [K in keyof Omit]: K extends N ? null : K extends M ? T[K] | null : T[K]; + }; export interface PartialDMChannel extends Partialize { lastMessageId: undefined; } -export interface PartialGuildMember extends Partialize {} +export interface PartialGuildMember extends Partialize { } export interface PartialMessage - extends Partialize {} + extends Partialize { } -export interface PartialMessageReaction extends Partialize {} +export interface PartialMessageReaction extends Partialize { } export interface PartialOverwriteData { id: Snowflake | number; @@ -4692,7 +4699,7 @@ export interface PartialRoleData extends RoleData { export type PartialTypes = 'USER' | 'CHANNEL' | 'GUILD_MEMBER' | 'MESSAGE' | 'REACTION'; -export interface PartialUser extends Partialize {} +export interface PartialUser extends Partialize { } export type PresenceStatusData = ClientPresenceStatus | 'invisible'; @@ -4741,6 +4748,7 @@ export interface RoleData { position?: number; permissions?: PermissionResolvable; mentionable?: boolean; + icon?: BufferResolvable | Base64Resolvable; } export type RoleMention = '@everyone' | `<@&${Snowflake}>`; From 20868c3962087acb767ab9f3270323ef78060a11 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Mon, 13 Sep 2021 09:51:22 +0530 Subject: [PATCH 05/17] feat: add role icon CDN --- src/util/Constants.js | 2 ++ typings/index.d.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/util/Constants.js b/src/util/Constants.js index a71d64fa1aec..a5b7837bc600 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -73,6 +73,8 @@ exports.Endpoints = { TeamIcon: (teamId, hash, options) => makeImageUrl(`${root}/team-icons/${teamId}/${hash}`, options), Sticker: (stickerId, stickerFormat) => `${root}/stickers/${stickerId}.${stickerFormat === 'LOTTIE' ? 'json' : 'png'}`, + // TODO: Need more info + RoleIcon: (roleId, hash, format) => `${root}/role-icons/${roleId}/${hash}.${format === 'png' ? 'png' : 'jpeg'}`, }; }, invite: (root, code) => `${root}/${code}`, diff --git a/typings/index.d.ts b/typings/index.d.ts index a41bc9b01815..35317ef1503f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2364,6 +2364,8 @@ export const Constants: { { format, size }: { format: AllowedImageFormat; size: AllowedImageSize }, ) => string; Sticker: (stickerId: Snowflake, stickerFormat: StickerFormatType) => string; + // TODO: update this later + RoleIcon: (roleId: Snowflake, hash: string, format: AllowedImageFormat) => string; }; }; WSCodes: { From 6fc566a2ad75328d06f665f6d6462888b0917e77 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Mon, 13 Sep 2021 17:04:22 +0530 Subject: [PATCH 06/17] feat: add Role#iconURL and update RoleIcon method --- src/structures/Role.js | 10 ++++++++++ src/util/Constants.js | 4 ++-- typings/index.d.ts | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/structures/Role.js b/src/structures/Role.js index 678b6776ad8b..5ac0c3c1cd1b 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -367,6 +367,16 @@ class Role extends Base { return this; } + /** + * A link to the role's icon + * @param {StaticImageURLOptions} [options={}] Options for the image URL + * @returns {?string} + */ + iconURL({ format, size } = {}) { + if (!this.icon) return null; + return this.client.rest.cdn.RoleIcon(this.id, this.icon, format, size); + } + /** * Whether this role equals another role. It compares all properties, so for most operations * it is advisable to just compare `role.id === role2.id` as it is much faster and is often diff --git a/src/util/Constants.js b/src/util/Constants.js index a5b7837bc600..80155da577b4 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -73,8 +73,8 @@ exports.Endpoints = { TeamIcon: (teamId, hash, options) => makeImageUrl(`${root}/team-icons/${teamId}/${hash}`, options), Sticker: (stickerId, stickerFormat) => `${root}/stickers/${stickerId}.${stickerFormat === 'LOTTIE' ? 'json' : 'png'}`, - // TODO: Need more info - RoleIcon: (roleId, hash, format) => `${root}/role-icons/${roleId}/${hash}.${format === 'png' ? 'png' : 'jpeg'}`, + RoleIcon: (roleId, hash, format = 'webp', size) => + makeImageUrl(`${root}/role-icons/${roleId}/${hash}`, { size, format }), }; }, invite: (root, code) => `${root}/${code}`, diff --git a/typings/index.d.ts b/typings/index.d.ts index 35317ef1503f..34a72461edd5 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1651,6 +1651,7 @@ export class Role extends Base { public delete(reason?: string): Promise; public edit(data: RoleData, reason?: string): Promise; public equals(role: Role): boolean; + public iconURL(options?: StaticImageURLOptions): string | null; public permissionsIn(channel: GuildChannel | Snowflake): Readonly; public setColor(color: ColorResolvable, reason?: string): Promise; public setHoist(hoist?: boolean, reason?: string): Promise; @@ -2364,8 +2365,7 @@ export const Constants: { { format, size }: { format: AllowedImageFormat; size: AllowedImageSize }, ) => string; Sticker: (stickerId: Snowflake, stickerFormat: StickerFormatType) => string; - // TODO: update this later - RoleIcon: (roleId: Snowflake, hash: string, format: AllowedImageFormat) => string; + RoleIcon: (roleId: Snowflake, hash: string, format: AllowedImageFormat, size: AllowedImageSize) => string; }; }; WSCodes: { From 9a9bc1a16e788317f3e85266b5d5aad6dd1b3985 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Mon, 13 Sep 2021 17:13:14 +0530 Subject: [PATCH 07/17] docs(CreateRoleOptions): move icon property above reason in jsdoc --- src/managers/RoleManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/managers/RoleManager.js b/src/managers/RoleManager.js index 51570daa3fa8..2933ce2353f6 100644 --- a/src/managers/RoleManager.js +++ b/src/managers/RoleManager.js @@ -105,8 +105,8 @@ class RoleManager extends CachedManager { * @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 * @property {BufferResolvable|Base64Resolvable} [icon] The icon for the role + * @property {string} [reason] The reason for creating this role */ /** From 42e64324ace7a6f73dd49fa9daf5d8f043ea4f0a Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Tue, 14 Sep 2021 13:14:04 +0530 Subject: [PATCH 08/17] types: allow role icon to be set to null --- src/managers/RoleManager.js | 2 +- src/structures/Role.js | 4 ++-- typings/index.d.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/managers/RoleManager.js b/src/managers/RoleManager.js index 2933ce2353f6..61bad2c3b483 100644 --- a/src/managers/RoleManager.js +++ b/src/managers/RoleManager.js @@ -105,7 +105,7 @@ class RoleManager extends CachedManager { * @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 {BufferResolvable|Base64Resolvable} [icon] The icon for the role + * @property {?(BufferResolvable|Base64Resolvable)} [icon] The icon for the role * @property {string} [reason] The reason for creating this role */ diff --git a/src/structures/Role.js b/src/structures/Role.js index 5ac0c3c1cd1b..960ce83e8b01 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -197,7 +197,7 @@ class Role extends Base { * @property {number} [position] The position of the role * @property {PermissionResolvable} [permissions] The permissions of the role * @property {boolean} [mentionable] Whether or not the role should be mentionable - * @property {BufferResolvable|Base64Resolvable} [icon] The icon for the role + * @property {?(BufferResolvable|Base64Resolvable)} [icon] The icon for the role */ /** @@ -309,7 +309,7 @@ class Role extends Base { /** * Sets a new icon for the role. - * @param {BufferResolvable|Base64Resolvable} icon The icon for the role + * @param {?(BufferResolvable|Base64Resolvable)} icon The icon for the role * @param {string} [reason] Reason for changing the role's icon * @returns {Promise} */ diff --git a/typings/index.d.ts b/typings/index.d.ts index 34a72461edd5..15ae14a78ce8 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1658,7 +1658,7 @@ export class Role extends Base { public setMentionable(mentionable?: boolean, reason?: string): Promise; public setName(name: string, reason?: string): Promise; public setPermissions(permissions: PermissionResolvable, reason?: string): Promise; - public setIcon(icon: BufferResolvable | Base64Resolvable, reason?: string): Promise; + public setIcon(icon: BufferResolvable | Base64Resolvable | null, reason?: string): Promise; public setPosition(position: number, options?: SetRolePositionOptions): Promise; public toJSON(): unknown; public toString(): RoleMention; @@ -4750,7 +4750,7 @@ export interface RoleData { position?: number; permissions?: PermissionResolvable; mentionable?: boolean; - icon?: BufferResolvable | Base64Resolvable; + icon?: BufferResolvable | Base64Resolvable | null; } export type RoleMention = '@everyone' | `<@&${Snowflake}>`; From 23dd5e4f37154dff01949038eee455c6df7b4315 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Wed, 22 Sep 2021 10:13:52 +0530 Subject: [PATCH 09/17] feat: add unicode_emoji field of the role --- src/managers/RoleManager.js | 5 ++++- src/structures/Role.js | 19 ++++++++++++++++++- typings/index.d.ts | 3 +++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/managers/RoleManager.js b/src/managers/RoleManager.js index 61bad2c3b483..18c55b790e96 100644 --- a/src/managers/RoleManager.js +++ b/src/managers/RoleManager.js @@ -106,6 +106,7 @@ class RoleManager extends CachedManager { * @property {number} [position] The position of the new role * @property {boolean} [mentionable] Whether or not the new role should be mentionable * @property {?(BufferResolvable|Base64Resolvable)} [icon] The icon for the role + * @property {string} [unicodeEmoji] The unicode emoji for the role * @property {string} [reason] The reason for creating this role */ @@ -130,7 +131,7 @@ class RoleManager extends CachedManager { * .catch(console.error); */ async create(options = {}) { - let { name, color, hoist, permissions, position, mentionable, reason, icon } = options; + let { name, color, hoist, permissions, position, mentionable, reason, icon, unicodeEmoji } = options; color &&= resolveColor(color); if (typeof permissions !== 'undefined') permissions = new Permissions(permissions); if (icon) icon = await DataResolver.resolveImage(icon); @@ -143,6 +144,7 @@ class RoleManager extends CachedManager { permissions, mentionable, icon, + unicode_emoji: unicodeEmoji, }, reason, }); @@ -193,6 +195,7 @@ class RoleManager extends CachedManager { permissions: typeof data.permissions === 'undefined' ? undefined : new Permissions(data.permissions), mentionable: data.mentionable, icon: typeof data.icon === 'undefined' ? undefined : await DataResolver.resolveImage(data.icon), + unicode_emoji: data.unicodeEmoji, }; const d = await this.client.api.guilds(this.guild.id).roles(role.id).patch({ data: _data, reason }); diff --git a/src/structures/Role.js b/src/structures/Role.js index 960ce83e8b01..2365019f149d 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -92,11 +92,17 @@ class Role extends Base { this.deleted = false; /** - * The icon of the role + * The icon hash of the role * @type {?string} */ this.icon = data.icon; + /** + * The unicode emoji of the role + * @type {?string} + */ + this.unicodeEmoji = data.unicode_emoji; + /** * The tags this role has * @type {?Object} @@ -198,6 +204,7 @@ class Role extends Base { * @property {PermissionResolvable} [permissions] The permissions of the role * @property {boolean} [mentionable] Whether or not the role should be mentionable * @property {?(BufferResolvable|Base64Resolvable)} [icon] The icon for the role + * @property {string} [unicodeEmoji] The unicode emoji for the role */ /** @@ -317,6 +324,16 @@ class Role extends Base { return this.edit({ icon }, reason); } + /** + * Sets a new unicode emoji for the role. + * @param {string} unicodeEmoji The unicode emoji for the role + * @param {string} [reason] Reason for changing the role's unicode emoji + * @returns {Promise} + */ + setUnicodeEmoji(unicodeEmoji, reason) { + return this.edit({ unicodeEmoji }, reason); + } + /** * Options used to set position of a role. * @typedef {Object} SetRolePositionOptions diff --git a/typings/index.d.ts b/typings/index.d.ts index 15ae14a78ce8..5521a9993521 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1648,6 +1648,7 @@ export class Role extends Base { public tags: RoleTagData | null; public comparePositionTo(role: RoleResolvable): number; public icon: string | null; + public unicodeEmoji: string | null; public delete(reason?: string): Promise; public edit(data: RoleData, reason?: string): Promise; public equals(role: Role): boolean; @@ -1660,6 +1661,7 @@ export class Role extends Base { public setPermissions(permissions: PermissionResolvable, reason?: string): Promise; public setIcon(icon: BufferResolvable | Base64Resolvable | null, reason?: string): Promise; public setPosition(position: number, options?: SetRolePositionOptions): Promise; + public setUnicodeEmoji(unicodeEmoji: string, reason?: string): Promise; public toJSON(): unknown; public toString(): RoleMention; @@ -4751,6 +4753,7 @@ export interface RoleData { permissions?: PermissionResolvable; mentionable?: boolean; icon?: BufferResolvable | Base64Resolvable | null; + unicodeEmoji?: string; } export type RoleMention = '@everyone' | `<@&${Snowflake}>`; From ece98128babd8942d947d6ac669c97ddcdf909c9 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Wed, 22 Sep 2021 10:19:30 +0530 Subject: [PATCH 10/17] feat(Role): add check for unicodeEmoji in #equals --- src/structures/Role.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/structures/Role.js b/src/structures/Role.js index 2365019f149d..82cf7000e017 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -411,7 +411,8 @@ class Role extends Base { this.position === role.position && this.permissions.bitfield === role.permissions.bitfield && this.managed === role.managed && - this.icon === role.icon + this.icon === role.icon && + this.unicodeEmoji === role.unicodeEmoji ); } From 211224b97320b7a3c0c1cacf87df6e18a4e37cab Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Wed, 22 Sep 2021 10:25:06 +0530 Subject: [PATCH 11/17] feat: allow unicodeEmoji to be set to null --- src/managers/RoleManager.js | 2 +- src/structures/Role.js | 4 ++-- typings/index.d.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/managers/RoleManager.js b/src/managers/RoleManager.js index 18c55b790e96..dd3f495fadc8 100644 --- a/src/managers/RoleManager.js +++ b/src/managers/RoleManager.js @@ -106,7 +106,7 @@ class RoleManager extends CachedManager { * @property {number} [position] The position of the new role * @property {boolean} [mentionable] Whether or not the new role should be mentionable * @property {?(BufferResolvable|Base64Resolvable)} [icon] The icon for the role - * @property {string} [unicodeEmoji] The unicode emoji for the role + * @property {?string} [unicodeEmoji] The unicode emoji for the role * @property {string} [reason] The reason for creating this role */ diff --git a/src/structures/Role.js b/src/structures/Role.js index 82cf7000e017..6428ac27b73f 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -204,7 +204,7 @@ class Role extends Base { * @property {PermissionResolvable} [permissions] The permissions of the role * @property {boolean} [mentionable] Whether or not the role should be mentionable * @property {?(BufferResolvable|Base64Resolvable)} [icon] The icon for the role - * @property {string} [unicodeEmoji] The unicode emoji for the role + * @property {?string} [unicodeEmoji] The unicode emoji for the role */ /** @@ -326,7 +326,7 @@ class Role extends Base { /** * Sets a new unicode emoji for the role. - * @param {string} unicodeEmoji The unicode emoji for the role + * @param {?string} unicodeEmoji The unicode emoji for the role * @param {string} [reason] Reason for changing the role's unicode emoji * @returns {Promise} */ diff --git a/typings/index.d.ts b/typings/index.d.ts index 5521a9993521..46a1f3bd7a9e 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1661,7 +1661,7 @@ export class Role extends Base { public setPermissions(permissions: PermissionResolvable, reason?: string): Promise; public setIcon(icon: BufferResolvable | Base64Resolvable | null, reason?: string): Promise; public setPosition(position: number, options?: SetRolePositionOptions): Promise; - public setUnicodeEmoji(unicodeEmoji: string, reason?: string): Promise; + public setUnicodeEmoji(unicodeEmoji: string | null, reason?: string): Promise; public toJSON(): unknown; public toString(): RoleMention; @@ -4753,7 +4753,7 @@ export interface RoleData { permissions?: PermissionResolvable; mentionable?: boolean; icon?: BufferResolvable | Base64Resolvable | null; - unicodeEmoji?: string; + unicodeEmoji?: string | null; } export type RoleMention = '@everyone' | `<@&${Snowflake}>`; From 1b24f3cb15237a015c0df715b6677c8237c45165 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Tue, 28 Sep 2021 09:37:31 +0530 Subject: [PATCH 12/17] docs: add example for updating unicode_emoji field --- src/managers/RoleManager.js | 2 +- src/structures/Role.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/managers/RoleManager.js b/src/managers/RoleManager.js index dd3f495fadc8..a80f0d92ad9f 100644 --- a/src/managers/RoleManager.js +++ b/src/managers/RoleManager.js @@ -106,7 +106,7 @@ class RoleManager extends CachedManager { * @property {number} [position] The position of the new role * @property {boolean} [mentionable] Whether or not the new role should be mentionable * @property {?(BufferResolvable|Base64Resolvable)} [icon] The icon for the role - * @property {?string} [unicodeEmoji] The unicode emoji for the role + * @property {?string} [unicodeEmoji] The name of the unicode emoji for the role * @property {string} [reason] The reason for creating this role */ diff --git a/src/structures/Role.js b/src/structures/Role.js index 6428ac27b73f..be98755308ed 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -98,7 +98,7 @@ class Role extends Base { this.icon = data.icon; /** - * The unicode emoji of the role + * The name of the unicode emoji for the role * @type {?string} */ this.unicodeEmoji = data.unicode_emoji; @@ -204,7 +204,7 @@ class Role extends Base { * @property {PermissionResolvable} [permissions] The permissions of the role * @property {boolean} [mentionable] Whether or not the role should be mentionable * @property {?(BufferResolvable|Base64Resolvable)} [icon] The icon for the role - * @property {?string} [unicodeEmoji] The unicode emoji for the role + * @property {?string} [unicodeEmoji] The name of the unicode emoji for the role */ /** @@ -326,9 +326,14 @@ class Role extends Base { /** * Sets a new unicode emoji for the role. - * @param {?string} unicodeEmoji The unicode emoji for the role + * @param {?string} unicodeEmoji The name of the new unicode emoji for the role * @param {string} [reason] Reason for changing the role's unicode emoji * @returns {Promise} + * @example + * // Set a new unicode emoji for the role + * role.setUnicodeEmoji('robot') + * .then(updated => console.log(`Set unicode emoji for the role to ${updated.unicodeEmoji}`)) + * .catch(console.error); */ setUnicodeEmoji(unicodeEmoji, reason) { return this.edit({ unicodeEmoji }, reason); From 8fa658d0f9641e8207a266eea11a6472838b16f2 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Tue, 28 Sep 2021 11:39:29 +0530 Subject: [PATCH 13/17] feat: allow guild emoji to be set as role icon --- src/managers/RoleManager.js | 15 ++++++++++++--- src/structures/Role.js | 4 ++-- typings/index.d.ts | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/managers/RoleManager.js b/src/managers/RoleManager.js index a80f0d92ad9f..4003a2b9acd3 100644 --- a/src/managers/RoleManager.js +++ b/src/managers/RoleManager.js @@ -105,7 +105,7 @@ class RoleManager extends CachedManager { * @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 {?(BufferResolvable|Base64Resolvable)} [icon] The icon for the role + * @property {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} [icon] The icon for the role * @property {?string} [unicodeEmoji] The name of the unicode emoji for the role * @property {string} [reason] The reason for creating this role */ @@ -134,7 +134,10 @@ class RoleManager extends CachedManager { let { name, color, hoist, permissions, position, mentionable, reason, icon, unicodeEmoji } = options; color &&= resolveColor(color); if (typeof permissions !== 'undefined') permissions = new Permissions(permissions); - if (icon) icon = await DataResolver.resolveImage(icon); + if (icon) { + const guildEmojiURL = this.guild.emojis.resolve(icon)?.url; + icon = guildEmojiURL ? await DataResolver.resolveImage(guildEmojiURL) : await DataResolver.resolveImage(icon); + } const data = await this.client.api.guilds(this.guild.id).roles.post({ data: { @@ -188,13 +191,19 @@ class RoleManager extends CachedManager { }); } + let icon = data.icon; + if (typeof icon !== 'undefined') { + const guildEmojiURL = this.guild.emojis.resolve(icon)?.url; + icon = guildEmojiURL ? await DataResolver.resolveImage(guildEmojiURL) : await DataResolver.resolveImage(icon); + } + const _data = { name: data.name, color: typeof data.color === 'undefined' ? undefined : resolveColor(data.color), hoist: data.hoist, permissions: typeof data.permissions === 'undefined' ? undefined : new Permissions(data.permissions), mentionable: data.mentionable, - icon: typeof data.icon === 'undefined' ? undefined : await DataResolver.resolveImage(data.icon), + icon, unicode_emoji: data.unicodeEmoji, }; diff --git a/src/structures/Role.js b/src/structures/Role.js index be98755308ed..8f8caa05d5f8 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -203,7 +203,7 @@ class Role extends Base { * @property {number} [position] The position of the role * @property {PermissionResolvable} [permissions] The permissions of the role * @property {boolean} [mentionable] Whether or not the role should be mentionable - * @property {?(BufferResolvable|Base64Resolvable)} [icon] The icon for the role + * @property {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} [icon] The icon for the role * @property {?string} [unicodeEmoji] The name of the unicode emoji for the role */ @@ -316,7 +316,7 @@ class Role extends Base { /** * Sets a new icon for the role. - * @param {?(BufferResolvable|Base64Resolvable)} icon The icon for the role + * @param {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} icon The icon for the role * @param {string} [reason] Reason for changing the role's icon * @returns {Promise} */ diff --git a/typings/index.d.ts b/typings/index.d.ts index 46a1f3bd7a9e..3d5100a2e269 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1659,7 +1659,7 @@ export class Role extends Base { public setMentionable(mentionable?: boolean, reason?: string): Promise; public setName(name: string, reason?: string): Promise; public setPermissions(permissions: PermissionResolvable, reason?: string): Promise; - public setIcon(icon: BufferResolvable | Base64Resolvable | null, reason?: string): Promise; + public setIcon(icon: BufferResolvable | Base64Resolvable | EmojiResolvable | null, reason?: string): Promise; public setPosition(position: number, options?: SetRolePositionOptions): Promise; public setUnicodeEmoji(unicodeEmoji: string | null, reason?: string): Promise; public toJSON(): unknown; @@ -4752,7 +4752,7 @@ export interface RoleData { position?: number; permissions?: PermissionResolvable; mentionable?: boolean; - icon?: BufferResolvable | Base64Resolvable | null; + icon?: BufferResolvable | Base64Resolvable | EmojiResolvable | null; unicodeEmoji?: string | null; } From 52b9dc0aed2a8b51b47b0e8c8735dc886f0aeb37 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Tue, 28 Sep 2021 17:06:58 +0530 Subject: [PATCH 14/17] refactor(RoleManager): rm redundant check for icon in #edit --- src/managers/RoleManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/managers/RoleManager.js b/src/managers/RoleManager.js index 4003a2b9acd3..ea0066d05844 100644 --- a/src/managers/RoleManager.js +++ b/src/managers/RoleManager.js @@ -192,7 +192,7 @@ class RoleManager extends CachedManager { } let icon = data.icon; - if (typeof icon !== 'undefined') { + if (icon) { const guildEmojiURL = this.guild.emojis.resolve(icon)?.url; icon = guildEmojiURL ? await DataResolver.resolveImage(guildEmojiURL) : await DataResolver.resolveImage(icon); } From 8a180ab87e38bf82dcf4062c38ce5f4ae9c99129 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Thu, 30 Sep 2021 20:37:17 +0530 Subject: [PATCH 15/17] docs: update role unicode emoji related docs --- src/managers/RoleManager.js | 2 +- src/structures/Role.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/managers/RoleManager.js b/src/managers/RoleManager.js index ea0066d05844..912ced643539 100644 --- a/src/managers/RoleManager.js +++ b/src/managers/RoleManager.js @@ -106,7 +106,7 @@ class RoleManager extends CachedManager { * @property {number} [position] The position of the new role * @property {boolean} [mentionable] Whether or not the new role should be mentionable * @property {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} [icon] The icon for the role - * @property {?string} [unicodeEmoji] The name of the unicode emoji for the role + * @property {?string} [unicodeEmoji] The unicode emoji for the role * @property {string} [reason] The reason for creating this role */ diff --git a/src/structures/Role.js b/src/structures/Role.js index 8f8caa05d5f8..9372e8f31dbe 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -98,7 +98,7 @@ class Role extends Base { this.icon = data.icon; /** - * The name of the unicode emoji for the role + * The unicode emoji for the role * @type {?string} */ this.unicodeEmoji = data.unicode_emoji; @@ -204,7 +204,7 @@ class Role extends Base { * @property {PermissionResolvable} [permissions] The permissions of the role * @property {boolean} [mentionable] Whether or not the role should be mentionable * @property {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} [icon] The icon for the role - * @property {?string} [unicodeEmoji] The name of the unicode emoji for the role + * @property {?string} [unicodeEmoji] The unicode emoji for the role */ /** @@ -326,12 +326,12 @@ class Role extends Base { /** * Sets a new unicode emoji for the role. - * @param {?string} unicodeEmoji The name of the new unicode emoji for the role + * @param {?string} unicodeEmoji The new unicode emoji for the role * @param {string} [reason] Reason for changing the role's unicode emoji * @returns {Promise} * @example * // Set a new unicode emoji for the role - * role.setUnicodeEmoji('robot') + * role.setUnicodeEmoji('🤖') * .then(updated => console.log(`Set unicode emoji for the role to ${updated.unicodeEmoji}`)) * .catch(console.error); */ From 9a1c4aa8cb1b51860af57a2872115bdf0b19623e Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Sun, 3 Oct 2021 09:31:53 +0530 Subject: [PATCH 16/17] feat: set icon field to undefined if not resolved to a string --- src/managers/RoleManager.js | 4 ++++ src/structures/Role.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/managers/RoleManager.js b/src/managers/RoleManager.js index 912ced643539..21e49bc66324 100644 --- a/src/managers/RoleManager.js +++ b/src/managers/RoleManager.js @@ -106,6 +106,8 @@ class RoleManager extends CachedManager { * @property {number} [position] The position of the new role * @property {boolean} [mentionable] Whether or not the new role should be mentionable * @property {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} [icon] The icon for the role + * The `EmojiResolvable` should belong to the same guild as the role. + * If not, pass the emoji's URL directly * @property {?string} [unicodeEmoji] The unicode emoji for the role * @property {string} [reason] The reason for creating this role */ @@ -137,6 +139,7 @@ class RoleManager extends CachedManager { if (icon) { const guildEmojiURL = this.guild.emojis.resolve(icon)?.url; icon = guildEmojiURL ? await DataResolver.resolveImage(guildEmojiURL) : await DataResolver.resolveImage(icon); + if (typeof icon !== 'string') icon = undefined; } const data = await this.client.api.guilds(this.guild.id).roles.post({ @@ -195,6 +198,7 @@ class RoleManager extends CachedManager { if (icon) { const guildEmojiURL = this.guild.emojis.resolve(icon)?.url; icon = guildEmojiURL ? await DataResolver.resolveImage(guildEmojiURL) : await DataResolver.resolveImage(icon); + if (typeof icon !== 'string') icon = undefined; } const _data = { diff --git a/src/structures/Role.js b/src/structures/Role.js index 9372e8f31dbe..9fb5a09e3210 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -204,6 +204,8 @@ class Role extends Base { * @property {PermissionResolvable} [permissions] The permissions of the role * @property {boolean} [mentionable] Whether or not the role should be mentionable * @property {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} [icon] The icon for the role + * The `EmojiResolvable` should belong to the same guild as the role. + * If not, pass the emoji's URL directly * @property {?string} [unicodeEmoji] The unicode emoji for the role */ @@ -317,6 +319,8 @@ class Role extends Base { /** * Sets a new icon for the role. * @param {?(BufferResolvable|Base64Resolvable|EmojiResolvable)} icon The icon for the role + * The `EmojiResolvable` should belong to the same guild as the role. + * If not, pass the emoji's URL directly * @param {string} [reason] Reason for changing the role's icon * @returns {Promise} */ From d0243c6e74c90a18c95970309db277c154c39559 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Sun, 3 Oct 2021 20:42:50 +0530 Subject: [PATCH 17/17] fix: git rebase stuff left behind, how? idk --- typings/index.d.ts | 75 ++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 3d5100a2e269..d81713d9e9d6 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -996,7 +996,7 @@ export class HTTPError extends Error { } // tslint:disable-next-line:no-empty-interface - Merge RateLimitData into RateLimitError to not have to type it again -export interface RateLimitError extends RateLimitData { } +export interface RateLimitError extends RateLimitData {} export class RateLimitError extends Error { private constructor(data: RateLimitData); public name: 'RateLimitError'; @@ -1164,8 +1164,8 @@ type TaggedUnion = T extends Record ? T : T extends Record ? V extends U - ? T - : never + ? T + : never : never; // This creates a map of MessageComponentTypes to their respective `InteractionCollectorOptionsResolvable` variant. @@ -1177,8 +1177,8 @@ type CollectorOptionsTypeResolver` variant back. type ConditionalInteractionCollectorType = T extends InteractionCollectorOptions - ? InteractionCollector - : InteractionCollector; + ? InteractionCollector + : InteractionCollector; // This maps each componentType key to each variant. type MappedInteractionCollectorOptions = CollectorOptionsTypeResolver; @@ -1194,20 +1194,20 @@ type InteractionExtractor - ? Item - : never + ? Item + : never : MessageComponentInteraction; type MessageCollectorOptionsParams = | { - componentType?: T; - } & MessageComponentCollectorOptions>; + componentType?: T; + } & MessageComponentCollectorOptions>; type AwaitMessageCollectorOptionsParams = | { componentType?: T } & Pick< - InteractionCollectorOptions>, - keyof AwaitMessageComponentOptions - >; + InteractionCollectorOptions>, + keyof AwaitMessageComponentOptions + >; export class Message extends Base { private constructor(client: Client, data: RawMessageData); @@ -1255,12 +1255,12 @@ export class Message extends Base { public reference: MessageReference | null; public awaitMessageComponent< T extends MessageComponentType | MessageComponentTypes | undefined = MessageComponentTypes.ACTION_ROW, - >(options?: AwaitMessageCollectorOptionsParams): Promise>; + >(options?: AwaitMessageCollectorOptionsParams): Promise>; public awaitReactions(options?: AwaitReactionsOptions): Promise>; public createReactionCollector(options?: ReactionCollectorOptions): ReactionCollector; public createMessageComponentCollector< T extends MessageComponentType | MessageComponentTypes | undefined = undefined, - >(options?: MessageCollectorOptionsParams): InteractionCollectorReturnType; + >(options?: MessageCollectorOptionsParams): InteractionCollectorReturnType; public delete(): Promise; public edit(content: string | MessageEditOptions | MessagePayload): Promise; public equals(message: Message, rawData: unknown): boolean; @@ -2452,7 +2452,7 @@ export class ApplicationCommandManager< ApplicationCommandScope = ApplicationCommand<{ guild: GuildResolvable }>, PermissionsOptionsExtras = { guild: GuildResolvable }, PermissionsGuildType = null, - > extends CachedManager { +> extends CachedManager { protected constructor(client: Client, iterable?: Iterable); public permissions: ApplicationCommandPermissionsManager< { command?: ApplicationCommandResolvable } & PermissionsOptionsExtras, @@ -2499,13 +2499,8 @@ export class ApplicationCommandPermissionsManager< FullPermissionsOptions, GuildType, CommandIdType, -<<<<<<< HEAD - > extends BaseManager { +> extends BaseManager { private constructor(manager: ApplicationCommandManager | GuildApplicationCommandManager | ApplicationCommand); -======= - > extends BaseManager { - public constructor(manager: ApplicationCommandManager | GuildApplicationCommandManager | ApplicationCommand); ->>>>>>> 3693f438 (types: update typings to support role icons) private manager: ApplicationCommandManager | GuildApplicationCommandManager | ApplicationCommand; public client: Client; @@ -2521,13 +2516,13 @@ export class ApplicationCommandPermissionsManager< public remove( options: | (FetchSingleOptions & { - users: UserResolvable | UserResolvable[]; - roles?: RoleResolvable | RoleResolvable[]; - }) + users: UserResolvable | UserResolvable[]; + roles?: RoleResolvable | RoleResolvable[]; + }) | (FetchSingleOptions & { - users?: UserResolvable | UserResolvable[]; - roles: RoleResolvable | RoleResolvable[]; - }), + users?: UserResolvable | UserResolvable[]; + roles: RoleResolvable | RoleResolvable[]; + }), ): Promise; public set( options: FetchSingleOptions & { permissions: ApplicationCommandPermissionData[] }, @@ -3311,8 +3306,8 @@ export type CacheFactory = ( export type CacheWithLimitsOptions = { [K in keyof Caches]?: Caches[K][0]['prototype'] extends DataManager - ? LimitedCollectionOptions | number - : never; + ? LimitedCollectionOptions | number + : never; }; export interface CategoryCreateChannelOptions { @@ -4671,24 +4666,24 @@ export type Partialize< N extends keyof T | null = null, M extends keyof T | null = null, E extends keyof T | '' = '', - > = { - readonly client: Client; - id: Snowflake; - partial: true; - } & { - [K in keyof Omit]: K extends N ? null : K extends M ? T[K] | null : T[K]; - }; +> = { + readonly client: Client; + id: Snowflake; + partial: true; +} & { + [K in keyof Omit]: K extends N ? null : K extends M ? T[K] | null : T[K]; +}; export interface PartialDMChannel extends Partialize { lastMessageId: undefined; } -export interface PartialGuildMember extends Partialize { } +export interface PartialGuildMember extends Partialize {} export interface PartialMessage - extends Partialize { } + extends Partialize {} -export interface PartialMessageReaction extends Partialize { } +export interface PartialMessageReaction extends Partialize {} export interface PartialOverwriteData { id: Snowflake | number; @@ -4703,7 +4698,7 @@ export interface PartialRoleData extends RoleData { export type PartialTypes = 'USER' | 'CHANNEL' | 'GUILD_MEMBER' | 'MESSAGE' | 'REACTION'; -export interface PartialUser extends Partialize { } +export interface PartialUser extends Partialize {} export type PresenceStatusData = ClientPresenceStatus | 'invisible';