Added some docs

This commit is contained in:
Toastie 2024-12-27 03:22:28 +13:00
parent b80733cf83
commit c2c305317c
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
2 changed files with 205 additions and 0 deletions

41
docs/Commands.md Normal file
View file

@ -0,0 +1,41 @@
# Commands
These are all the commands you can use with the bot. Remember to set up your command permissions after you start the bot up, otherwise everyone will be able to use all commands.
| Command | Description |
|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `/add <user>` | Add a user to the ticket. |
| `/addcategory <title> <category>` | Adds a category for users to open tickets in. The title is what will be used on buttons and in selection menus. |
| `/addmessage <identifier> <message>` | Adds a new message for the `/say` command. The identifier is the word used in the say command and the message is what the bot prints. |
| `/addstaff <user>` | Registers a user as a staff member for ticket assignment. |
| `/assign (user)` | Assigns a ticket to a staff member. Assigns to self if no mention or id is provided. |
| `/blacklist <user>` | Blocks a user from opening tickets. |
| `/close` | Closes a ticket channel. The ticket transcript is optionally sent to the ticket creator. |
| `/createbuttonpanel` | Creates a panel of buttons for users to open tickets with, one for each saved category. |
| `/createselectionbox (placeholder)` | Creates a selection menu for users to open tickets with. Placeholder is the text shown on the selection menu before anything is selected. |
| `/interview restart` | Restarts the interview in the current channel. It will use a new template if one is available. |
| `/interview stop` | Stops the ongoing interview in this channel. |
| `/interviewtemplate get <category>` | Get the json interview template for a specific category. A basic one will be returned if one doesn't exist. |
| `/interviewtemplate set <template>` | Set the interview template for a category. The category is specified by the ID in the template file. |
| `/interviewtemplate delete <category>` | Deletes the interview template for a category. |
| `/list (user)` | Lists a user's open and closed tickets. |
| `/listassigned (user)` | Lists all of a staff member's assigned tickets. |
| `/listinvalid` | Lists tickets which channels have been deleted or the creator has left the server. |
| `/listopen` | Lists a number of the oldest still open tickets, default is 20. Only shows tickets the user has access to read. |
| `/listunassigned` | Lists all unassigned tickets. Only shows tickets the user has access to read. |
| `/move <category>` | Moves a ticket to a specific category by partial name. |
| `/new` | Opens a new ticket channel. |
| `/rassign (role)` | Randomly assigns a ticket to an active staff member. If a role is provided only staff members with that role are considered. |
| `/removecategory <category>` | Removes a category from the bot. |
| `/removemessage <identifier>` | Removes message from the database. |
| `/removestaff <user>` | Removes a user from staff. |
| `/say (identifier)` | Prints a message with information from staff. Use with no arguments to list identifiers. |
| `/setsummary <summary>` | Sets a summary for a ticket which can be viewed using the `/summary` command. |
| `/status` | Shows a status message about the bot with info such as number of tickets and which version is running. |
| `/summary` | Shows some information about a ticket and its summary if set. |
| `/toggleactive (user)` | Toggles whether a staff member counts as active or not when automatic assigning occurs. |
| `/transcript (ticket id)` | Generates a ticket transcript as an html file. |
| `/unassign` | Unassigns a ticket from the currently assigned staff member. |
| `/unblacklist <user>` | Un-blacklists users from opening tickets. |
| `/admin reload` | Reloads the config. |
| `/admin setticket (channel)` | Makes the current channel a ticket. WARNING: Anyone will be able to delete the channel using /close. |
| `/admin unsetticket (ticket id)` | Deletes a ticket from the ticket system without deleting the Discord channel. |

164
docs/InterviewTemplates.md Normal file
View file

