Rename mainGuildId to mainServerId, mailGuildId to inboxServerId

The original names (mainGuildId, mailGuildId) are now aliases for
the new option names, so old configs still work after this change.
cshd
Dragory 2020-08-16 23:53:35 +03:00
parent 3f2948bbc1
commit be7f172b62
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
8 changed files with 49 additions and 23 deletions

View File

@ -1,8 +1,8 @@
# Required settings # Required settings
# ----------------- # -----------------
token = REPLACE_WITH_TOKEN token = REPLACE_WITH_TOKEN
mainGuildId = REPLACE_WITH_MAIN_SERVER_ID mainServerId = REPLACE_WITH_MAIN_SERVER_ID
mailGuildId = REPLACE_WITH_INBOX_SERVER_ID inboxServerId = REPLACE_WITH_INBOX_SERVER_ID
logChannelId = REPLACE_WITH_LOG_CHANNEL_ID logChannelId = REPLACE_WITH_LOG_CHANNEL_ID
# Add new options below this line: # Add new options below this line:

View File

@ -22,7 +22,7 @@ vice versa.
## Adding new options ## Adding new options
To add a new option to your `config.ini`, open the file in a text editor such as notepad. To add a new option to your `config.ini`, open the file in a text editor such as notepad.
Each option is put on a new line, and follows the format `option = value`. For example, `mainGuildId = 1234`. Each option is put on a new line, and follows the format `option = value`. For example, `mainServerId = 1234`.
**You need to restart the bot for configuration changes to take effect!** **You need to restart the bot for configuration changes to take effect!**
@ -65,12 +65,12 @@ greetingMessage[] = Fourth line! With an empty line in the middle.
#### token #### token
The bot user's token from [Discord Developer Portal](https://discordapp.com/developers/). The bot user's token from [Discord Developer Portal](https://discordapp.com/developers/).
#### mainGuildId #### mainServerId
**Accepts multiple values** Your server's ID. **Accepts multiple values** Your server's ID.
#### mailGuildId #### inboxServerId
For a two-server setup, the inbox server's ID. For a single-server setup, same as [mainServerId](#mainServerId).
For a single-server setup, same as [mainGuildId](#mainguildid). For a two-server setup, the inbox server's ID.
#### logChannelId #### logChannelId
ID of a channel on the inbox server where logs are posted after a modmail thread is closed ID of a channel on the inbox server where logs are posted after a modmail thread is closed
@ -190,6 +190,12 @@ See ["Permissions" on this page](https://abal.moe/Eris/docs/reference) for suppo
**Default:** `You haven't been a member of the server for long enough to contact modmail.` **Default:** `You haven't been a member of the server for long enough to contact modmail.`
If `requiredTimeOnServer` is set, users that are too new will be sent this message if they try to message modmail. If `requiredTimeOnServer` is set, users that are too new will be sent this message if they try to message modmail.
#### mainGuildId
Alias for [mainServerId](#mainServerId)
#### mailGuildId
Alias for [inboxServerId](#inboxServerId)
#### mentionRole #### mentionRole
**Default:** `here` **Default:** `here`
**Accepts multiple values.** Role that is mentioned when new threads are created or the bot is mentioned. **Accepts multiple values.** Role that is mentioned when new threads are created or the bot is mentioned.
@ -359,7 +365,7 @@ However, there are some differences between `config.ini` and `config.json`.
*See [the example on the Wikipedia page for JSON](https://en.wikipedia.org/wiki/JSON#Example) *See [the example on the Wikipedia page for JSON](https://en.wikipedia.org/wiki/JSON#Example)
for a general overview of the JSON format.* for a general overview of the JSON format.*
* In `config.json`, all text values and IDs need to be wrapped in quotes, e.g. `"mainGuildId": "94882524378968064"` * In `config.json`, all text values and IDs need to be wrapped in quotes, e.g. `"mainServerId": "94882524378968064"`
* In `config.json`, all numbers (other than IDs) are written without quotes, e.g. `"port": 3000` * In `config.json`, all numbers (other than IDs) are written without quotes, e.g. `"port": 3000`
### Toggle options ### Toggle options
@ -400,7 +406,7 @@ being replaced by two underscores and add `MM_` as a prefix. If adding multiple
values with two pipe characters: `||`. values with two pipe characters: `||`.
Examples: Examples:
* `mainGuildId` -> `MM_MAIN_GUILD_ID` * `mainServerId` -> `MM_MAIN_SERVER_ID`
* `commandAliases.mv` -> `MM_COMMAND_ALIASES__MV` * `commandAliases.mv` -> `MM_COMMAND_ALIASES__MV`
* From: * From:
```ini ```ini

View File

@ -25,7 +25,7 @@ In this setup, modmail threads are opened on the main server in a special catego
This is the recommended setup for small and medium sized servers. This is the recommended setup for small and medium sized servers.
1. **Go through the [prerequisites](#prerequisites) above first!** 1. **Go through the [prerequisites](#prerequisites) above first!**
2. Open `config.ini` in a text editor and fill in the required values. `mainGuildId` and `mailGuildId` should both be set to your server's id. 2. Open `config.ini` in a text editor and fill in the required values. `mainServerId` and `inboxServerId` should both be set to your server's id.
3. Invite the bot to the server 3. Invite the bot to the server
4. On a new line at the end of `config.ini`, add `categoryAutomation.newThread = CATEGORY_ID_HERE` 4. On a new line at the end of `config.ini`, add `categoryAutomation.newThread = CATEGORY_ID_HERE`
* Replace `CATEGORY_ID_HERE` with the ID of the category where new modmail threads should go * Replace `CATEGORY_ID_HERE` with the ID of the category where new modmail threads should go
@ -44,8 +44,8 @@ You might also want this setup for privacy concerns*.
1. **Go through the [prerequisites](#prerequisites) above first!** 1. **Go through the [prerequisites](#prerequisites) above first!**
2. Create an inbox server on Discord 2. Create an inbox server on Discord
3. Open `config.ini` in a text editor and fill in the required values 3. Open `config.ini` in a text editor and fill in the required values
* Set `mainGuildId` to the ID of the *main* server where users will message the bot from * Set `mainServerId` to the ID of the *main* server where users will message the bot from
* Set `mailGuildId` to the ID of the *inbox* server created in step 2 * Set `inboxServerId` to the ID of the *inbox* server created in step 2
4. Invite the bot to both the main server and the newly-created inbox server 4. Invite the bot to both the main server and the newly-created inbox server
5. Open `config.ini` in a text editor and fill in the values 5. Open `config.ini` in a text editor and fill in the values
6. Make sure the bot has the `Manage Channels`, `Manage Messages`, and `Attach Files` permissions on the **inbox** server 6. Make sure the bot has the `Manage Channels`, `Manage Messages`, and `Attach Files` permissions on the **inbox** server

View File

@ -102,6 +102,15 @@ for (const [key, value] of Object.entries(config)) {
delete config[key]; delete config[key];
} }
// mainGuildId => mainServerId
// mailGuildId => inboxServerId
if (config.mainGuildId && ! config.mainServerId) {
config.mainServerId = config.mainGuildId;
}
if (config.mailGuildId && ! config.inboxServerId) {
config.inboxServerId = config.mailGuildId;
}
if (! config.dbType) { if (! config.dbType) {
config.dbType = "sqlite"; config.dbType = "sqlite";
} }
@ -117,7 +126,7 @@ if (! config.sqliteOptions) {
// already have something set up in guildGreetings. This retains backwards compatibility while allowing you to override // already have something set up in guildGreetings. This retains backwards compatibility while allowing you to override
// greetings for specific servers in guildGreetings. // greetings for specific servers in guildGreetings.
if (config.greetingMessage || config.greetingAttachment) { if (config.greetingMessage || config.greetingAttachment) {
for (const guildId of config.mainGuildId) { for (const guildId of config.mainServerId) {
if (config.guildGreetings[guildId]) continue; if (config.guildGreetings[guildId]) continue;
config.guildGreetings[guildId] = { config.guildGreetings[guildId] = {
message: config.greetingMessage, message: config.greetingMessage,

View File

@ -1,9 +1,11 @@
/** /**
* @typedef {object} ModmailConfig * @typedef {object} ModmailConfig
* @property {string} [token] * @property {string} [token]
* @property {array} [mainServerId]
* @property {string} [inboxServerId]
* @property {string} [logChannelId]
* @property {array} [mainGuildId] * @property {array} [mainGuildId]
* @property {string} [mailGuildId] * @property {string} [mailGuildId]
* @property {string} [logChannelId]
* @property {string} [prefix="!"] * @property {string} [prefix="!"]
* @property {string} [snippetPrefix="!!"] * @property {string} [snippetPrefix="!!"]
* @property {string} [snippetPrefixAnon="!!!"] * @property {string} [snippetPrefixAnon="!!!"]

View File

@ -46,16 +46,25 @@
"token": { "token": {
"type": "string" "type": "string"
}, },
"mainGuildId": { "mainServerId": {
"$ref": "#/definitions/stringArray" "$ref": "#/definitions/stringArray"
}, },
"mailGuildId": { "inboxServerId": {
"type": "string" "type": "string"
}, },
"logChannelId": { "logChannelId": {
"type": "string" "type": "string"
}, },
"mainGuildId": {
"$comment": "Alias for mainServerId",
"$ref": "#/definitions/stringArray"
},
"mailGuildId": {
"$comment": "Alias for inboxServerId",
"type": "string"
},
"prefix": { "prefix": {
"type": "string", "type": "string",
"default": "!" "default": "!"
@ -323,7 +332,7 @@
"allOf": [ "allOf": [
{ {
"$comment": "Base required values", "$comment": "Base required values",
"required": ["token", "mainGuildId", "mailGuildId", "logChannelId", "dbType"] "required": ["token", "mainServerId", "inboxServerId", "logChannelId", "dbType"]
}, },
{ {
"$comment": "Make attachmentStorageChannelId required if attachmentStorage is set to 'discord'", "$comment": "Make attachmentStorageChannelId required if attachmentStorage is set to 'discord'",

View File

@ -38,8 +38,8 @@ module.exports = {
bot.once("ready", async () => { bot.once("ready", async () => {
console.log("Connected! Waiting for guilds to become available..."); console.log("Connected! Waiting for guilds to become available...");
await Promise.all([ await Promise.all([
...config.mainGuildId.map(id => waitForGuild(id)), ...config.mainServerId.map(id => waitForGuild(id)),
waitForGuild(config.mailGuildId) waitForGuild(config.inboxServerId),
]); ]);
console.log("Initializing..."); console.log("Initializing...");

View File

@ -17,7 +17,7 @@ let logChannel = null;
* @returns {Eris~Guild} * @returns {Eris~Guild}
*/ */
function getInboxGuild() { function getInboxGuild() {
if (! inboxGuild) inboxGuild = bot.guilds.find(g => g.id === config.mailGuildId); if (! inboxGuild) inboxGuild = bot.guilds.find(g => g.id === config.inboxServerId);
if (! inboxGuild) throw new BotError("The bot is not on the modmail (inbox) server!"); if (! inboxGuild) throw new BotError("The bot is not on the modmail (inbox) server!");
return inboxGuild; return inboxGuild;
} }
@ -27,11 +27,11 @@ function getInboxGuild() {
*/ */
function getMainGuilds() { function getMainGuilds() {
if (mainGuilds.length === 0) { if (mainGuilds.length === 0) {
mainGuilds = bot.guilds.filter(g => config.mainGuildId.includes(g.id)); mainGuilds = bot.guilds.filter(g => config.mainServerId.includes(g.id));
} }
if (mainGuilds.length !== config.mainGuildId.length) { if (mainGuilds.length !== config.mainServerId.length) {
if (config.mainGuildId.length === 1) { if (config.mainServerId.length === 1) {
console.warn("[WARN] The bot hasn't joined the main guild!"); console.warn("[WARN] The bot hasn't joined the main guild!");
} else { } else {
console.warn("[WARN] The bot hasn't joined one or more main guilds!"); console.warn("[WARN] The bot hasn't joined one or more main guilds!");