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
parent
900a14d8a1
commit
4fbf2a1769
|
@ -170,15 +170,7 @@ greetingMessage[] = Remember to read the rules.
|
||||||
```
|
```
|
||||||
|
|
||||||
#### guildGreetings
|
#### guildGreetings
|
||||||
**Default:** *None*
|
Alias for [`serverGreetings`](#serverGreetings)
|
||||||
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.
|
|
||||||
```
|
|
||||||
|
|
||||||
#### ignoreAccidentalThreads
|
#### ignoreAccidentalThreads
|
||||||
**Default:** `off`
|
**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`
|
**Default:** `off`
|
||||||
If enabled, the user's roles will be shown in the modmail thread header
|
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
|
#### smallAttachmentLimit
|
||||||
**Default:** `2097152`
|
**Default:** `2097152`
|
||||||
Size limit of `relaySmallAttachmentsAsAttachments` in bytes (default is 2MB)
|
Size limit of `relaySmallAttachmentsAsAttachments` in bytes (default is 2MB)
|
||||||
|
|
15
src/cfg.js
15
src/cfg.js
|
@ -126,14 +126,19 @@ if (config.categoryAutomation && config.categoryAutomation.newThreadFromGuild &&
|
||||||
config.categoryAutomation.newThreadFromServer = 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
|
// 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
|
// already have something set up in serverGreetings. This retains backwards compatibility while allowing you to override
|
||||||
// greetings for specific servers in guildGreetings.
|
// greetings for specific servers in serverGreetings.
|
||||||
if (config.greetingMessage || config.greetingAttachment) {
|
if (config.greetingMessage || config.greetingAttachment) {
|
||||||
for (const guildId of config.mainServerId) {
|
for (const guildId of config.mainServerId) {
|
||||||
if (config.guildGreetings[guildId]) continue;
|
if (config.serverGreetings[guildId]) continue;
|
||||||
config.guildGreetings[guildId] = {
|
config.serverGreetings[guildId] = {
|
||||||
message: config.greetingMessage,
|
message: config.greetingMessage,
|
||||||
attachment: config.greetingAttachment
|
attachment: config.greetingAttachment
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,7 +34,8 @@
|
||||||
* @property {boolean} [enableGreeting=false]
|
* @property {boolean} [enableGreeting=false]
|
||||||
* @property {string} [greetingMessage]
|
* @property {string} [greetingMessage]
|
||||||
* @property {string} [greetingAttachment]
|
* @property {string} [greetingAttachment]
|
||||||
* @property {*} [guildGreetings={}]
|
* @property {*} [serverGreetings={}]
|
||||||
|
* @property {*} [guildGreetings]
|
||||||
* @property {number} [requiredAccountAge] Required account age to message Modmail, in hours
|
* @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 {string} [accountAgeDeniedMessage="Your Discord account is not old enough to contact modmail."]
|
||||||
* @property {number} [requiredTimeOnServer] Required time on server to message Modmail, in minutes
|
* @property {number} [requiredTimeOnServer] Required time on server to message Modmail, in minutes
|
||||||
|
|
|
@ -175,14 +175,26 @@
|
||||||
"greetingAttachment": {
|
"greetingAttachment": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"guildGreetings": {
|
"serverGreetings": {
|
||||||
"patternProperties": {
|
"patternProperties": {
|
||||||
"^\\d+$": {
|
"^\\d+$": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"message": {
|
||||||
"$ref": "#/definitions/multilineString"
|
"$ref": "#/definitions/multilineString"
|
||||||
|
},
|
||||||
|
"attachment": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"default": {}
|
"default": {}
|
||||||
},
|
},
|
||||||
|
"guildGreetings": {
|
||||||
|
"$comment": "Alias for serverGreetings",
|
||||||
|
"$ref": "#/properties/serverGreetings"
|
||||||
|
},
|
||||||
|
|
||||||
"requiredAccountAge": {
|
"requiredAccountAge": {
|
||||||
"description": "Required account age to message Modmail, in hours",
|
"description": "Required account age to message Modmail, in hours",
|
||||||
|
|
|
@ -7,8 +7,8 @@ module.exports = ({ bot }) => {
|
||||||
if (! config.enableGreeting) return;
|
if (! config.enableGreeting) return;
|
||||||
|
|
||||||
bot.on("guildMemberAdd", (guild, member) => {
|
bot.on("guildMemberAdd", (guild, member) => {
|
||||||
const guildGreeting = config.guildGreetings[guild.id];
|
const serverGreeting = config.serverGreetings[guild.id];
|
||||||
if (! guildGreeting || (! guildGreeting.message && ! guildGreeting.attachment)) return;
|
if (! serverGreeting || (! serverGreeting.message && ! serverGreeting.attachment)) return;
|
||||||
|
|
||||||
function sendGreeting(message, file) {
|
function sendGreeting(message, file) {
|
||||||
bot.getDMChannel(member.id).then(channel => {
|
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) {
|
if (serverGreeting.attachment) {
|
||||||
const filename = path.basename(guildGreeting.attachment);
|
const filename = path.basename(serverGreeting.attachment);
|
||||||
fs.readFile(guildGreeting.attachment, (err, data) => {
|
fs.readFile(serverGreeting.attachment, (err, data) => {
|
||||||
const file = {file: data, name: filename};
|
const file = {file: data, name: filename};
|
||||||
sendGreeting(greetingMessage, file);
|
sendGreeting(greetingMessage, file);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue