Merge pull request #77 from ayntee/role-struct

feat: add Role#tags prop
This commit is contained in:
DjDeveloper 2020-12-29 11:42:52 +05:30 committed by GitHub
commit 205f88281b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 !== undefined
? {
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
}
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
}