Welcome to Phen-Cogs’s documentation!
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
argstagand 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
Discord Object Variables
These blocks reference Discord objects from the tag invocation context.
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:
guildUsage:
{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:
whitelistPayload: 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:
rateandperintegers. Therateis the number of times the tag can be used everyperseconds.The payload requires a
keyvalue, 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 samerateandpervalues.The payload also has an optional
messagevalue, 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:keyandretry_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:
titledescriptioncolorurlthumbnailimagefooterfield- (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
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:
reactuPayload: 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, commandPayload: 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 Serverpermissions.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
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
TrueorFalseas 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)}.
Credits
Thank you to the following users who contributed to this documentation!
PhenoM4n4n
phenom4n4nsravan
sravan#0001Anik
aniksarker_21