RoleTransformer
Class: RoleTransformer
Defined in: tagscript-plugin-discord/src/lib/Transformer/Role.ts:51
Transformer for a Discord APIRole payload.
Properties:
id: Gives role id.
name: Gives role name.
mention: Mentions the role.
color: Gives role color.
hoist: Gives true if the role is hoisted else false.
mentionable: Gives true if the role is mentionable else false.
position: Gives role position.
permissions: Gives role permissions.
createdAt: Gives role create date.
createdTimestamp: Gives role create date in ms.Remarks
You need to use StrictVarsParser parser to use this transformer.
A role payload does not say who holds the role, so pass a member count yourself if a template needs one:
new RoleTransformer(role, { memberCount: members.filter((member) => member.roles.includes(role.id)).length }).
Example
import { Interpreter, StrictVarsParser } from 'tagscript';
import { RoleTransformer } from '@tagscript/plugin-discord';
const ts = new Interpreter(new StrictVarsParser());
await ts.run('Ping {role}', { role: new RoleTransformer(role) });
// Ping <@&868430685231271966>Extends
BaseTransformer<APIRole>
Constructors
Constructor
new RoleTransformer(base, safeValues?): RoleTransformer
Defined in: tagscript-plugin-discord/src/lib/Transformer/Base.ts:28
Parameters
base
APIRole
safeValues?
SafeValues<APIRole> = {}
Returns
RoleTransformer
Inherited from
Properties
base
protected base: APIRole
Defined in: tagscript-plugin-discord/src/lib/Transformer/Base.ts:24
Inherited from
safeValues
protected safeValues: SafeValues<APIRole> = {}
Defined in: tagscript-plugin-discord/src/lib/Transformer/Base.ts:26
Inherited from
Methods
resolveId()
protected resolveId(): string
Defined in: tagscript-plugin-discord/src/lib/Transformer/Role.ts:52
The snowflake this payload is identified by. Read as {thing.id}.
Returns
string
Overrides
resolveMention()
protected resolveMention(): string
Defined in: tagscript-plugin-discord/src/lib/Transformer/Role.ts:56
What a bare {thing} renders to.
Returns
string
Overrides
BaseTransformer.resolveMention
toJSON()
toJSON(): SafeValues<APIRole>
Defined in: tagscript-plugin-discord/src/lib/Transformer/Base.ts:45
Returns
SafeValues<APIRole>
Inherited from
transform()
transform(tag): string | null
Defined in: tagscript-plugin-discord/src/lib/Transformer/Base.ts:37
Transforms the given tag.
Parameters
tag
Lexer
The tag that triggered the transformer.
Returns
string | null
Inherited from
updateSafeValues()
protected updateSafeValues(): void
Defined in: tagscript-plugin-discord/src/lib/Transformer/Role.ts:60
Returns
void