feat: add Role#tags prop

This commit is contained in:
ayntee 2020-12-25 22:29:26 +04:00
parent 3695b81de6
commit 1e753cf51d
2 changed files with 28 additions and 8 deletions

View file

@ -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
}

View file

@ -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
}