From 1e753cf51d5c34d008c668d397d520ce7670c081 Mon Sep 17 00:00:00 2001 From: ayntee Date: Fri, 25 Dec 2020 22:29:26 +0400 Subject: [PATCH 1/3] feat: add Role#tags prop --- src/structures/role.ts | 26 ++++++++++++++++++-------- src/types/role.ts | 10 ++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/structures/role.ts b/src/structures/role.ts index 01ada1d..a725127 100644 --- a/src/structures/role.ts +++ b/src/structures/role.ts @@ -12,14 +12,7 @@ export class Role extends Base { permissions: Permissions managed: boolean mentionable: boolean - - get mention(): string { - return `<@&${this.id}>` - } - - toString(): string { - return this.mention - } + tags?: RoleTags constructor(client: Client, data: RolePayload) { super(client, data) @@ -31,6 +24,14 @@ export class Role extends Base { this.permissions = new Permissions(data.permissions) this.managed = data.managed this.mentionable = data.mentionable + this.tags = + data.tags !== null + ? { + botID: data.tags?.bot_id, + integrationID: data.tags?.integration_id, + premiumSubscriber: 'premium_subscriber' in (data.tags ?? {}) + } + : undefined } readFromData(data: RolePayload): void { @@ -46,3 +47,12 @@ export class Role extends Base { this.mentionable = data.mentionable ?? this.mentionable } } + +export interface RoleTags { + /** The id of the bot who has this role */ + botID?: string + /** Whether this is the premium subscriber role for this guild */ + premiumSubscriber: boolean + /** The id of the integration this role belongs to */ + integrationID?: string +} diff --git a/src/types/role.ts b/src/types/role.ts index 78f43d6..d91aef8 100644 --- a/src/types/role.ts +++ b/src/types/role.ts @@ -7,4 +7,14 @@ export interface RolePayload { permissions: string managed: boolean mentionable: boolean + tags: RoleTagsPayload | null +} + +export interface RoleTagsPayload { + /** The id of the bot who has this role */ + bot_id?: string + /** Whether this is the premium subscriber role for this guild */ + premium_subscriber?: null + /** The id of the integration this role belongs to */ + integration_id?: string } From b7a93a280fde5fb1bdaf442bde85a91242c45761 Mon Sep 17 00:00:00 2001 From: Ayyan Date: Mon, 28 Dec 2020 12:14:10 +0400 Subject: [PATCH 2/3] Update role.ts --- src/types/role.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/role.ts b/src/types/role.ts index d91aef8..5ddfee8 100644 --- a/src/types/role.ts +++ b/src/types/role.ts @@ -7,7 +7,7 @@ export interface RolePayload { permissions: string managed: boolean mentionable: boolean - tags: RoleTagsPayload | null + tags?: RoleTagsPayload } export interface RoleTagsPayload { From e37e0c38853f5b97e52d28c3f8693e2d7f2a01dc Mon Sep 17 00:00:00 2001 From: Ayyan Date: Mon, 28 Dec 2020 12:18:09 +0400 Subject: [PATCH 3/3] Update role.ts --- src/structures/role.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/role.ts b/src/structures/role.ts index a725127..ed2e821 100644 --- a/src/structures/role.ts +++ b/src/structures/role.ts @@ -25,7 +25,7 @@ export class Role extends Base { this.managed = data.managed this.mentionable = data.mentionable this.tags = - data.tags !== null + data.tags !== undefined ? { botID: data.tags?.bot_id, integrationID: data.tags?.integration_id,