Creating Custom Commands with Bender

This is a guide on how custom commands work, what you can do with them and how to create them. If you have suggestions or examples you think should be added to this guide, see #suggestions in Bender's Lair.

The dashboard doesn't currently support custom commands. For the time being, you'll have to create them using the commands in the guide below.

Introduction

There are a few ways in which Bender's custom commands differ from other bots:

  • - Most of the bot's other commands are available as custom command actions, meaning you can do things like changing settings, banning users, searching Google, viewing server info, and more.
  • - It has a robust parameter system ({{ prefix }}cc params) which allows for both required and optional arguments with types (role, user, member, or channel.)
  • - Each of the parameters as mentioned above can be formatted into an ID, mention, user tag, etc. in responses or passed to other commands/actions.
  • - "Silent" commands which don't respond but still have functionality are very easy to create. Simply add your actions without a response ("say" action) at the end.
  • - Commands that respond with an attachment (image manipulation and meme commands) and commands that respond with an embed will pass said embed/attachment to the response ("say" action) automatically, allowing you to combine them with other text commands. For example, you could create a {{ prefix }}fullstats command which shows the output of both {{ prefix }}stats and {{ prefix }}serverinfo in a single response message.

To create a custom command, use {{ prefix }}cc create <name>. For example, {{ prefix }}cc create fullstats.


To create an auto-responder, use {{ prefix }}cc create responder <regex>. For example, {{ prefix }}cc create responder ^no u will respond to all messages starting with "no u". To try out regular expressions (regex), see Regexr.


To view a list of all custom commands on the server, use {{ prefix }}cc list. For details about a specific custom command, use {{ prefix }}cc <name> or {{ prefix }}help <name>, i.e. {{ prefix }}help fullstats.
For auto-responders, you need to find the auto-responder number in {{ prefix }}cc list and use {{ prefix }}cc <number>, i.e. {{ prefix }}cc 1 for auto-responder #1. {{ prefix }}help <number> won't work for auto-responders.



Adding Actions

There are three types of actions you can add: say, wait, and commands. Over 170 commands are available as custom command actions; see
{{ prefix }}help all
for a full list on what can and can't be used.

To add an action to a custom command, use {{ prefix }}cc add <name> <action> [additional arguments]. For example, {{ prefix }}cc add fullstats stats or {{ prefix }}cc add fullstats info server.


To add an action to an auto-responder, use {{ prefix }}cc list to find the number of the auto-responder and use that number in place of a name. For example, for responder #2, you would use {{ prefix }}cc add 2 say You just swore in my Christian server!.


The wait action simply waits a certain number of seconds (between 1 and 60) before continuing to the next action. To add one, use {{ prefix }}cc add <name> wait <seconds>. For example, {{ prefix }}cc add slowbot wait 36.


The say action has a couple special features regarding the channel the message is sent to. To send to a static channel every time, use {{ prefix }}cc add <name> say <channel> <text>. For example, {{ prefix }}cc add staff-suggestion say #private-suggestions A user has a suggestion....

To send to a dynamic channel (which is found using the first argument to the command), use [destination] instead of a channel name.


For example, in a custom command called talk, you could add {{ prefix }}cc add talk say [destination] {1...}. Using {{ prefix }}talk #staff A message for the mods..., the message will be sent to #staff, but the text "#staff" won't be included.
Unlike a static channel, [destination] will fail the command if the user specifies a channel they don't have access to. If no channel is specified for [destination], the action will be skipped. To prevent this, use a required channel parameter (see the parameters section.)


Normal users can only add one say action per custom command/auto-responder. If you have Bender Pro, this limit is increased to 10, allowing you to send different responses to different channels or split a response into multiple messages in the same channel.


Arguments for custom command actions can also include variables such as {1} or {prev} - see the variables section.

Note that some commands, including all from the Image Tools and Memes groups, can only be used once per custom command.


Editing Actions

Actions can be edited in a very similar way as they were added - {{ prefix }}cc replace works the same way as {{ prefix }}cc add with an extra argument for the action number. For example, to change the 3rd action of a custom command called bigban, you could use {{ prefix }}cc replace bigban 3 say #logs New message here.


Note: When replacing an auto-responder action, make sure you use the numbers in the correct order! Mistaking {{ prefix }}cc replace 1 3 ... with {{ prefix }}cc replace 3 1 ... could accidentally break your other responders.



Specifying Permissions

Restrict usage of a custom command or auto-responder to a certain list of roles, Discord permission, or specified role and above (just like using {{ prefix }}perms with a regular command.).

To set permissions for a custom command, use {{ prefix }}cc perms <name> <permission>. For example, {{ prefix }}cc perms fullstats chat-mod+ or for an auto-responder, {{ prefix }}cc perms 1 kick_members.

When a user doesn't have perms to use a custom command, a "You don't have permission..." message is sent if {{ prefix }}config perm-msgs is enabled. When a user doesn't have perms to use an auto-responder (or {{ prefix }}config perm-msgs is disabled), it's simply ignored and has no response.



Channel Whitelist/Blacklist

To restrict a custom command to certain channels or prevent it from being used in others, you can used a whitelist or blacklist respectively.

