Rename guildGreetings to serverGreetings

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

View File

@ -170,15 +170,7 @@ greetingMessage[] = Remember to read the rules.
```
#### guildGreetings
**Default:** *None*
When running the bot on multiple main servers, this allows you to set different greetings for each server. Example:
```ini
guildGreetings.94882524378968064.message = Welcome to server ID 94882524378968064!
guildGreetings.94882524378968064.attachment = greeting.png
guildGreetings.541484311354933258.message[] = Welcome to server ID 541484311354933258!
guildGreetings.541484311354933258.message[] = Second line of the greeting.
```
Alias for [`serverGreetings`](#serverGreetings)
#### ignoreAccidentalThreads
**Default:** `off`
@ -261,6 +253,17 @@ The bot's response to the user when they message the bot and open a new modmail
**Default:** `off`
If enabled, the user's roles will be shown in the modmail thread header
#### serverGreetings
**Default:** *None*
When running the bot on multiple main servers, this allows you to set different greetings for each server. Example:
```ini
serverGreetings.94882524378968064.message = Welcome to server ID 94882524378968064!
serverGreetings.94882524378968064.attachment = greeting.png
serverGreetings.541484311354933258.message[] = Welcome to server ID 541484311354933258!
serverGreetings.541484311354933258.message[] = Second line of the greeting.
```
#### smallAttachmentLimit
**Default:** `2097152`
Size limit of `relaySmallAttachmentsAsAttachments` in bytes (default is 2MB)

View File

@ -126,14 +126,19 @@ if (config.categoryAutomation && config.categoryAutomation.newThreadFromGuild &&
config.categoryAutomation.newThreadFromServer = config.categoryAutomation.newThreadFromGuild;
}
// Move greetingMessage/greetingAttachment to the guildGreetings object internally
// guildGreetings => serverGreetings
if (config.guildGreetings && ! config.serverGreetings) {
config.serverGreetings = config.guildGreetings;
}
// Move greetingMessage/greetingAttachment to the serverGreetings 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
// greetings for specific servers in guildGreetings.
// already have something set up in serverGreetings. This retains backwards compatibility while allowing you to override
// greetings for specific servers in serverGreetings.
if (config.greetingMessage || config.greetingAttachment) {
for (const guildId of config.mainServerId) {
if (config.guildGreetings[guildId]) continue;
config.guildGreetings[guildId] = {
if (config.serverGreetings[guildId]) continue;
config.serverGreetings[guildId] = {
message: config.greetingMessage,
attachment: config.greetingAttachment
};

View File

@ -34,7 +34,8 @@
* @property {boolean} [enableGreeting=false]
* @property {string} [greetingMessage]
* @property {string} [greetingAttachment]
* @property {*} [guildGreetings={}]
* @property {*} [serverGreetings={}]
* @property {*} [guildGreetings]
* @property {number} [requiredAccountAge] Required account age to message Modmail, in hours
* @property {string} [accountAgeDeniedMessage="Your Discord account is not old enough to contact modmail."]
* @property {number} [requiredTimeOnServer] Required time on server to message Modmail, in minutes

View File

@ -175,14 +175,26 @@
"greetingAttachment": {
"type": "string"
},
"guildGreetings": {
"serverGreetings": {
"patternProperties": {
"^\\d+$": {
"type": "object",
"properties": {
"message": {
"$ref": "#/definitions/multilineString"
},
"attachment": {
"type": "string"
}
}
}
},
"default": {}
},
"guildGreetings": {
"$comment": "Alias for serverGreetings",
"$ref": "#/properties/serverGreetings"
},
"requiredAccountAge": {
"description": "Required account age to message Modmail, in hours",

View File

@ -7,8 +7,8 @@ module.exports = ({ bot }) => {
if (! config.enableGreeting) return;
bot.on("guildMemberAdd", (guild, member) => {
const guildGreeting = config.guildGreetings[guild.id];
if (! guildGreeting || (! guildGreeting.message && ! guildGreeting.attachment)) return;
const serverGreeting = config.serverGreetings[guild.id];
if (! serverGreeting || (! serverGreeting.message && ! serverGreeting.attachment)) return;
function sendGreeting(message, file) {
bot.getDMChannel(member.id).then(channel => {
@ -22,11 +22,11 @@ module.exports = ({ bot }) => {
});
}
const greetingMessage = utils.readMultilineConfigValue(guildGreeting.message);
const greetingMessage = utils.readMultilineConfigValue(serverGreeting.message);
if (guildGreeting.attachment) {
const filename = path.basename(guildGreeting.attachment);
fs.readFile(guildGreeting.attachment, (err, data) => {
if (serverGreeting.attachment) {
const filename = path.basename(serverGreeting.attachment);
fs.readFile(serverGreeting.attachment, (err, data) => {
const file = {file: data, name: filename};
sendGreeting(greetingMessage, file);
});