@ -0,0 +1,164 @@
# Writing interview templates
The bot can automatically interview users when they open a ticket. These interviews are defined in interview templates.
The templates each apply to a single ticket category so you can have different interviews depending on the type of ticket.
## Interview template commands
Whether you already have a template or not the first step is always to use the `/interviewtemplate get <category>` command on the
ticket category you want to edit. If you haven't yet, use the `/addcategory` command on the category to register it with the bot.
The bot will reply with a JSON template file which you can edit and upload using the `/interviewtemplate set` command.
You can also delete an interview template using the `/interviewtemplate delete` command.
## Writing your first interview template
Use the get command to get a default template for the ticket category you want to edit:
```
/interviewtemplate get <category>
```
The bot will reply with a JSON template file for you to edit using your preferred text editor.
**Note:** It is highly recommended to use integrated template validation in your text editor, see below.
When you are done editing it you can upload it to the bot using the set command:
```
/interviewtemplate set <category>
```
The bot will check that your template is correctly formatted and provide feedback if it is not.
### Automatic validation and suggestions in your text editor
It is highly recommended to use the interview template JSON schema to get live validation of your template while you write it:
#### Guides for different editors:
<details>
<summary>VS Code</summary>
1. Go to `File->Preferences->Settings`.
2. Search for `json schema`.
3. Click `Edit in settings.json` on the schema setting.
4. Set the `json.schemas` property to the following to automatically validate template files:
```json
{
"json.schemas":
[
{
"fileMatch":
[
"interview-template*.json"
],
"url": "https://toastielab.dev/Emotions-stuff/SupportChild/raw/branch/main/Interviews/interview_template.schema.json"
}
]
}
```
5. Open an interview template, you should now get suggestions for things like message types and color names, and error highlighting for any invalid sections.
</details>
<details>
<summary>Jetbrains Editors</summary>
1. Go to `File->Settings->Languages & Frameworks->Schemas->JSON Schema Mapping`.
2. Add a new schema with the following URL: `https://toastielab.dev/Emotions-stuff/SupportChild/raw/branch/main/Interviews/interview_template.schema.json`.
3. Restart your editor and all interview templates should now automatically be set to the correct schema in the bottom right of the window.
</details>
## Interview template format
This section lists all the properties that can be used in an interview template.
If you have set up your editor as suggested above it will handle a lot of this for you automatically.
All templates start with the following properties at the top level:
| Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Required | Description |
|----------------------------------------------------------------------------------------------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------|
| `category-id` | Yes | The id of the category this template applies to. You can change this and re-upload the template to apply it to a different category. |
| `interview` | Yes | Contains the first step of the interview, see below. |
The rest of the template is a series of interview steps, with the following parameters:
| Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Required | Description |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `message` | Yes | The text in the embed message that will be sent to the user when they reach this step. |
| `message-type` | Yes | The type of message, decides what the bot will do when the user gets to this step.<br/>Must be one of: ERROR, END_WITH_SUMMARY, END_WITHOUT_SUMMARY, BUTTONS, TEXT_SELECTOR, USER_SELECTOR, ROLE_SELECTOR,MENTIONABLE_SELECTOR, CHANNEL_SELECTOR, TEXT_INPUT |
| `color` | Yes | Colour of the message embed. |
| `paths` | Yes | One or more interview steps. The name of the step is used as a regex match against the user's answer, except for selection boxes and buttons where each step becomes a button or selection option. |
| `heading` | No | The title of the embed message. |
| `summary-field` | No | |
| `button-style` | No | |
| `selector-description` | No | |
| `selector-placeholder` | No | |
| `max-length` | No | |
| `min-length` | No | |
## Example template
```json
{
"category-id": "1005612326340272169",
"interview":
{
"message": "Are you appealing your own ban or on behalf of another user?",
"message-type": "BUTTONS",
"color": "AQUAMARINE",
"paths":
{
"My own ban":
{
"message": "Please write your appeal below, motivate why you think you should be unbanned.",
"message-type": "TEXT_INPUT",
"color": "CYAN",
"summary-field": "Ban appeal",
"paths":
{
".*":
{
"heading": "Appeal Summary",
"message": "Thank you, a staff member will review your appeal.",
"message-type": "END_WITH_SUMMARY",
"color": "GREEN",
"paths": {}
}
}
},
"Another user's ban":
{
"message": "Whose ban are you appealing?",
"message-type": "USER_SELECTOR",
"color": "CYAN",
"summary-field": "User",
"paths":
{
"<@170904988724232192>":
{
"message": "Not allowed",
"message-type": "ERROR",
"color": "RED",
"paths": {}
},
".*":
{
"message": "What is their role?",
"message-type": "ROLE_SELECTOR",
"color": "CYAN",
"summary-field": "Their Role",
"paths":
{
".*":
{
"message": "Please write the appeal below.",
"message-type": "TEXT_INPUT",
"color": "CYAN",
"summary-field": "Ban appeal",
"paths":
{
".*":
{
"heading": "Appeal Summary",
"message": "Thank you, a staff member will review the appeal.",
"message-type": "END_WITH_SUMMARY",
"color": "GREEN",
"paths": {}
}
}
}
}
}
}
}
}
}
}
```