Welcome to Phen-Cogs’s documentation!

Phen-Cogs Discord Server PyPI - Python Version discord.py Code Style: Black Documentation Status

Tags

Tags come with the ability to create powerful custom commands through the usage of tag blocks. The basic block begins with a { and ends with an }. More advanced blocks may contain after the block declaration () to specify a parameter or a : to specify a payload.

Block Syntax

{block(parameter):payload}

[arg] = Optional

<arg> = Required

Usage

Note

[p] is your prefix.

Add a tag using the following command:

[p]tag add mytag Hello world!

Invoke the tag with your bot prefix and the tag’s name as if it were a command:

[p]mytag

The bot will then respond with the stored tag content:

Hello world!

Default Variables

Tags come with built-in variable blocks you can access for more information about the invocation context. These are:

  • args

  • author | user

  • target | member

  • channel

  • guild | server

You can see attributes available using these blocks in Default Variables.

Below is an example tag that returns info related to the tag author.

[p]tag add authorinfo Username: **{author}**
ID: **{author(id)}**
Creation Date: **{author(created_at)}**
Bot: **{author(bot)}**

The args block can be useful for customizing tags and works well with the Command Block. Simple echo command that validates if args were provided:

[p]tag add echo {if({args}==):You must provide text to echo.|{args}}

Here’s a tag that uses the default variable blocks as well as the If Block:

[p]tag add startertag Hi, this is an example of a tag.
This tag will now invoke a ping command.
{c:ping}
{delete({args(0)}==delete)}
{embed({
    "title":"The server this was invoked on was {server}.",
    "description":"{if({args}==):You did not provide any arguments for this tag|The arguments provided were: `{args}`}",
    "thumbnail":{"url":"{guild(icon)}"},
    "author":{"name":"{author} invoked this tag.","icon_url":"{author(avatar)}"},
    "color":2105893,
    "footer":{"icon_url":"{author(avatar)}","text":"{target} is the target of this tag."}
})}

TagScriptEngine Blocks

Core Blocks

Assignment Block

class TagScriptEngine.AssignmentBlock[source]

Variables are useful for choosing a value and referencing it later in a tag. Variables can be referenced using brackets as any other block.

Usage: {=(<name>):<value>}

Aliases: assign, let, var

Payload: value

Parameter: name

Examples:

{=(prefix):!}
The prefix here is `{prefix}`.
# The prefix here is `!`.

