Tagscript

Class: UserTransformer

Transformer for Discord User.

Properties:

id: Gives user id.
mention: Mentions the user.
globalName: Gives user's global name.
username: Gives username of the user.
discriminator: Gives discriminator of the user
tag: Gives username#discriminator
avatar: Gives user's custom avatar if they have one. Else it'll be an empty string.
displayAvatar: Gives user's avatar URL if they have one else gives user's default avatar.
createdAt: Gives user's account create date.
createdTimestamp: Gives user's account created date in ms
bot: Gives true if the user is a bot else false.

Remarks

You need to use StrictVarsParser parser to use this transformer.

Example

import { Interpreter, StrictVarsParser } from 'tagscript';
import { UserTransformer } from '@tagscript/plugin-discord';
 
const ts = new Interpreter(new StrictVarsParser());
 
await ts.run('Hi {user}', { user: new UserTransformer(message.author) });
// Hi <@758880890159235083>

Extends

Constructors

new UserTransformer()

new UserTransformer(base, safeValues): UserTransformer

Parameters

base: User

safeValues: SafeValues<User> = {}

Returns

UserTransformer

Inherited from

BaseTransformer.constructor

Defined in

tagscript-plugin-discord/src/lib/Transformer/Base.ts:26

Properties

base

protected base: User

Inherited from

BaseTransformer.base

Defined in

tagscript-plugin-discord/src/lib/Transformer/Base.ts:22


safeValues

protected safeValues: SafeValues<User> = {}

Inherited from

BaseTransformer.safeValues

Defined in

tagscript-plugin-discord/src/lib/Transformer/Base.ts:24

Methods

toJSON()

toJSON(): SafeValues<User>

Returns

SafeValues<User>

Inherited from

BaseTransformer.toJSON

Defined in

tagscript-plugin-discord/src/lib/Transformer/Base.ts:44


transform()

transform(tag): null | string

Transforms the given tag.

Parameters

tag: Lexer

The tag that triggered the transformer.

Returns

null | string

Inherited from

BaseTransformer.transform

Defined in

tagscript-plugin-discord/src/lib/Transformer/Base.ts:36


updateSafeValues()

protected updateSafeValues(): void

Returns

void

Overrides

BaseTransformer.updateSafeValues

Defined in

tagscript-plugin-discord/src/lib/Transformer/User.ts:37

On this page