feat: add Role#tags prop
This commit is contained in:
parent
3695b81de6
commit
1e753cf51d
2 changed files with 28 additions and 8 deletions
|
@ -12,14 +12,7 @@ export class Role extends Base {
|
||||||
permissions: Permissions
|
permissions: Permissions
|
||||||
managed: boolean
|
managed: boolean
|
||||||
mentionable: boolean
|
mentionable: boolean
|
||||||
|
tags?: RoleTags
|
||||||
get mention(): string {
|
|
||||||
return `<@&${this.id}>`
|
|
||||||
}
|
|
||||||
|
|
||||||
toString(): string {
|
|
||||||
return this.mention
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(client: Client, data: RolePayload) {
|
constructor(client: Client, data: RolePayload) {
|
||||||
super(client, data)
|
super(client, data)
|
||||||
|
@ -31,6 +24,14 @@ export class Role extends Base {
|
||||||
this.permissions = new Permissions(data.permissions)
|
this.permissions = new Permissions(data.permissions)
|
||||||
this.managed = data.managed
|
this.managed = data.managed
|
||||||
this.mentionable = data.mentionable
|
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 {
|
readFromData(data: RolePayload): void {
|
||||||
|
@ -46,3 +47,12 @@ export class Role extends Base {
|
||||||
this.mentionable = data.mentionable ?? this.mentionable
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -7,4 +7,14 @@ export interface RolePayload {
|
||||||
permissions: string
|
permissions: string
|
||||||
managed: boolean
|
managed: boolean
|
||||||
mentionable: 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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue