Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3502113
Added the base module folders and module.json
Dec 11, 2025
9bd863d
Added all folders necessary and the configuration files for each folder
Dec 11, 2025
804ceed
Added a test command
Dec 12, 2025
13733f7
removed the manage file
Dec 12, 2025
88322e3
Added, renamed and deleted some files as necessary and coded the models.
Dec 13, 2025
843ebbd
Renamed action.js to moderation.js, coded multiple things, added a ne…
Dec 13, 2025
225abb7
Forgot to update module.json, now updated aswell
Dec 13, 2025
1602a16
Added additional information in ping-protection.js
Kevinking500 Dec 13, 2025
d285aee
Disabled allowing reply pings, added the enable moderation and enable…
Dec 13, 2025
cdf6f70
Added support for actually correct parameters and those parameters ad…
Dec 13, 2025
0e4cafb
Added proper support for localization, and coded the events
Dec 13, 2025
24dc3b2
Completed the full module and fixed some critical bugs that caused th…
Dec 14, 2025
01660ad
Cleaned up some code notes I used for debugging
Dec 14, 2025
93eb5a3
Completely finished the module and worked tirelessly for many hours t…
Dec 14, 2025
f464555
Debugged absolutely everything, removed like 300 lines of code for po…
Dec 15, 2025
35afa5a
Added the option to lower mod actions history
Dec 15, 2025
9cf2c36
Made the deault value of pings to trigger action 10 instead of 5 in b…
Dec 15, 2025
b5ca02f
Added the commands warnings for most commands
Kevinking500 Dec 15, 2025
edaa5d1
Almost completely rewrote the module to make sure the modules works a…
Dec 17, 2025
84c2634
Merge branch 'main' of github.com:Kevinking500/CustomDCBot
Dec 17, 2025
0b4d87b
Added "automod" abilities - Will now delete the original message by d…
Dec 17, 2025
347b674
(not working correctly) added automod integration and some small changes
Dec 18, 2025
bc3737a
Fixed the
Dec 18, 2025
d1d0271
Removed the feature that didn't work (reposting), adds a custom messa…
Dec 18, 2025
aa79dd4
Fixed the bug of the bot still sending the warning and punishing if l…
Dec 20, 2025
3244371
Added a funny easter egg
Dec 28, 2025
7267711
Added a funny easter egg
Kevinking500 Dec 28, 2025
e310ac8
Some QOL improvements, including merging the list commands
Jan 2, 2026
9e83962
Some QOL improvements, including merging list commands and allowing …
Kevinking500 Jan 2, 2026
b61c31b
Added some new options in the config
Jan 8, 2026
84a1bbc
Added some new options in the config
Kevinking500 Jan 8, 2026
34f3459
Update configuration.json
Kevinking500 Jan 8, 2026
f8427da
Fix self-ping condition to allow self-pinging
Kevinking500 Jan 8, 2026
9e6af40
Update to Discord.js V14 from ScootKit BETA
Kevinking500 Jan 9, 2026
b75f228
New updates from BETA fixes
Kevinking500 Jan 9, 2026
c2d3cad
Ping protection V1, in Discord.JS V14
Jan 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -928,5 +928,57 @@
"nicknames": {
"owner-cannot-be-renamed": "The owner of the server (%u) cannot be renamed.",
"nickname-error": "An error occurred while trying to change the nickname of %u: %e"
}
},
"ping-protection": {
"not-a-member": "Punishment failed: The pinger is not a member.",
"punish-role-error": "Punishment failed: I cannot punish %tag because their role is higher than or equal to my highest role.",
"log-mute-success": "Muted %tag for %dur minutes because they exceeded the ping limit.",
"log-kick-success": "Kicked %tag because they exceeded the ping limit.",
"log-mute-error": "Punishment failed: I cannot mute %tag: %e",
"log-kick-error": "Punishment failed: I cannot kick %tag: %e",
"log-manual-delete": "All data for <@%u> (%u) has been deleted successfully.",
"log-manual-delete-logs": "All data for user with ID %u has been deleted successfully.",
"reason-basic": "User reached %c pings in the last %w weeks.",
"reason-advanced": "User reached %c pings in the last %d days (Custom timeframe).",
"cmd-desc-module": "Ping protection related commands",
"cmd-desc-group-user": "Every command related to the users",
"cmd-desc-history": "View the ping history of a user",
"cmd-opt-user": "The user to check",
"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",
"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",
"actions-retention-note": "Note: Moderation actions are retained for 1 - 12 months based on the configuration.",
"no-permission": "You don't have sufficient permissions to use this command.",
"panel-title": "User Panel: %u",
"panel-description": "Manage and view data for %u (%i). View a quick recap of their ping and moderation history, or delete all data stored for this user (Risky).",
"btn-history": "Ping history",
"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-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",
"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.",
"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.",
"warning-mod-disabled": "⚠️ **Moderation Actions are disabled!**\nYou can enable them in the dashboard under 'Moderation' to start logging punishments automatically."
}
}
206 changes: 206 additions & 0 deletions modules/ping-protection/commands/ping-protection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
const {
fetchModHistory,
getPingCountInWindow,
generateHistoryResponse,
generateActionsResponse
} = require('../ping-protection');
const { localize } = require('../../../src/functions/localize');
const { ActionRowBuilder, ButtonBuilder, EmbedBuilder, ButtonStyle, MessageFlags } = require('discord.js');

