Rename categoryAutomation.newThreadFromGuild to categoryAutomation.newThreadFromServer

The original name (categoryAutomation.newThreadFromGuild) is now
an alias for the new option name, so old configs still work after
this change.
cshd
Dragory 2020-08-17 01:04:05 +03:00
parent c177be8920
commit 900a14d8a1
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
4 changed files with 20 additions and 8 deletions

View File

@ -124,16 +124,19 @@ If set, the bot auto-replies to bot mentions (pings) with this message. Use `{us
#### categoryAutomation.newThread
**Default:** *None*
ID of the category where new threads are opened. Also functions as a fallback for `categoryAutomation.newThreadFromGuild`.
ID of the category where new threads are opened. Also functions as a fallback for `categoryAutomation.newThreadFromServer`.
#### categoryAutomation.newThreadFromGuild.GUILDID
#### categoryAutomation.newThreadFromGuild.SERVER_ID
Alias for [`categoryAutomation.newThreadFromServer`](#categoryAutomationNewThreadFromServerServer_id)
#### categoryAutomation.newThreadFromServer.SERVER_ID
**Default:** *None*
When running the bot on multiple main servers, this allows you to specify new thread categories for users from each guild. Example:
When running the bot on multiple main servers, this allows you to specify which category to use for modmail threads from each server. Example:
```ini
# When the user is from the server ID 94882524378968064, their modmail thread will be placed in the category ID 360863035130249235
categoryAutomation.newThreadFromGuild.94882524378968064 = 360863035130249235
categoryAutomation.newThreadFromServer.94882524378968064 = 360863035130249235
# When the user is from the server ID 541484311354933258, their modmail thread will be placed in the category ID 542780020972716042
categoryAutomation.newThreadFromGuild.541484311354933258 = 542780020972716042
categoryAutomation.newThreadFromServer.541484311354933258 = 542780020972716042
```
#### closeMessage

View File

@ -121,6 +121,11 @@ if (! config.sqliteOptions) {
};
}
// categoryAutomation.newThreadFromGuild => categoryAutomation.newThreadFromServer
if (config.categoryAutomation && config.categoryAutomation.newThreadFromGuild && ! config.categoryAutomation.newThreadFromServer) {
config.categoryAutomation.newThreadFromServer = config.categoryAutomation.newThreadFromGuild;
}
// Move greetingMessage/greetingAttachment to the guildGreetings object internally
// Or, in other words, if greetingMessage and/or greetingAttachment is set, it is applied for all servers that don't
// already have something set up in guildGreetings. This retains backwards compatibility while allowing you to override

View File

@ -227,7 +227,7 @@
"newThread": {
"type": "string"
},
"newThreadFromGuild": {
"newThreadFromServer": {
"type": "object",
"patternProperties": {
"^.+$": {
@ -235,6 +235,10 @@
"pattern": "^\\d+$"
}
}
},
"newThreadFromGuild": {
"$comment": "Alias for categoryAutomation.newThreadFromServer",
"$ref": "#/properties/categoryAutomation/properties/newThreadFromServer"
}
},
"default": {}

View File

@ -142,9 +142,9 @@ async function createNewThreadForUser(user, opts = {}) {
// Figure out which category we should place the thread channel in
let newThreadCategoryId = hookResult.categoryId || null;
if (! newThreadCategoryId && config.categoryAutomation.newThreadFromGuild) {
if (! newThreadCategoryId && config.categoryAutomation.newThreadFromServer) {
// Categories for specific source guilds (in case of multiple main guilds)
for (const [guildId, categoryId] of Object.entries(config.categoryAutomation.newThreadFromGuild)) {
for (const [guildId, categoryId] of Object.entries(config.categoryAutomation.newThreadFromServer)) {
if (userGuildData.has(guildId)) {
newThreadCategoryId = categoryId;
break;