{assign(day):Monday}
{if({day}==Wednesday):It's Wednesday my dudes!|The day is {day}.}
# The day is Monday.

Random Block

class TagScriptEngine.RandomBlock[source]

Pick a random item from a list of strings, split by either ~ or ,. An optional seed can be provided to the parameter to always choose the same item when using that seed.

Usage: {random([seed]):<list>}

Aliases: #, rand

Payload: list

Parameter: seed, None

Examples:

{random:Carl,Harold,Josh} attempts to pick the lock!
# Possible Outputs:
# Josh attempts to pick the lock!
# Carl attempts to pick the lock!
# Harold attempts to pick the lock!

{=(insults):You're so ugly that you went to the salon and it took 3 hours just to get an estimate.~I'll never forget the first time we met, although I'll keep trying.~You look like a before picture.}
{=(insult):{#:{insults}}}
{insult}
# Assigns a random insult to the insult variable

Math Block

class TagScriptEngine.MathBlock[source]

Range Block

class TagScriptEngine.RangeBlock[source]

The range block picks a random number from a range of numbers seperated by -. The number range is inclusive, so it can pick the starting/ending number as well. Using the rangef block will pick a number to the tenth decimal place.

An optional seed can be provided to the parameter to always choose the same item when using that seed.

Usage: {range([seed]):<lowest-highest>}

Aliases: rangef

Payload: number

Parameter: seed, None

Examples:

Your lucky number is {range:10-30}!
# Your lucky number is 14!
# Your lucky number is 25!

{=(height):{rangef:5-7}}
I am guessing your height is {height}ft.
# I am guessing your height is 5.3ft.

Control Blocks

If Block

class TagScriptEngine.IfBlock[source]

The if block returns a message based on the passed expression to the parameter. An expression is represented by two values compared with an operator.

The payload is a required message that must be split by |. If the expression evaluates true, then the message before the | is returned, else the message after is returned.

Expression Operators:

Operator

Check

Example

Description

==

equality

a==a

value 1 is equal to value 2

!=

inequality

a!=b

value 1 is not equal to value 2

>

greater than

5>3

value 1 is greater than value 2

<

less than

4<8

value 1 is less than value 2

>=

greater than or equality

10>=10

value 1 is greater than or equal to value 2

<=

less than or equality

5<=6

value 1 is less than or equal to value 2

Usage: {if(<expression>):<message>]}

Payload: message

Parameter: expression

Examples:

{if({args}==63):You guessed it! The number I was thinking of was 63!|Too {if({args}<63):low|high}, try again.}
# if args is 63
# You guessed it! The number I was thinking of was 63!

# if args is 73
# Too low, try again.

# if args is 14
# Too high, try again.

Break Block

class TagScriptEngine.BreakBlock[source]

The break block will force the tag output to only be the payload of this block, if the passed expresssion evaluates true. If no message is provided to the payload, the tag output will be empty.

This differs from the StopBlock as the stop block stops all tagscript processing and returns its message while the break block continues to process blocks. If command blocks exist after the break block, they will still execute.

Usage: {break(<expression>):[message]}

Aliases: short, shortcircuit

Payload: message

Parameter: expression

Examples:

{break({args}==):You did not provide any input.}

All Block

class TagScriptEngine.AllBlock[source]

The all block checks that all of the passed expressions are true. Multiple expressions can be passed to the parameter by splitting them with |.

The payload is a required message that must be split by |. If the expression evaluates true, then the message before the | is returned, else the message after is returned.

Usage: {all(<expression|expression|...>):<message>}

Aliases: and

Payload: message

Parameter: expression

Examples:

{all({args}>=100|{args}<=1000):You picked {args}.|You must provide a number between 100 and 1000.}
# if {args} is 52
You must provide a number between 100 and 1000.

# if {args} is 282
You picked 282.

Any Block

class TagScriptEngine.AnyBlock[source]

The any block checks that any of the passed expressions are true. Multiple expressions can be passed to the parameter by splitting them with |.

The payload is a required message that must be split by |. If the expression evaluates true, then the message before the | is returned, else the message after is returned.

Usage: {any(<expression|expression|...>):<message>}

Aliases: or

Payload: message

Parameter: expression

Examples:

{any({args}==hi|{args}==hello|{args}==heyy):Hello {user}!|How rude.}
# if {args} is hi
Hello sravan#0001!

# if {args} is what's up!
How rude.

Fifty-fifty Block

class TagScriptEngine.FiftyFiftyBlock[source]

The fifty-fifty block has a 50% change of returning the payload, and 50% chance of returning null.

Usage: {50:<message>}

Aliases: 5050, ?

Payload: message

Parameter: None

Examples:

I pick {if({5050:.}!=):heads|tails}
# I pick heads

Stop Block

class TagScriptEngine.StopBlock[source]

The stop block stops tag processing if the given parameter is true. If a message is passed to the payload it will return that message.

Usage: {stop(<bool>):[string]}

Aliases: halt, error

Payload: string, None

Parameter: bool

Example:

{stop({args}==):You must provide arguments for this tag.}
# enforces providing arguments for a tag

String Blocks

Replace Block

class TagScriptEngine.ReplaceBlock[source]

The replace block will replace specific characters in a string. The parameter should split by a ,, containing the characters to find before the command and the replacements after.

Usage: {replace(<original,new>):<message>}

Aliases: None

Payload: message

Parameter: original, new

Examples:

{replace(o,i):welcome to the server}
# welcime ti the server

{replace(1,6):{args}}
# if {args} is 1637812
# 6637862

{replace(, ):Test}
# T e s t

URLEncode Block

class TagScriptEngine.URLEncodeBlock[source]

This block will encode a given string into a properly formatted url with non-url compliant characters replaced. Using + as the parameter will replace spaces with + rather than %20.

Usage: {urlencode(["+"]):<string>}

Payload: string

Parameter: “+”, None

Examples:

{urlencode:covid-19 sucks}
# covid-19%20sucks

{urlencode(+):im stuck at home writing docs}
# im+stuck+at+home+writing+docs

# the following tagscript can be used to search up tag blocks
# assume {args} = "command block"
<https://phen-cogs.readthedocs.io/en/latest/search.html?q={urlencode(+):{args}}&check_keywords=yes&area=default>
# <https://phen-cogs.readthedocs.io/en/latest/search.html?q=command+block&check_keywords=yes&area=default>

Miscellaneous Blocks

Strftime Block

class TagScriptEngine.StrfBlock[source]

The strf block converts and formats timestamps based on strftime formatting spec. Two types of timestamps are supported: ISO and epoch. If a timestamp isn’t passed, the current UTC time is used.

Invoking this block with unix will return the current Unix timestamp.

Usage: {strf([timestamp]):<format>}

Aliases: unix

Payload: format, None

Parameter: timestamp

Example:

{strf:%Y-%m-%d}
# 2021-07-11

{strf({user(timestamp)}):%c}
# Fri Jun 29 21:10:28 2018

{strf(1420070400):%A %d, %B %Y}
# Thursday 01, January 2015

{strf(2019-10-09T01:45:00.805000):%H:%M %d-%B-%Y}
# 01:45 09-October-2019

{unix}
# 1629182008

Substring Block

class TagScriptEngine.SubstringBlock[source]

Default Variables

The following blocks will be present and accessable as defaults when running any tag.

Meta Variables

Meta variables reference meta attributes about the tag invocation.

Args Block

class TagScriptEngine.StringAdapter(string: str, *, escape: bool = False)[source]

The {args} block represents the arguments passed after the tag name when invoking a tag. If no parameter is passed, it returns all the text after the invocation name. If an index is passed, it will split the arguments into a list by the given splitter, and return the word at that index. The default splitter is a ” “.

Usage: {args([index]):[splitter]>}

Payload: splitter

Parameter: index

Examples:

In the following examples, assume the tag’s name is argstag and the message content is [p]argstag My dog is cute! Would you like to see a photo?.

{args}
# My dog is cute! Would you like to see a photo?

{args(1)}
# My

{args(2):!}
# Would you like to see a photo?

Uses Block

class TagScriptEngine.IntAdapter(integer: int)[source]

The {uses} block returns the number of times a tag has been used.

Usage: {uses}

Payload: None

Parameter: None

Examples:

{uses}
# 1

Discord Object Variables

These blocks reference Discord objects from the tag invocation context.

Author Block

class TagScriptEngine.MemberAdapter(base)[source]

The {author} block with no parameters returns the tag invoker’s full username and discriminator, but passing the attributes listed below to the block payload will return that attribute instead.

Aliases: user

Usage: {author([attribute])

Payload: None

Parameter: attribute, None

id

The author’s Discord ID.

name

The author’s username.

nick

The author’s nickname, if they have one, else their username.

avatar

A link to the author’s avatar, which can be used in embeds.

discriminator

The author’s discriminator.

created_at

The author’s account creation date.

timestamp

The author’s account creation date as a UTC timestamp.

joined_at

The date the author joined the server.

joinstamp

The author’s join date as a UTC timestamp.

mention

A formatted text that pings the author.

bot

Whether or not the author is a bot.

color

The author’s top role’s color as a hex code.

top_role

The author’s top role.

roleids

A list of the author’s role IDs, split by spaces.

Target Block

The {target} block follows the same usage and has the same attributes as the Author Block, but it defaults to the mentioned user in the tag invocation message if any users are mentioned, or the tag author.

Usage: {target}

Aliases: {member}

Channel Block

class TagScriptEngine.ChannelAdapter(base)[source]

The {channel} block with no parameters returns the channel’s full name but passing the attributes listed below to the block payload will return that attribute instead.

Usage: {channel([attribute])

Payload: None

Parameter: attribute, None

id

The channel’s ID.

name

The channel’s name.

created_at

The channel’s creation date.

timestamp

The channel’s creation date as a UTC timestamp.

nsfw

Whether the channel is nsfw.

mention

A formatted text that pings the channel.

topic

The channel’s topic.

Server Block

class TagScriptEngine.GuildAdapter(base)[source]

The {server} block with no parameters returns the server’s name but passing the attributes listed below to the block payload will return that attribute instead.

Aliases: guild

Usage: {server([attribute])

Payload: None

Parameter: attribute, None

id

The server’s ID.

name

The server’s name.

icon

A link to the server’s icon, which can be used in embeds.

created_at

The server’s creation date.

timestamp

The server’s creation date as a UTC timestamp.

member_count

The server’s member count.

bots

The number of bots in the server.

humans

The number of humans in the server.

description

The server’s description if one is set, or “No description”.

random

A random member from the server.

Parsing Blocks

Parsing blocks interact with the tag invocation and affect the tag’s output in Discord.

Restriction Blocks

The following blocks allow for restriction of tags behind roles or channels, or setting tag cooldowns.

Require Block

class TagScriptEngine.RequireBlock[source]

The require block will attempt to convert the given parameter into a channel or role, using name or ID. If the user running the tag is not in the targeted channel or doesn’t have the targeted role, the tag will stop processing and it will send the response if one is given. Multiple role or channel requirements can be given, and should be split by a “,”.

Usage: {require(<role,channel>):[response]}

Aliases: whitelist

Payload: response, None

Parameter: role, channel

Examples:

{require(Moderator)}
{require(#general, #bot-cmds):This tag can only be run in #general and #bot-cmds.}
{require(757425366209134764, 668713062186090506, 737961895356792882):You aren't allowed to use this tag.}

Blacklist Block

class TagScriptEngine.BlacklistBlock[source]

The blacklist block will attempt to convert the given parameter into a channel or role, using name or ID. If the user running the tag is in the targeted channel or has the targeted role, the tag will stop processing and it will send the response if one is given. Multiple role or channel requirements can be given, and should be split by a “,”.

Usage: {blacklist(<role,channel>):[response]}

Payload: response, None

Parameter: role, channel

Examples:

{blacklist(Muted)}
{blacklist(#support):This tag is not allowed in #support.}
{blacklist(Tag Blacklist, 668713062186090506):You are blacklisted from using tags.}

Cooldown Block

class TagScriptEngine.CooldownBlock[source]

The cooldown block implements cooldowns when running a tag. The parameter requires 2 values to be passed: rate and per integers. The rate is the number of times the tag can be used every per seconds.

The payload requires a key value, which is the key used to store the cooldown. A key should be any string that is unique. If a channel’s ID is passed as a key, the tag’s cooldown will be enforced on that channel. Running the tag in a separate channel would have a different cooldown with the same rate and per values.

The payload also has an optional message value, which is the message to be sent when the cooldown is exceeded. If no message is passed, the default message will be sent instead. The cooldown message supports 2 blocks: key and retry_after.

Usage: {cooldown(<rate>|<per>):<key>|[message]}

Payload: key, message

Parameter: rate, per

Examples:

{cooldown(1|10):{author(id)}}
# the tag author used the tag more than once in 10 seconds
# The bucket for 741074175875088424 has reached its cooldown. Retry in 3.25 seconds."

{cooldown(3|3):{channel(id)}|Slow down! This tag can only be used 3 times per 3 seconds per channel. Try again in **{retry_after}** seconds."}
# the tag was used more than 3 times in 3 seconds in a channel
# Slow down! This tag can only be used 3 times per 3 seconds per channel. Try again in **0.74** seconds.

Message Blocks

Message blocks modify the tag’s output.

Embed Block

class TagScriptEngine.EmbedBlock[source]

An embed block will send an embed in the tag response. There are two ways to use the embed block, either by using properly formatted embed JSON from an embed generator or manually inputting the accepted embed attributes.

JSON

Using JSON to create an embed offers complete embed customization. Multiple embed generators are available online to visualize and generate embed JSON.

Usage: {embed(<json>)}

Payload: None

Parameter: json

Examples:

{embed({"title":"Hello!", "description":"This is a test embed."})}
{embed({
    "title":"Here's a random duck!",
    "image":{"url":"https://random-d.uk/api/randomimg"},
    "color":15194415
})}

Manual

The following embed attributes can be set manually:

  • title

  • description

  • color

  • url

  • thumbnail

  • image

  • footer

  • field - (See below)

Adding a field to an embed requires the payload to be split by |, into either 2 or 3 parts. The first part is the name of the field, the second is the text of the field, and the third optionally specifies whether the field should be inline.

Usage: {embed(<attribute>):<value>}

Payload: value

Parameter: attribute

Examples:

{embed(color):#37b2cb}
{embed(title):Rules}
{embed(description):Follow these rules to ensure a good experience in our server!}
{embed(field):Rule 1|Respect everyone you speak to.|false}
{embed(footer):Thanks for reading!|{guild(icon)}}

Both methods can be combined to create an embed in a tag. The following tagscript uses JSON to create an embed with fields and later set the embed title.

{embed({{"fields":[{"name":"Field 1","value":"field description","inline":false}]})}
{embed(title):my embed title}

Redirect Block

class TagScriptEngine.RedirectBlock[source]

Redirects the tag response to either the given channel, the author’s DMs, or uses a reply based on what is passed to the parameter.

Usage: {redirect(<"dm"|"reply"|channel>)}

Payload: None

Parameter: “dm”, “reply”, channel

Examples:

{redirect(dm)}
{redirect(reply)}
{redirect(#general)}
{redirect(626861902521434160)}

Delete Block

class tags.blocks.DeleteBlock[source]

Delete blocks will delete the invocation message if the given parameter is true. If there is no parameter i.e. {delete} it will default to true.

Usage: {delete([bool])

Payload: None

Parameter: bool, None

Examples:

{delete}
{delete({args(1)}==delete)}

React Block

class tags.blocks.ReactBlock[source]

The react block will react with up to 5 emoji to the tag response message. If the name used is reactu, it will react to the tag invocation instead. The given emoji can be custom or unicode emoji. Emojis can be split with “,”.

The block accepts emojis being passed to the parameter or the payload, but not both.

Usage: {react(<emoji,emoji>):[emoji,emoji]}

Aliases: reactu

Payload: emoji

Parameter: emoji

Examples:

{react(🅱️)}
{react(🍎,🍏)}
{react(<:kappa:754146174843355146>)}
{reactu:🅱️}

Utility Blocks

The following utility blocks extend the power of tags that interface with bot commands.

Command Block

class TagScriptEngine.CommandBlock(limit: int = 3)[source]

Run a command as if the tag invoker had ran it. Only 3 command blocks can be used in a tag.

Usage: {command:<command>}

Aliases: c, com, command

Payload: command

Parameter: None

Examples:

{c:ping}
# invokes ping command

{c:ban {target(id)} Chatflood/spam}
# invokes ban command on the pinged user with the reason as "Chatflood/spam"

Override Block

class TagScriptEngine.OverrideBlock[source]

Override a command’s permission requirements. This can override mod, admin, or general user permission requirements when running commands with the Command Block. Passing no parameter will default to overriding all permissions.

In order to add a tag with the override block, the tag author must have Manage Server permissions.

This will not override bot owner commands or command checks.

Usage: {override(["admin"|"mod"|"permissions"]):[command]}

Payload: command

Parameter: “admin”, “mod”, “permissions”

Examples:

{override}
# overrides all commands and permissions

{override(admin)}
# overrides commands that require the admin role

{override(permissions)}
{override(mod)}
# overrides commands that require the mod role or have user permission requirements

Example Tags

The following tags listed show examples of using tagscript blocks.

Context Variables Example

The following tag shows an example of using the various attributes listed in Default Variables.

[p]tag + introduce Hi {user(nick)}, welcome to **{guild}**!

__**USER BLOCK USAGE**__
Your username is {user(name)}, discriminator is {user(discriminator)}, id is {user(id)}.
Your account was created at {user(created_at)} and you joined {guild(name)} on {user(joined_at)}.
The color for your highest role is {user(color)}.

__**SERVER BLOCK USAGE**__
The id of this server is {server(id)}, and it was created at {server(created_at)}.
*Some stats about the server:*
Member count: {server(member_count)}
Human Count: {server(humans)}
Bot Count: {server(bots)}
Additional Info about Server: {server(description)}

{server(random)} is a just random member of the server you might want to say hi.

__**CHANNEL BLOCK USAGE**__
The channel you are using this tag in is {channel(name)} and channel id is {channel(id)}.
Alternatively you could use this attribute in your tags to jump to other channels {channel(mention)}
The channel was created at {channel(created_at)} and the NSFW status of this channel is: {channel(nsfw)}
__*Channel Topic:*__ {channel(topic)}

Information Storage Example

This simple tag shows how to store repeated/informational text. This tag has often been used in a support server.

[p] tag + ss Please send a screenshot. It’s much easier to figure out your problem if we can see what went wrong.

Command Alias Example

The following tag is a simple example of using a tag to add an alias to a command.

[p]tag add gstart {c:giveaway start {args}}

Tags Owner Configuration

This page details some of the configurability options to Bot owners using the Tags cog.

These settings can be applied with the [p]tagset group command, and viewed with [p]tagset settings.

Custom Blocks

For developers who wish to add custom blocks to the TagScript engine, Tags has built in commands to add blocks without editing the cog.

Start off with the [p]tagset block add <name> <code> command. The code passed must subclass TagScriptEngine.Block and return the subclass. Here’s an example of a block that returns a random duck image

[p]tagset block add duck ```py
import aiohttp

class RandomDuck(tse.Block):
    ACCEPTED_NAMES = ("duck",)

    async def process(self, ctx: tse.Context):
        async with aiohttp.ClientSession() as session:
            async with session.get("https://random-d.uk/api/v2/random") as resp:
                data = await resp.json()
        return data["url"]

return RandomDuck
```

When a user runs a tag with a duck block, it will return a random duck image such as

[p]tag + randomduck {duck}
[p]randomduck
# https://random-d.uk/api/121.jpg

One thing to note in the above example is that the RandomDuck.process method is asynchronous. By default, the Tags interpreter doesn’t support asynchronous blocks, but asynchronous parsing can be enabled as detailed in Asynchronous Interpreter.

Custom blocks can be viewed with [p]tagset block list or [p]tagset block show <block_name>. They can be deleted with [p]tagset block remove <block_name>, and edited by simply re-adding a block with the same name.

Custom Block Environment

The following global scope variables are available when compiling custom block code:

Name

Value

tse

The TagScriptEngine module.

asyncio

The standard library asyncio module.

bot

The bot object.

tags

The Tags cog object.

Asynchronous Interpreter

By default, the Tags interpreter only supports synchronous blocks and methods. However, in order to support custom blocks with asynchronous code and avoid blocking tags, bot owners can enable the asynchronous interpreter with [p]tagset async True. Synchronous blocks will still parse normally through the interpreter.

Dot Parameter

TagScript block parsing can be changed to identify parameters with . rather than (). This “dot-parameter” style parsing is similar to other formatting parsers, such as the one used in CustomCom. Enabling this with [p]tagset dotparam will have the following behavior:

{server.name}
# Red - Discord Bot

# dot parameter disabled
{server(name)}
# Red - Discord Bot

SlashTags

Slash Tags allow you to create custom Discord Slash Commands which harness the power of the TagScriptEngine. If you haven’t already, it’s recommended you also read the Tags page for a general understanding of TagScript blocks.

Tag Creation

Note

[p] is your prefix.

Add a tag using the following command:

[p]slashtag add mytag Hello world!

The bot will then ask for a tag description, for which you can respond with:

Test slash command.

Afterwards, the bot will ask whether you would like to add arguments to the tag. In this example, we won’t be adding any arguments, so reply no:

no

Invoke the slash tag with a /:

/mytag

The bot will then respond with the tag’s tagscript:

Hello world!

Context Variables

Tags come with built-in variable blocks you can access for more information about the invocation context. These are:

  • author

  • channel

  • server

You can see attributes available using these blocks in Default Variables.

Slash Arguments

SlashTags support up to 10 arguments with multiple types, allowing for flexibility and advanced user input handling.

Adding Arguments

Similar to the initial slash tag creation process, adding arguments to slash tags follows an interactive setup. You can either choose to add arguments while creating a slash tag, or by editing them later with [p]slashtag edit arguments <slashtag>.

Argument Types

class slashtags.SlashOptionType(value)[source]

Type

Description

Example

Adapter

String

Accepts any user inputted text as an argument.

{string}

StringAdapter

Integer

Only allows integer input for the argument.

{integer}

IntAdapter

Boolean

Allows either True or False as input.

{boolean}

StringAdapter

User

Refers to a member of the server or a member in the DM channel, accepting username or IDs as input.

{user(name)}

MemberAdapter

Channel

Refers to a text, voice, or category channel in this server, accepting channel names or IDs as input.

{channel(topic)}

ChannelAdapter

Role

Refers to a server role, accepting role name or IDs as input.

{role(id)}

SafeObjectAdapter

Number

Accepts any floating point number.

{number}

StringAdapter

Choices

Offers a list of string choices for the user to pick. Each option has a name and underlying value which is returned as string argument when accessed.

{choice}

StringAdapter

Argument Usage

A slash tag’s argument can be accessed in its tagscript through the use of a variable block. For example, if a slash tag has an argument named member, it could be accessed with {member}.

Additionally, slash tag arguments of the channel, role, or user type support attribute access through the block parameter such as {member(nick)}.

Context Menus

SlashTags also supports adding context menu commands. These can be added with [p]slashtag user or [p]slashtags message. Context menu commands differ from slash commands as they are invoked through the Apps section on a message/user context menu.

You can only add 5 global and 5 server context menu commands for each type.

Context Menu Arguments

Context menu commands do not allow for custom argument creation. They do however have two variables that are automatically accessible in the tagscript:

  • {target_id} - representing the ID of the object context menu that invoked the command

  • {user} - the user that the command was ran on, if a user command was invoked

  • {message} - the message that the command was ran on, if a message command was invoked

Example Slash Tags

The following examples show the capabilities of slash tags.

Command Execution Example

This slash tag adds a /ban command that can be used to ban users.

Arguments:

Name

Description

Type

Required

victim

A member to ban.

member

True

reason

The reason for the ban.

string

False

[p]slashtag add ban {c:ban {victim(id)} {reason}}

Context Menu Example

This slash tag adds a View user info user command that shows user information by invoking the user info command.

Arguments: None

[p]slashtag user "View user info" {c:userinfo {target_id}}

Credits

Thank you to the following users who contributed to this documentation!

  • PhenoM4n4n phenom4n4n

  • sravan sravan#0001

  • Anik aniksarker_21

Indices and tables