Skip to content

Commit 488ba6a

Browse files
committed
Allow the use of custom names instead of "System" for system messages
1 parent 40e8a44 commit 488ba6a

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

CONFIG.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,27 @@ Below you can find the default options:
2020

2121
em.systemStaffEnabled = on
2222
em.systemStaffColor = "#1AA4BC"
23+
24+
# Miscellaneous Settings
25+
em.systemName = "System"
2326
```
2427
If you want to change an option, simply copy and paste the corresponding line into your config and change the value.
2528

26-
## Valid values
27-
### Toggles
29+
# Valid values
30+
## Toggles
2831
Any setting that ends in `Enabled` is a toggle.
2932
Like regular on/off settings, these take any truthy or falsy values.
3033
Truthy: `on`, `1`, `true`
3134
Falsy: `off`, `0`, `false`, `null`
3235

33-
### Colors
36+
## Colors
3437
Any option that ends in `Color` takes a color value.
3538
Valid color formats are:
3639
- HEX (e.g. "#7289DA") | These must start with a `#` and be in quotes
37-
- RGB (e.g. 114, 137, 218) | Any three numbers delimited with any non-number
40+
- RGB (e.g. 114, 137, 218) | Any three numbers delimited with any non-number
41+
42+
## Miscellaneous Settings
43+
These all accept different values. All misc. settings and their types are listed here:
44+
### systemName
45+
This accepts any string. Said string will then be used in the embed instead of `System` when a system message is sent.
46+
Setting this to `$botname` will automatically use the Bots username (as it was when the plugin was loaded - later changes are not reflected until the bot restarts).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## A plugin for [Dragory's ModMail](https://github.com/dragory/modmailbot) that changes messages to embeds
2-
**Currently on Version 1.1.1**
2+
**Currently on Version 1.1.2**
33
Plugin written and maintained by [DarkView](https://github.com/DarkView) (Dark#1010 on Discord)
44

55
## Setup

embedMessages.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = async function ({ config, bot, formats }) {
22
const moment = require("moment");
3-
const pluginVersion = "1.1.1";
3+
const pluginVersion = "1.1.2";
44
const KEY = "em";
55
const truthyValues = ["on", "1", "true"];
66
const falsyValues = ["off", "0", "false", "null"];
@@ -99,6 +99,9 @@ module.exports = async function ({ config, bot, formats }) {
9999
SYSTEM_USER_THREAD_COLOR: "systemReplyThreadColor",
100100
SYSTEM_STAFF_ENABLED: "systemStaffEnabled",
101101
SYSTEM_STAFF_COLOR: "systemStaffColor",
102+
103+
// Miscellaneous Settings
104+
CUSTOM_SYSTEM_NAME: "systemName",
102105
});
103106

104107
// Init with defaults
@@ -121,6 +124,9 @@ module.exports = async function ({ config, bot, formats }) {
121124
[SETTING_NAMES.SYSTEM_USER_THREAD_COLOR, parseColor("#5865F2")],
122125
[SETTING_NAMES.SYSTEM_STAFF_ENABLED, true],
123126
[SETTING_NAMES.SYSTEM_STAFF_COLOR, parseColor("#1AA4BC")],
127+
128+
// Miscellaneous Settings
129+
[SETTING_NAMES.CUSTOM_SYSTEM_NAME, "System"],
124130
]);
125131

126132
// Load config settings
@@ -144,9 +150,14 @@ module.exports = async function ({ config, bot, formats }) {
144150
} else {
145151
settings.set(name, parsedColor);
146152
}
153+
} else {
154+
settings.set(name, override);
147155
}
148156
}
149157
}
158+
159+
// Do auto-value checks on boot instead of once every message
160+
const systemName = settings.get(SETTING_NAMES.CUSTOM_SYSTEM_NAME).toLowerCase() === "$botname" ? bot.user.username : settings.get(SETTING_NAMES.CUSTOM_SYSTEM_NAME);
150161

151162
/**
152163
* Returns pfp url for userId
@@ -296,7 +307,7 @@ module.exports = async function ({ config, bot, formats }) {
296307
const embed = { description: threadMessage.body, color: settings.get(SETTING_NAMES.SYSTEM_USER_DM_COLOR) };
297308

298309
embed.author = {
299-
name: "System",
310+
name: systemName,
300311
icon_url: bot.user.avatarURL,
301312
};
302313

@@ -329,7 +340,7 @@ module.exports = async function ({ config, bot, formats }) {
329340
const embed = { description: threadMessage.body, color: settings.get(SETTING_NAMES.SYSTEM_USER_THREAD_COLOR) };
330341

331342
embed.author = {
332-
name: "System",
343+
name: systemName,
333344
icon_url: bot.user.avatarURL,
334345
};
335346

@@ -362,7 +373,7 @@ module.exports = async function ({ config, bot, formats }) {
362373
const embed = { description: threadMessage.body, color: settings.get(SETTING_NAMES.SYSTEM_STAFF_COLOR) };
363374

364375
embed.author = {
365-
name: "System",
376+
name: systemName,
366377
icon_url: bot.user.avatarURL,
367378
};
368379

0 commit comments

Comments
 (0)