module.exports.run = async function (interaction) {
const group = interaction.options.getSubcommandGroup(false);
const sub = interaction.options.getSubcommand(false);

if (group) {
return module.exports.subcommands[group][sub](interaction);
}
return module.exports.subcommands[sub](interaction);
};

// Handles subcommands
module.exports.subcommands = {
'user': {
'history': async function (interaction) {
const user = interaction.options.getUser('user');
const payload = await generateHistoryResponse(interaction.client, user.id, 1);
await interaction.reply(payload);
},
'actions-history': async function (interaction) {
const user = interaction.options.getUser('user');
const payload = await generateActionsResponse(interaction.client, user.id, 1);
await interaction.reply(payload);
},
'panel': async function (interaction) {
const isAdmin = interaction.member.permissions.has('Administrator') ||
(interaction.client.config.admins || []).includes(interaction.user.id);

if (!isAdmin) return interaction.reply({
content: localize('ping-protection', 'no-permission'),
flags: MessageFlags.Ephemeral
});

const user = interaction.options.getUser('user');
const pingerId = user.id;
const storageConfig = interaction.client.configurations['ping-protection']['storage'];
const retentionWeeks = (storageConfig && storageConfig.pingHistoryRetention)
? storageConfig.pingHistoryRetention
: 12;
const timeframeDays = retentionWeeks * 7;

const pingCount = await getPingCountInWindow(interaction.client, pingerId, timeframeDays);
const modData = await fetchModHistory(interaction.client, pingerId, 1, 1000);

const row = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(`ping-protection_history_${user.id}`)
.setLabel(localize('ping-protection', 'btn-history'))
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId(`ping-protection_actions_${user.id}`)
.setLabel(localize('ping-protection', 'btn-actions'))
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId(`ping-protection_delete_${user.id}`)
.setLabel(localize('ping-protection', 'btn-delete'))
.setStyle(ButtonStyle.Danger)
);

const embed = new EmbedBuilder()
.setTitle(localize('ping-protection', 'panel-title', { u: user.tag }))
.setDescription(localize('ping-protection', 'panel-description', { u: user.toString(), i: user.id }))
.setColor('Blue')
.setThumbnail(user.displayAvatarURL({ dynamic: true }))
.addFields([{
name: localize('ping-protection', 'field-quick-history', { w: retentionWeeks }),
value: localize('ping-protection', 'field-quick-desc', { p: pingCount, m: modData.total }),
inline: false
}]);

await interaction.reply({ embeds: [embed.toJSON()], components: [row.toJSON()] });
}
},
'list': {
'protected': async function (interaction) {
await listHandler(interaction, 'protected');
},
'whitelisted': async function (interaction) {
await listHandler(interaction, 'whitelisted');
}
}
};