These options ({{ prefix }}cc whitelist and {{ prefix }}cc blacklist) are mutually exclusive; you can have one or the other (or neither) but not both.

To create a whitelist, use {{ prefix }}cc whitelist <name> <channels>, with <channels> being a list of channels separated by |. For example, {{ prefix }}cc whitelist fullstats #commands | #spam | #shitposting.
{{ prefix }}cc blacklist works the same way; an example using an auto-responder is {{ prefix }}cc blacklist 1 #staff | #staff-commands | #rules.



Parameters

Parameters are used to tell Bender how to parse the command input into channels, roles, etc. for use in actions.
They can only be used in custom commands, not auto-responders.

Use required parameters (<role>, <channel>, <user>, <member>) to force proper usage of your command, failing if it isn't found.


Use optional parameters ([role], [channel], [user], [member]) to parse roles, channels, etc. in a more flexible way, still functioning if they're omitted or can't be resolved.


To add parameters to a custom command, use {{ prefix }}cc params <name> <parameter set>; for example, {{ prefix }}cc params gibrole <member> <role<.


Required and optional arguments can be mixed or matched; for example, <role> [user] <channel> would be a valid parameter set. However, we recommend putting all required arguments first (i.e. <role> <channel> [user]) to avoid confusion and ambiguity.



Variables

Variables are very important for creating most custom commands - they let you use different kinds of text and values in actions.

They can be used in both responses (say actions) and in arguments to other actions. For example, in {{ prefix }}cc add bigtag mentionable {1.mention}, the parsed role mention of the 1st argument is passed to {{ prefix }}mentionable, ensuring that it uses the same role as other actions.


General

{prev} - Result from the previous action, i.e. πŸ“ API Latency: `69ms`
{args} - The arguments from the original command, or all of a responder message.
{p} - The current bot prefix.


Server Information

{server} - The name of the current server. You can also use `guild` for this and the following variables.
{server.id} - ID of the server.
{server.members} - Number of members in the server.
{server.region} - Formatted region of the server, i.e. πŸ‡ΊπŸ‡Έ US (South)
{server.region_id} - Unformatted region of the server, i.e. us-south
{server.icon} - URL of the server icon, if one is set.
{server.owner} - Mentions (pings) the server owner.
{server.owner.tag} - The owner's Discord tag, i.e. Bender#2282
{server.owner.discrim} - The owner's discrim, i.e. 2282
{server.owner.id} - The owner's ID, i.e. 300800171988484096
{server.owner.avatar} - The owner's avatar URL, if they have one.


Command Author & Channel

{author} - Mentions the user that sent the original command.
{author.tag}, {author.discrim}, {author.id}, {author.avatar}, {author.name}, {author.color}
^ These work the same way as the server.owner options above.
{channel} - Clickable name of the channel in which the original command was used.
{channel.name}, {channel.id} - Unclickable (text) name and ID of the channel, respectively.


Unformatted Arguments

Note: These can only be used in custom commands, not auto-responders.

{#} (i.e. {1}, {2}) - An unformatted argument from the original command, from 1 to 9.
{#...} (i.e. {2...}) - Includes an argument (like above) and all text after it.
{...#} (i.e. {...3}) - Includes an argument and all text before it.
{#...#} (i.e. {2...8}) - A range of arguments (inclusive.)
*If the previous was added as a user, member, role, or channel using `;cc params`, it can be formatted using these options:*


Formatted Arguments

Note: These can only be used in custom commands, not auto-responders.

{#.mention} - Clickable user, member, role, or channel mention. This will ping users if Bender has the proper permissions.
{#.id} - User, member role, or channel ID, i.e. 300800171988484096
{#.name} - User, member (nickname or username), role, or channel name, i.e. general
{#.color} - Member or role color, i.e. #FF0000
{#.members} - Role member count, i.e. 24
{#.tag} - User or member tag, i.e. Mark.#9999
{#.discrim} - User or member discriminator, i.e. 9999
{#.avatar} - User or member avatar URL, if they have one.



Enabling/Disabling

To enable or disable your custom command, use {{ prefix }}cc enable <name> or {{ prefix }}cc disable <name> respectively. For example, {{ prefix }}cc enable bigban. As with other subcommands, replace the name with a number for auto-responders.

Before enabling a custom command, make sure it's set up properly; if it includes sensitive actions that normal members shouldn't have access to, set permissions for the command first! Custom command actions bypass Bender's regular permissions system, so it's very important that you configure them properly, especially when using potentially destructive commands such as {{ prefix }}del.



Deleting a Command or Action

To remove an action from a custom command, use {{ prefix }}cc delete <name> <action number> or {{ prefix }}cc remove <name> <action number>. For example, {{ prefix }}cc remove bigban 1.
To delete an entire custom command, use {{ prefix }}cc delete <name> or {{ prefix }}cc remove <name>. For example, {{ prefix }}cc delete bigban.
As with other subcommands, replace the name with a number for auto-responders.

Be careful using this subcommand as well - if you forget a number or put something in the wrong order, you might accidentally delete the whole command or the wrong action.