Skip to content

Commit cdf6f70

Browse files
Kevinking500Kevinking500
authored andcommitted
Added support for actually correct parameters and those parameters added into the message editor for the warning message
1 parent d285aee commit cdf6f70

File tree

2 files changed

+52
-62
lines changed

2 files changed

+52
-62
lines changed

modules/ping-protection/configs/configuration.json

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,65 +11,39 @@
1111
"content": [
1212
{
1313
"name": "protectedRoles",
14-
"humanName": {
15-
"en": "Protected Roles",
16-
"de": "Geschützte Rollen"
17-
},
18-
"description": {
19-
"en": "Members with these roles will trigger protection when pinged.",
20-
"de": "Mitglieder mit diesen Rollen lösen den Schutz aus."
21-
},
14+
"humanName": { "en": "Protected Roles", "de": "Geschützte Rollen" },
15+
"description": { "en": "Members with these roles will trigger protection when pinged.", "de": "Mitglieder mit diesen Rollen lösen den Schutz aus." },
2216
"type": "array",
2317
"content": "roleID",
2418
"default": { "en": [] }
2519
},
2620
{
2721
"name": "protectedUsers",
28-
"humanName": {
29-
"en": "Protected Users",
30-
"de": "Geschützte Benutzer"
31-
},
32-
"description": {
33-
"en": "Specific users who are protected from pings.",
34-
"de": "Spezifische Benutzer, die geschützt sind."
35-
},
22+
"humanName": { "en": "Protected Users", "de": "Geschützte Benutzer" },
23+
"description": { "en": "Specific users who are protected from pings.", "de": "Spezifische Benutzer, die geschützt sind." },
3624
"type": "array",
3725
"content": "userID",
3826
"default": { "en": [] }
3927
},
4028
{
4129
"name": "ignoredRoles",
42-
"humanName": {
43-
"en": "Whitelisted Roles",
44-
"de": "Erlaubte Rollen"
45-
},
46-
"description": {
47-
"en": "Roles allowed to ping protected members or roles.",
48-
"de": "Rollen, die pingen dürfen."
49-
},
30+
"humanName": { "en": "Whitelisted Roles", "de": "Erlaubte Rollen" },
31+
"description": { "en": "Roles allowed to ping protected members or roles.", "de": "Rollen, die pingen dürfen." },
5032
"type": "array",
5133
"content": "roleID",
5234
"default": { "en": [] }
5335
},
5436
{
5537
"name": "ignoredChannels",
56-
"humanName": {
57-
"en": "Ignored Channels",
58-
"de": "Ignorierte Kanäle"
59-
},
60-
"description": {
61-
"en": "Pings in these channels are ignored.",
62-
"de": "Pings hier werden ignoriert." },
38+
"humanName": { "en": "Ignored Channels", "de": "Ignorierte Kanäle" },
39+
"description": { "en": "Pings in these channels are ignored.", "de": "Pings hier werden ignoriert." },
6340
"type": "array",
6441
"content": "channelID",
6542
"default": { "en": [] }
6643
},
6744
{
6845
"name": "allowReplyPings",
69-
"humanName": {
70-
"en": "Allow Reply Pings",
71-
"de": "Antwort-Pings erlauben"
72-
},
46+
"humanName": { "en": "Allow Reply Pings", "de": "Antwort-Pings erlauben" },
7347
"description": {
7448
"en": "If enabled, replying to a protected user (with mention ON) is allowed.",
7549
"de": "Wenn aktiviert, sind Antworten (mit Mention) an geschützte Benutzer erlaubt."
@@ -79,25 +53,36 @@
7953
},
8054
{
8155
"name": "pingWarningMessage",
82-
"humanName": {
83-
"en": "Warning Message",
84-
"de": "Warnnachricht"
85-
},
56+
"humanName": { "en": "Warning Message", "de": "Warnnachricht" },
8657
"description": {
8758
"en": "The message that gets sent to the user when they ping someone.",
8859
"de": "Die Nachricht, die an den Benutzer gesendet wird."
8960
},
9061
"type": "string",
9162
"allowEmbed": true,
63+
"params": [
64+
{
65+
"name": "target-name",
66+
"description": { "en": "Name of the pinged user/role", "de": "Name des gepingten Benutzers/der Rolle" }
67+
},
68+
{
69+
"name": "target-mention",
70+
"description": { "en": "Mention of the pinged user/role", "de": "Erwähnung des gepingten Benutzers/der Rolle" }
71+
},
72+
{
73+
"name": "target-id",
74+
"description": { "en": "ID of the pinged user/role", "de": "ID des gepingten Benutzers/der Rolle" }
75+
}
76+
],
9277
"default": {
9378
"en": {
94-
"title": "You are not allowed to ping %target_name%!",
95-
"description": "You are not allowed to ping %target_mention% due to your role. You can view which roles/members you are not allowed to ping by using the `/ping protection list roles` or `/ping protection list members`.\n\nIf you were replying, make sure to turn off the mention in the reply.",
79+
"title": "You are not allowed to ping %target-name%!",
80+
"description": "You are not allowed to ping %target-mention% due to your role. You can view which roles/members you are not allowed to ping by using the `/ping protection list roles` or `/ping protection list members`.\n\nIf you were replying, make sure to turn off the mention in the reply.",
9681
"color": "RED"
9782
},
9883
"de": {
99-
"title": "Du darfst %target_name% nicht pingen!",
100-
"description": "Du darfst %target_mention% aufgrund deiner Rolle nicht pingen. Du kannst sehen, welche Rollen/Mitglieder du nicht pingen darfst, indem du `/ping protection list roles` oder `/ping protection list members` benutzt.\n\nFalls du geantwortet hast, stelle sicher, dass die Erwähnung in der Antwort deaktiviert ist.",
84+
"title": "Du darfst %target-name% nicht pingen!",
85+
"description": "Du darfst %target-mention% aufgrund deiner Rolle nicht pingen. Du kannst sehen, welche Rollen/Mitglieder du nicht pingen darfst, indem du `/ping protection list roles` oder `/ping protection list members` benutzt.\n\nFalls du geantwortet hast, stelle sicher, dass die Erwähnung in der Antwort deaktiviert ist.",
10186
"color": "RED"
10287
}
10388
}

modules/ping-protection/ping-protection.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Logic and functions for the Ping Protection module
2+
* Logic for the Ping Protection module
33
* @module ping-protection
44
* @author itskevinnn
55
*/
@@ -51,12 +51,12 @@ async function sendPingWarning(client, message, target, moduleConfig) {
5151
if (!warningMsg) return;
5252

5353
const targetName = target.name || target.tag || target.username || 'Unknown';
54-
5554
const targetMention = target.toString();
5655

5756
const placeholders = {
58-
'%target_name%': targetName,
59-
'%target_mention%': targetMention
57+
'%target-name%': targetName,
58+
'%target-mention%': targetMention,
59+
'%target-id%': target.id
6060
};
6161

6262
const replyOptions = embedType(warningMsg, placeholders);
@@ -97,13 +97,14 @@ async function fetchModHistory(client, userId, limit = 10) {
9797
}
9898

9999
/**
100-
* Executes a punishment and logs it.
100+
* Executes a punishment and optionally logs it.
101101
* @param {Client} client
102102
* @param {GuildMember} member
103103
* @param {Object} actionConfig
104104
* @param {string} reason
105+
* @param {Object} storageConfig
105106
*/
106-
async function executeAction(client, member, actionConfig, reason) {
107+
async function executeAction(client, member, actionConfig, reason, storageConfig) {
107108
const ModLog = client.models['ping-protection']['ModerationLog'];
108109

109110
try {
@@ -112,23 +113,27 @@ async function executeAction(client, member, actionConfig, reason) {
112113

113114
await member.timeout(durationMs, reason);
114115

115-
await ModLog.create({
116-
userId: member.id,
117-
actionType: 'MUTE',
118-
actionDuration: durationMs,
119-
reason: reason
120-
});
116+
if (storageConfig && storageConfig.enableModLogHistory) {
117+
await ModLog.create({
118+
userId: member.id,
119+
actionType: 'MUTE',
120+
actionDuration: durationMs,
121+
reason: reason
122+
});
123+
}
121124
client.logger.info(`[ping-protection] Muted ${member.user.tag} for ${actionConfig.muteDuration} mins. Reason: ${reason}`);
122125

123126
} else if (actionConfig.type === 'KICK') {
124127
await member.kick(reason);
125128

126-
await ModLog.create({
127-
userId: member.id,
128-
actionType: 'KICK',
129-
actionDuration: null,
130-
reason: reason
131-
});
129+
if (storageConfig && storageConfig.enableModLogHistory) {
130+
await ModLog.create({
131+
userId: member.id,
132+
actionType: 'KICK',
133+
actionDuration: null,
134+
reason: reason
135+
});
136+
}
132137
client.logger.info(`[ping-protection] Kicked ${member.user.tag}. Reason: ${reason}`);
133138
}
134139
} catch (error) {
@@ -189,4 +194,4 @@ module.exports = {
189194
getLeaverStatus,
190195
markUserAsLeft,
191196
markUserAsRejoined
192-
};
197+
};

0 commit comments

Comments
 (0)