diff --git a/locales/en.json b/locales/en.json index 171abe2..a87a6a8 100644 --- a/locales/en.json +++ b/locales/en.json @@ -935,8 +935,7 @@ "log-mute-error": "[Ping Protection] Punishment failed: I cannot mute %tag: %e", "log-kick-error": "[Ping Protection] Punishment failed: I cannot kick %tag: %e", "log-action-log-failed": "[Ping Protection] Punishment logging failed: %e", - "log-manual-delete": "All data for <@%u> (%u) has been deleted successfully.", - "log-manual-delete-logs": "[Ping Protection] All data for user with ID %u has been deleted successfully.", + "log-data-deletion": "[Ping Protection] All data for the user with ID %u has been deleted successfully.", "log-automod-keyword-limit": "[Ping Protection] Automod keywords exceed 1000 characters limit. Keywords were truncated.", "punish-log-failed-title": "Punishment failed for user %u", "punish-log-failed-desc": "An error occured while trying to punish the user %m. Please check the bot's permissions and role hierarchy. See the message below for the error.", @@ -951,10 +950,9 @@ "cmd-desc-actions": "View the moderation action history of a user", "cmd-desc-panel": "Admin: Open the user management panel", "cmd-desc-group-list": "Lists protected or whitelisted entities", - "cmd-desc-list-protected": "List all protected users and roles", - "cmd-desc-list-wl": "List all whitelisted roles and channels", + "cmd-desc-list-protected": "List of all the protected users and roles", + "cmd-desc-list-wl": "List of all the whitelisted roles, channels and users", "embed-history-title": "Ping history of %u", - "embed-leaver-warning": "This user left the server at %t. These logs will stay until automatic deletion.", "no-data-found": "No logs found for this user.", "embed-actions-title": "Moderation history of %u", "label-reason": "Reason", @@ -966,23 +964,25 @@ "btn-actions": "Actions history", "btn-delete": "Delete all data (Risky)", "list-protected-title": "Protected Users and Roles", - "list-protected-desc": "View all protected users and roles here. When someone pings one of these protected user(s)/role(s), a warning will be sent. Exceptions are whitelisted roles, and when sent in a whitelisted channel.", - "field-prot-users": "Protected Users", - "field-prot-roles": "Protected Roles", - "list-whitelist-title": "Whitelisted Roles and Channels", + "list-protected-desc": "View all protected users and roles here. When someone pings one of these protected user(s)/role(s), a warning will be sent. Exceptions are when pinged by someone with a whitelisted role/as a whitelisted user or when it's sent in a whitelisted channel.", + "field-protected-users": "Protected Users", + "field-protected-roles": "Protected Roles", + "list-whitelist-title": "Whitelisted Roles, Users and Channels", "list-whitelist-desc": "View all whitelisted roles and channels here. Whitelisted roles will not get a warning for pinging a protected entity, and pings will be ignored in whitelisted channels.", "field-wl-roles": "Whitelisted Roles", "field-wl-channels": "Whitelisted Channels", + "field-wl-users": "Whitelisted Users", "list-none": "None are configured.", "modal-title": "Confirm data deletion for this user", "modal-label": "Confirm data deletion by typing this phrase:", "modal-phrase": "I understand that all data of this user will be deleted and that this action cannot be undone.", "modal-failed": "The phrase you entered is incorrect. Data deletion cancelled.", + "modal-success-data-deletion": "All data for the user <@%u> (%u) has been deleted successfully", "field-quick-history": "Quick history view (Last %w weeks)", "field-quick-desc": "Pings history amount: %p\nModeration actions amount: %m", - "history-disabled": "History logging has been disabled by a bot-configurator.\nAre you (one of) the bot-configurators? You can enable history logging in the \"storage\" tab in the 'ping-protection' module ^^", - "leaver-warning-long": "User left at %d. These logs will stay until automatic deletion.", - "leaver-warning-short": "User left at %d.", + "history-disabled": "History logging has been disabled by a bot-configurator.\nAre you (one of) the bot-configurators? You can enable history logging in the \"Data Storage\" tab in the 'ping-protection' module ^^", + "leaver-warning-long": "This user left the server at %d. These logs will stay until automatic deletion.", + "leaver-warning-short": "This user left the server at %d.", "meme-why": "😐 [Why are you the way that you are?]() - You just pinged yourself..", "meme-played": "🔑 [Congratulations, you played yourself.]()", "meme-spider": "🕷️ [Is this you?]() - You just pinged yourself.", @@ -992,4 +992,4 @@ "no-message-link": "This ping was blocked by AutoMod", "list-entry-text": "%index. **Pinged %target** at %time\n%link" } -} \ No newline at end of file +} diff --git a/modules/ping-protection/commands/ping-protection.js b/modules/ping-protection/commands/ping-protection.js index 71f1eb9..d8ac43c 100644 --- a/modules/ping-protection/commands/ping-protection.js +++ b/modules/ping-protection/commands/ping-protection.js @@ -117,12 +117,12 @@ async function listHandler(interaction, type) { embed.addFields([ { - name: localize('ping-protection', 'field-prot-users'), + name: localize('ping-protection', 'field-protected-users'), value: truncate(usersList, 1024), inline: true }, { - name: localize('ping-protection', 'field-prot-roles'), + name: localize('ping-protection', 'field-protected-roles'), value: truncate(rolesList, 1024), inline: true } @@ -140,6 +140,10 @@ async function listHandler(interaction, type) { ? config.ignoredChannels.map(id => `<#${id}>`).join('\n') : localize('ping-protection', 'list-none'); + const usersList = config.ignoredUsers.length > 0 + ? config.ignoredUsers.map(id => `<@${id}>`).join('\n') + : localize('ping-protection', 'list-none'); + embed.addFields([ { name: localize('ping-protection', 'field-wl-roles'), @@ -148,7 +152,12 @@ async function listHandler(interaction, type) { { name: localize('ping-protection', 'field-wl-channels'), value: truncate(channelsList, 1024), - inline: true } + inline: true }, + { + name: localize('ping-protection', 'field-wl-users'), + value: truncate(usersList, 1024), + inline: true + } ]); } diff --git a/modules/ping-protection/configs/configuration.json b/modules/ping-protection/configs/configuration.json index fb7cf2c..acd5b7d 100644 --- a/modules/ping-protection/configs/configuration.json +++ b/modules/ping-protection/configs/configuration.json @@ -5,19 +5,57 @@ }, "commandsWarnings": { "normal": [ - "/ping-protection user history", - "/ping-protection user actions-history", - "/ping-protection list roles", - "/ping-protection list users", - "/ping-protection list whitelisted" + "/ping-protection user history", + "/ping-protection user actions-history", + "/ping-protection list roles", + "/ping-protection list users", + "/ping-protection list whitelisted" ] }, "description": { "en": "Configure protected users/roles, whitelisted roles/members, ignored channels and the notification message." }, + "categories": [ + { + "id": "protection", + "icon": "fa-solid fa-shield", + "displayName": { + "en": "Protected" + } + }, + { + "id": "whitelisted", + "icon": "fa-solid fa-badge-check", + "displayName": { + "en": "Whitelists" + } + }, + { + "id": "rules", + "icon": "fas fa-gears", + "displayName": { + "en": "Ping rules" + } + }, + { + "id": "automod", + "icon": "far fa-robot", + "displayName": { + "en": "AutoMod settings" + } + }, + { + "id": "messages", + "icon": "fa-duotone fa-regular fa-triangle-exclamation", + "displayName": { + "en": "Warning message" + } + } + ], "content": [ { "name": "protectedRoles", + "category": "protection", "humanName": { "en": "Protected Roles" }, @@ -32,6 +70,7 @@ }, { "name": "protectAllUsersWithProtectedRole", + "category": "protection", "humanName": { "en": "Protect all users with a protected role" }, @@ -45,6 +84,7 @@ }, { "name": "protectedUsers", + "category": "protection", "humanName": { "en": "Protected Users" }, @@ -59,6 +99,7 @@ }, { "name": "ignoredRoles", + "category": "whitelisted", "humanName": { "en": "Whitelisted Roles" }, @@ -73,6 +114,7 @@ }, { "name": "ignoredChannels", + "category": "whitelisted", "humanName": { "en": "Whitelisted Channels" }, @@ -87,6 +129,7 @@ }, { "name": "ignoredUsers", + "category": "whitelisted", "humanName": { "en": "Whitelisted Users" }, @@ -101,6 +144,7 @@ }, { "name": "allowReplyPings", + "category": "rules", "humanName": { "en": "Allow Reply Pings" }, @@ -114,6 +158,7 @@ }, { "name": "selfPingConfiguration", + "category": "rules", "humanName": { "en": "Self-Ping configuration" }, @@ -132,6 +177,7 @@ }, { "name": "enableAutomod", + "category": "automod", "humanName": { "en": "Enable automod" }, @@ -145,6 +191,7 @@ }, { "name": "autoModLogChannel", + "category": "automod", "humanName": { "en": "AutoMod Log Channel" }, @@ -162,20 +209,23 @@ }, { "name": "autoModBlockMessage", + "category": "automod", "humanName": { - "en": "AutoMod custom message for message block" }, + "en": "AutoMod custom message for message block" + }, "description": { "en": "Custom text shown to the user when blocked (Max 150 characters)." }, "type": "string", "maxLength": 150, "default": { - "en": "Protected User Ping: Your message was blocked because you are trying to ping a protected user/role. The content of your message might be sent to a log channel depending on the configuration." + "en": "Your message was blocked because you are trying to ping a protected user/role. The message content might be logged depending on the configuration." }, "dependsOn": "enableAutomod" }, { "name": "pingWarningMessage", + "category": "messages", "humanName": { "en": "Warning Message" }, @@ -220,4 +270,4 @@ } } ] -} +} \ No newline at end of file diff --git a/modules/ping-protection/configs/moderation.json b/modules/ping-protection/configs/moderation.json index 5b08f3f..1c15ed6 100644 --- a/modules/ping-protection/configs/moderation.json +++ b/modules/ping-protection/configs/moderation.json @@ -15,12 +15,12 @@ "configElements": true, "content": [ { - "name": "pingsCountBasic", + "name": "pingsCount", "humanName": { "en": "Pings to trigger moderation" }, "description": { - "en": "The amount of pings required to trigger a moderation action (Uses 'Ping History Retention' timeframe)." + "en": "The amount of pings required to trigger a moderation action." }, "type": "integer", "default": { @@ -33,27 +33,13 @@ "en": "Use a custom timeframe" }, "description": { - "en": "If enabled, you can choose your own custom timeframe and the basic configuration will be ignored." + "en": "If enabled, you can choose your own custom timeframe of days in which the pings must occur to trigger the moderation action." }, "type": "boolean", "default": { "en": false } }, - { - "name": "pingsCountAdvanced", - "humanName": { - "en": "Pings to trigger (Custom Timeframe)" - }, - "description": { - "en": "The amount of pings required in the custom timeframe below." - }, - "type": "integer", - "default": { - "en": 5 - }, - "dependsOn": "useCustomTimeframe" - }, { "name": "timeframeDays", "humanName": { diff --git a/modules/ping-protection/configs/storage.json b/modules/ping-protection/configs/storage.json index 54395ab..995a1ca 100644 --- a/modules/ping-protection/configs/storage.json +++ b/modules/ping-protection/configs/storage.json @@ -6,9 +6,33 @@ "description": { "en": "Configure how long moderation logs and leaver data are kept." }, + "categories": [ + { + "id": "pings", + "icon": "fa-regular fa-clock-rotate-left", + "displayName": { + "en": "Ping History" + } + }, + { + "id": "moderation", + "icon": "fas fa-hammer", + "displayName": { + "en": "Moderation Logs" + } + }, + { + "id": "leavers", + "icon": "fas fa-right-from-bracket", + "displayName": { + "en": "Leaver Data" + } + } + ], "content": [ { "name": "enablePingHistory", + "category": "pings", "humanName": { "en": "Enable Ping History" }, @@ -22,22 +46,24 @@ }, { "name": "pingHistoryRetention", + "category": "pings", "humanName": { "en": "Ping History Retention" }, "description": { - "en": "Decides on how long to keep ping logs. Minimum is 4 weeks (1 month) with a maximum of 24 weeks (6 months). This is the length factor of the 'Basic' punishment timeframe." + "en": "Decides on how long to keep ping logs. Minimum is 4 weeks (1 month) with a maximum of 96 weeks (2 years). This is the length factor of the 'Basic' punishment timeframe." }, "type": "integer", "default": { "en": 12 }, "minValue": "4", - "maxValue": "24", + "maxValue": "96", "dependsOn": "enablePingHistory" }, { "name": "deleteAllPingHistoryAfterTimeframe", + "category": "pings", "humanName": { "en": "Delete all the pings in history after the timeframe?" }, @@ -51,21 +77,23 @@ }, { "name": "modLogRetention", + "category": "moderation", "humanName": { "en": "Moderation Log Retention (Months)" }, "description": { - "en": "How long to keep records of punishments (1-12 Months). This is applied when moderation actions are enabled." + "en": "How long to keep records of punishments (1 - 24 Months). This is applied when moderation actions are enabled." }, "type": "integer", "default": { - "en": 6 + "en": 12 }, "minValue": "1", - "maxValue": "12" + "maxValue": "24" }, { "name": "enableLeaverDataRetention", + "category": "leavers", "humanName": { "en": "Keep user logs after they leave" }, @@ -79,6 +107,7 @@ }, { "name": "leaverRetention", + "category": "leavers", "humanName": { "en": "Leaver Data Retention (Days)" }, diff --git a/modules/ping-protection/events/interactionCreate.js b/modules/ping-protection/events/interactionCreate.js index 05fd99b..042de12 100644 --- a/modules/ping-protection/events/interactionCreate.js +++ b/modules/ping-protection/events/interactionCreate.js @@ -83,7 +83,7 @@ module.exports.run = async function (client, interaction) { if (userInput === requiredPhrase) { await deleteAllUserData(client, userId); await interaction.reply({ - content: `✅ ${localize('ping-protection', 'log-manual-delete', {u: userId})}`, + content: `✅ ${localize('ping-protection', 'modal-success-data-deletion', {u: userId})}`, flags: MessageFlags.Ephemeral }); } else { await interaction.reply({ diff --git a/modules/ping-protection/ping-protection.js b/modules/ping-protection/ping-protection.js index 34b3579..885bfc9 100644 --- a/modules/ping-protection/ping-protection.js +++ b/modules/ping-protection/ping-protection.js @@ -389,7 +389,7 @@ async function deleteAllUserData(client, userId) { await client.models['ping-protection']['LeaverData'].destroy({ where: { userId: userId } }); - client.logger.info(localize('ping-protection', 'log-manual-delete-logs', { + client.logger.info(localize('ping-protection', 'log-data-deletion', { u: userId })); } @@ -441,7 +441,7 @@ async function enforceRetention(client) { } if (storageConfig.modLogRetention) { const modCutoff = new Date(); - modCutoff.setMonth(modCutoff.getMonth() - (storageConfig.modLogRetention || 6)); + modCutoff.setMonth(modCutoff.getMonth() - (storageConfig.modLogRetention || 12)); await client.models['ping-protection']['ModerationLog'].destroy({ where: { createdAt: { [Op.lt]: modCutoff } @@ -597,16 +597,14 @@ async function processPing(client, userId, targetId, isRole, messageUrl, originC for (let i = moderationRules.length - 1; i >= 0; i--) { const rule = moderationRules[i]; - + const retentionWeeks = storageConfig?.pingHistoryRetention || 12; const timeframeDays = rule.useCustomTimeframe ? (rule.timeframeDays || 7) : (retentionWeeks * 7); const pingCount = await getPingCountInWindow(client, userId, timeframeDays); - const requiredCount = rule.useCustomTimeframe - ? rule.pingsCountAdvanced - : rule.pingsCountBasic; + const requiredCount = rule.pingsCount; if (pingCount >= requiredCount) { const oneMinuteAgo = new Date(Date.now() - 60000);