Tagscript

ChannelTransformer

TagScript


Class: ChannelTransformer

Defined in: tagscript-plugin-discord/src/lib/Transformer/GuildTextBasedChannel.ts:52

Transformer for a Discord GuildChannel payload.

Properties:

id: Gives channel id.
mention: Mentions the channel.
name: Gives channel name.
topic: Gives channel topic.
type: Gives channel type.
position: Gives channel position.
nsfw: Gives true if the channel is nsfw else false.
parentId: Gives channel parent id.
createdAt: Gives channel create date.
createdTimestamp: Gives channel create date in ms.
slowmode: Gives channel slowmode.

Remarks

You need to use StrictVarsParser parser to use this transformer.

A channel payload carries parentId and nothing else about the category, so pass the category yourself if a template needs its name: new ChannelTransformer(channel, { parentName: parent.name }).

Example

import { Interpreter, StrictVarsParser } from 'tagscript';
import { ChannelTransformer } from '@tagscript/plugin-discord';

const ts = new Interpreter(new StrictVarsParser());

await ts.run('channel: {channel}', { channel: new ChannelTransformer(channel) });
// channel: <#870354581115256852>

Extends

Constructors

Constructor

new ChannelTransformer(base, safeValues?): ChannelTransformer

Defined in: tagscript-plugin-discord/src/lib/Transformer/Base.ts:28

Parameters

base

GuildChannel

safeValues?

SafeValues<GuildChannel> = {}

Returns

ChannelTransformer

Inherited from

BaseTransformer.constructor

Properties

base

protected base: GuildChannel

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

Inherited from

BaseTransformer.base


safeValues

protected safeValues: SafeValues<GuildChannel> = {}

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

Inherited from

BaseTransformer.safeValues

Methods

resolveId()

protected resolveId(): string

Defined in: tagscript-plugin-discord/src/lib/Transformer/GuildTextBasedChannel.ts:53

The snowflake this payload is identified by. Read as {thing.id}.

Returns

string

Overrides

BaseTransformer.resolveId


resolveMention()

protected resolveMention(): string

Defined in: tagscript-plugin-discord/src/lib/Transformer/GuildTextBasedChannel.ts:57

What a bare {thing} renders to.

Returns

string

Overrides

BaseTransformer.resolveMention


toJSON()

Defined in: tagscript-plugin-discord/src/lib/Transformer/Base.ts:45

Returns

SafeValues<GuildChannel>

Inherited from

BaseTransformer.toJSON


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

BaseTransformer.transform


updateSafeValues()

protected updateSafeValues(): void

Defined in: tagscript-plugin-discord/src/lib/Transformer/GuildTextBasedChannel.ts:61

Returns

void

Overrides

BaseTransformer.updateSafeValues

On this page