// Handles list subcommands
async function listHandler(interaction, type) {
const config = interaction.client.configurations['ping-protection']['configuration'];
const embed = new EmbedBuilder()
.setColor('Green')
.setFooter({
text: interaction.client.strings.footer,
iconURL: interaction.client.strings.footerImgUrl
});

if (!interaction.client.strings.disableFooterTimestamp) embed.setTimestamp();

if (type === 'protected') {
embed.setTitle(localize('ping-protection', 'list-protected-title'));
embed.setDescription(localize('ping-protection', 'list-protected-desc'));

const usersList = config.protectedUsers.length > 0
? config.protectedUsers.map(id => `<@${id}>`).join('\n')
: localize('ping-protection', 'list-none');

const rolesList = config.protectedRoles.length > 0
? config.protectedRoles.map(id => `<@&${id}>`).join('\n')
: localize('ping-protection', 'list-none');

embed.addFields([
{ name: localize('ping-protection', 'field-prot-users'), value: usersList, inline: true },
{ name: localize('ping-protection', 'field-prot-roles'), value: rolesList, inline: true }
]);

} else if (type === 'whitelisted') {
embed.setTitle(localize('ping-protection', 'list-whitelist-title'));
embed.setDescription(localize('ping-protection', 'list-whitelist-desc'));

const rolesList = config.ignoredRoles.length > 0
? config.ignoredRoles.map(id => `<@&${id}>`).join('\n')
: localize('ping-protection', 'list-none');

const channelsList = config.ignoredChannels.length > 0
? config.ignoredChannels.map(id => `<#${id}>`).join('\n')
: localize('ping-protection', 'list-none');

embed.addFields([
{ name: localize('ping-protection', 'field-wl-roles'), value: rolesList, inline: true },
{ name: localize('ping-protection', 'field-wl-channels'), value: channelsList, inline: true }
]);
}

await interaction.reply({ embeds: [embed.toJSON()] });
}

module.exports.config = {
name: 'ping-protection',
description: localize('ping-protection', 'cmd-desc-module'),
usage: '/ping-protection',
type: 'slash',
options: [
{
type: 'SUB_COMMAND_GROUP',
name: 'user',
description: localize('ping-protection', 'cmd-desc-group-user'),
options: [
{
type: 'SUB_COMMAND',
name: 'history',
description: localize('ping-protection', 'cmd-desc-history'),
options: [{
type: 'USER',
name: 'user',
description: localize('ping-protection', 'cmd-opt-user'),
required: true
}]
},
{
type: 'SUB_COMMAND',
name: 'actions-history',
description: localize('ping-protection', 'cmd-desc-actions'),
options: [{
type: 'USER',
name: 'user',
description: localize('ping-protection', 'cmd-opt-user'),
required: true
}]
},
{
type: 'SUB_COMMAND',
name: 'panel',
description: localize('ping-protection', 'cmd-desc-panel'),
options: [{
type: 'USER',
name: 'user',
description: localize('ping-protection', 'cmd-opt-user'),
required: true
}]
}
]
},
{
type: 'SUB_COMMAND_GROUP',
name: 'list',
description: localize('ping-protection', 'cmd-desc-group-list'),
options: [
{
type: 'SUB_COMMAND',
name: 'protected',
description: localize('ping-protection', 'cmd-desc-list-protected')
},
{
type: 'SUB_COMMAND',
name: 'whitelisted',
description: localize('ping-protection', 'cmd-desc-list-wl')
}
]
}
]
};
Loading