GuildTransformer
Expose a guild to a template.
GuildTransformer reads an APIGuild payload, including the roles it ships with and a few counts derived from them.
For template authors
Syntax
{{guild}}
{{guild(key)}}
{{guild.key}}The bare tag renders the guild name. A parameter picks one field.
Examples
Welcome to {guild}, owned by <@{guild(ownerId)}>.
# Welcome to My Server, owned by <@938716130720235601>.Fields
| Key | Gives |
|---|---|
id | The guild ID. |
name | The guild name. |
description | The guild description. |
icon | The icon. |
splash | The invite splash. |
banner | The banner. |
features | The guild features. |
ownerId | The owner ID. |
createdAt | Creation date as an ISO string. |
createdTimestamp | Creation time in milliseconds. |
memberCount | The approximate member count, when the payload was fetched with counts. |
roles | A mention per role. |
roleIds | The role IDs. |
roleNames | The role names. |
roleCount | How many roles. |
emojiCount | How many emojis. |
stickerCount | How many stickers. |
afkTimeout | The AFK timeout. |
afkChannel | A mention of the AFK channel. |
verificationLevel | The verification level. |
A key that does not exist leaves the tag in the output as written, so a typo is visible rather than silent.
For developers
Seeding one
import { GuildTransformer } from '@tagscript/plugin-discord';
import { Interpreter, StrictVarsParser } from 'tagscript';
const ts = new Interpreter(new StrictVarsParser());
const response = await ts.run(template, {
guild: new GuildTransformer(guild),
});A variable parser has to be registered for the tag to resolve.
Adding your own fields
Pass a second argument to expose extra keys. A function receives the payload and runs when the tag renders.
new GuildTransformer(guild, {
custom: 'a fixed value',
computed: (base) => `${base.id} was looked up at render time`,
});Channels are a separate endpoint and are not part of a guild payload, and memberCount reads
approximate_member_count, which Discord only sends when you fetch the guild with with_counts. Pass what
you have:
new GuildTransformer(guild, {
channelCount: channels.length,
channelNames: channels.map((channel) => channel.name).join(', '),
memberCount: cachedMemberCount,
});API reference
Last updated on