Moderation
newTicket
$newTicket
The function $newTicket[] creates a private text channel named ticket-... for the author of the command, optionally inside a category, then sends a welcome message in the new channel and a confirmation to the user.
Syntax
$newTicket[categoryIDorName;noSubjectMessage;inTicketMessage;messageToUser;errorMessage;(ticketNumber);(returnMessageID)]
At least the first 5 arguments are required (they may be empty); a call with fewer than 5 or more than 7 arguments is refused.
Parameters
| Parameter | Description |
|---|---|
categoryIDorName |
Required (may be empty). ID of the category, or name of a category (case-insensitive). Empty creates the channel without a category. An unknown category name is a failure (see errorMessage). |
noSubjectMessage |
Required (may be empty). Text used as the ticket subject when the command was called without any text. |
inTicketMessage |
Required (may be empty). Message sent inside the new ticket channel. Empty means no message is sent in the channel. |
messageToUser |
Required (may be empty). Text added to the response of the command (the confirmation shown to the user). |
errorMessage |
Required (may be empty). Text added to the response if the ticket could not be created. If it is empty, a failure raises an error instead. |
ticketNumber |
Optional. Integer used as the channel name suffix. Empty means no number; any other non-integer value raises Ticket number must be an integer. |
returnMessageID |
Optional. yes/true to return the ID of the message sent in the ticket channel, no/false (default when the argument is absent) to return nothing. Any other value, including an empty one, raises Return message ID must be yes or no. |
In inTicketMessage and in messageToUser, {subject} is replaced by the ticket subject and {channel} by the mention of the new channel (<#id>).
Behavior
- The channel is named
ticket-<suffix>, where the suffix isticketNumberif given, otherwise the author’s username (lowercase; each run of characters other than letters, digits,-and_is replaced by one-, and leading/trailing-are removed), otherwise the author’s ID. - The subject is the content of the command message (
message.content); if it is empty,noSubjectMessageis used. - The bot needs
Manage Channels(the channel is created like$createChannel); a refusal is a creation failure (seeerrorMessage). - Permissions of the channel:
@everyonecannot view it; the author and the bot can view it, send messages and read the history. - If
inTicketMessageis not empty, it is sent in the new channel (the pending response is flushed first). messageToUseris appended to the response of the command.- Returns the ID of the message sent in the ticket channel only when
returnMessageIDisyes/trueandinTicketMessagewas not empty; otherwise it returns an empty string. - The function raises an error if the ticket service or the message output is unavailable.
See also Support Ticket System Guide, $closeTicket, $isTicket and Execution model.
Examples
Create a ticket in a category
$newTicket[Support;No subject given;Hello <@$authorID>, a staff member will help you about: {subject};Your ticket is ready: {channel};Could not create the ticket.]
Without category, with a ticket number
$newTicket[;General request;Welcome to your ticket!;Ticket created: {channel};Ticket creation failed.;42]
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.