mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-29 14:11:02 +00:00
feat(bots/discord)!: read commit description
FEATURES: - Updated documentation - Improved configuration format - Allow filter overriding for each response config (closes #29) - Improved commands directory structure - Improved slash command reload script - New commands - New command exception handling
This commit is contained in:
@@ -1,59 +1,16 @@
|
||||
# ⚙️ Configuration
|
||||
|
||||
This is the default configuration (provided in [config.ts](../config.ts)):
|
||||
|
||||
```ts
|
||||
export default {
|
||||
owners: ["USER_ID_HERE"],
|
||||
allowedGuilds: ["GUILD_ID_HERE"],
|
||||
messageScan: {
|
||||
channels: ["CHANNEL_ID_HERE"],
|
||||
roles: ["ROLE_ID_HERE"],
|
||||
users: ["USER_ID_HERE"],
|
||||
whitelist: false,
|
||||
humanCorrections: {
|
||||
falsePositiveLabel: "false_positive",
|
||||
allowUsers: ["USER_ID_HERE"],
|
||||
memberRequirements: {
|
||||
permissions: 8n,
|
||||
roles: ["ROLE_ID_HERE"],
|
||||
},
|
||||
},
|
||||
allowedAttachmentMimeTypes: ["image/jpeg", "image/png", "image/webp"],
|
||||
responses: [
|
||||
{
|
||||
triggers: [/^regexp?$/, { label: "label", threshold: 0.85 }],
|
||||
response: {
|
||||
title: "Embed title",
|
||||
description: "Embed description",
|
||||
fields: [
|
||||
{
|
||||
name: "Field name",
|
||||
value: "Field value",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
logLevel: "log",
|
||||
api: {
|
||||
websocketUrl: "ws://127.0.0.1:3000",
|
||||
},
|
||||
} as Config;
|
||||
```
|
||||
|
||||
This may look very overwhelming but configurating it is pretty easy.
|
||||
You will need to copy `config.example.ts` to `config.ts` to be able to start the bot, as it is the default configuration.
|
||||
|
||||
---
|
||||
|
||||
### `config.owners`
|
||||
|
||||
User IDs of the owners of the bot. They'll be able to execute specific commands that others can't and take control of the bot.
|
||||
User IDs of the owners of the bot. Only add owners when needed.
|
||||
|
||||
### `config.allowedGuilds`
|
||||
### `config.guilds`
|
||||
|
||||
Servers the bot is allowed to be and register commands in. The bot will leave servers that are not in this list automatically once detected.
|
||||
Servers the bot is allowed to be and register commands in.
|
||||
|
||||
### `config.logLevel`
|
||||
|
||||
@@ -71,57 +28,14 @@ The possible levels (sorted by their importance descendingly) are:
|
||||
|
||||
### `config.api.websocketUrl`
|
||||
|
||||
The WebSocket URL to connect to (including port).
|
||||
The WebSocket URL to connect to (including port). Soon auto-discovery will be implemented.
|
||||
|
||||
### `config.messageScan`
|
||||
|
||||
Message scan configuration.
|
||||
|
||||
##### `config.messageScan.roles` & `config.messageScan.users` & `config.messageScan.channels`
|
||||
|
||||
Roles, users, and channels which will be affected by the blacklist/whitelist rule.
|
||||
|
||||
##### `config.messageScan.whitelist`
|
||||
|
||||
Whether to use whitelist (`true`) or blacklist (`false`) mode.
|
||||
|
||||
- Blacklist mode **will refuse** to scan messages of any roles or users who **are** in the list above.
|
||||
- Whitelist mode **will refuse** to scan messages of any roles or users who **aren't** in the list above.
|
||||
|
||||
##### `config.messageScan.responses`
|
||||
|
||||
An array containing response configurations. A response can be triggered by multiple ways[^1], which can be specified in the `response.triggers` field.
|
||||
The `response` field contains the embed data that the bot should send. If it is set to `null`, the bot will not send a response or delete the current response if editing.
|
||||
|
||||
> [!NOTE]
|
||||
> If you want only OCR results to match a certain regular expression, you can put them into the `response.ocrTriggers` array.
|
||||
|
||||
```ts
|
||||
{
|
||||
triggers: [
|
||||
/cool regex/i,
|
||||
{
|
||||
label: 'some_label',
|
||||
threshold: 0.8,
|
||||
},
|
||||
],
|
||||
response: {
|
||||
title: 'Embed title',
|
||||
description: 'Embed description',
|
||||
fields: [
|
||||
{
|
||||
name: 'Field name',
|
||||
value: 'Field value',
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
[^1]: Possible triggers are regular expressions or [label configurations](../config.example.ts#68).
|
||||
[Please see the next page.](./2_adding_autoresponses.md)
|
||||
|
||||
## ⏭️ What's next
|
||||
|
||||
The next page will tell you how to run and bundle the bot.
|
||||
The next page will tell you how to configure auto-responses.
|
||||
|
||||
Continue: [🏃🏻♂️ Running the bot](./2_running.md)
|
||||
Continue: [🗣️ Adding auto-responses](./2_adding_autoresponses.md)
|
||||
|
||||
88
bots/discord/docs/2_adding_autoresponses.md
Normal file
88
bots/discord/docs/2_adding_autoresponses.md
Normal file
@@ -0,0 +1,88 @@
|
||||
# 🗣️ Adding auto-responses
|
||||
|
||||
This is referring to `config.messageScan`.
|
||||
|
||||
## 🧱 Filters
|
||||
|
||||
You can add filters to blacklist or whitelist a user from message scanning preventing auto-responses.
|
||||
|
||||
### `filter.roles` & `filter.users` & `filter.channels`
|
||||
|
||||
Roles, users, and channels which will be affected by the blacklist/whitelist rule.
|
||||
|
||||
### `filter.whitelist`
|
||||
|
||||
Whether to use whitelist (`true`) or blacklist (`false`) mode.
|
||||
|
||||
- Blacklist mode **will refuse** to scan messages that match any of the filters above
|
||||
- Whitelist mode **will refuse** to scan messages that match any of the filters above.
|
||||
|
||||
## 💬 Responses
|
||||
|
||||
The `responses` field is array containing response configurations.
|
||||
|
||||
### Adding a message response
|
||||
|
||||
The `responses[n].response` field contains the embed data that the bot should send. If it is set to `null`, the bot will not send a response or delete the current response if editing (useful for catching false positives).
|
||||
|
||||
```ts
|
||||
response: {
|
||||
title: 'Embed title',
|
||||
description: 'Embed description',
|
||||
fields: [
|
||||
{
|
||||
name: 'Field name',
|
||||
value: 'Field value',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
// or if it's a false positive label (for example)
|
||||
response: null
|
||||
```
|
||||
|
||||
### Adding triggers
|
||||
|
||||
A response can be triggered by multiple ways[^1], which can be specified in the `response[n].triggers` object.
|
||||
|
||||
You can add a trigger for text messages which can either be a regular expression, or a label match config (NLP) into the `responses.triggers.text` array.
|
||||
However, if you want **only OCR results** to match a certain regular expression, you can put them into the `response.triggers.image` array instead.
|
||||
|
||||
```ts
|
||||
triggers: {
|
||||
// Text messages
|
||||
text: [
|
||||
/cool regex/i,
|
||||
{
|
||||
label: 'some_label',
|
||||
threshold: 0.8,
|
||||
},
|
||||
],
|
||||
// Text messages with image attachments (OCR results)
|
||||
image: [
|
||||
/image regex/i
|
||||
]
|
||||
},
|
||||
```
|
||||
|
||||
### Override a filter
|
||||
|
||||
You can also override the filter of the current response by supplying the [filter object](#configmessagescanfilter) into the `response.filterOverride` field.
|
||||
|
||||
```ts
|
||||
filterOverride: {
|
||||
// will only respond to members with this role
|
||||
roles: ['ROLE_ID'],
|
||||
// or in this channel
|
||||
channels: ['CHANNEL_ID'],
|
||||
whitelist: true,
|
||||
},
|
||||
```
|
||||
|
||||
[^1]: Possible triggers are regular expressions or [label configurations](../config.example.ts#68).
|
||||
|
||||
## ⏭️ What's next
|
||||
|
||||
The next page will tell you how to run and bundle the bot.
|
||||
|
||||
Continue: [🏃🏻♂️ Running the bot](./3_running.md)
|
||||
@@ -21,4 +21,4 @@ As a workaround, you can zip up the whole project, unzip, and run it in developm
|
||||
|
||||
The next page will tell you how to add commands and listen to events to the bot.
|
||||
|
||||
Continue: [✨ Adding commands and listening to events](./3_commands_and_events.md)
|
||||
Continue: [✨ Adding commands and listening to events](./4_commands_and_events.md)
|
||||
@@ -107,4 +107,4 @@ API events are stored in [`src/events/api`](../src/events/api), and Discord even
|
||||
|
||||
The next page will tell you how to create and interact with a database.
|
||||
|
||||
Continue: [🫙 Storing data](./4_databases.md)
|
||||
Continue: [🫙 Storing data](./5_databases.md)
|
||||
@@ -4,11 +4,12 @@ This documentation explains how to start developing, and how to configure the bo
|
||||
|
||||
## 📖 Table of contents
|
||||
|
||||
0. [🏗️ Set up the development environment (if you haven't already)](../../../docs/0_development_environment.md)
|
||||
0. [🏗️ Set up the development environment (if you haven't already)](../../../docs/0_development_environment.md)
|
||||
1. [⚙️ Configuration](./1_configuration.md)
|
||||
2. [🏃🏻♂️ Running the server](./2_running.md)
|
||||
3. [🗣️ Command and events](./3_commands_and_events.md)
|
||||
4. [🫙 Storing data](./4_databases.md)
|
||||
2. [🗣️ Adding auto-responses](./2_adding_autoresponses.md)
|
||||
3. [🏃🏻♂️ Running the bot](./3_running.md)
|
||||
4. [✨ Command and events](./4_commands_and_events.md)
|
||||
5. [🫙 Storing data](./5_databases.md)
|
||||
|
||||
## ⏭️ Start here
|
||||
|
||||
|
||||
Reference in New Issue
Block a user