aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-12 20:27:37 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-12 20:27:37 -0400
commitba2d7b7db0a627234ed08de9d6bec8cb675404a7 (patch)
tree9ade9ed549b52eac3f2966a5cee5478267eca7c4 /src/lib
parentcac6abf3efd563b83f8f0ce70ce4bcfa5ada1a27 (diff)
downloadtanzanite-ba2d7b7db0a627234ed08de9d6bec8cb675404a7.tar.gz
tanzanite-ba2d7b7db0a627234ed08de9d6bec8cb675404a7.tar.bz2
tanzanite-ba2d7b7db0a627234ed08de9d6bec8cb675404a7.zip
revamp automod, refactoring, fixes
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/badlinks.ts410
-rw-r--r--src/lib/badwords.ts242
-rw-r--r--src/lib/common/autoMod.ts236
-rw-r--r--src/lib/common/moderation.ts181
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts361
-rw-r--r--src/lib/extensions/discord.js/BushGuild.ts22
-rw-r--r--src/lib/extensions/discord.js/BushGuildMember.ts25
-rw-r--r--src/lib/models/Guild.ts25
8 files changed, 1211 insertions, 291 deletions
diff --git a/src/lib/badlinks.ts b/src/lib/badlinks.ts
new file mode 100644
index 0000000..67f9679
--- /dev/null
+++ b/src/lib/badlinks.ts
@@ -0,0 +1,410 @@
+/* Links in this file are treated as severity 3 offences.
+
+made in part possible by https://github.com/nacrt/SkyblockClient-REPO/blob/main/files/scamlinks.json */
+export default [
+ "acercup.com",
+ "affix-cup.ru",
+ "affix-sport.ru",
+ "airdrops.tips",
+ "aladdinhub.fun",
+ "allskinz.xyz",
+ "ano-skinspin.xyz",
+ "anomalygiveaways.pro",
+ "anomalyknifes.xyz",
+ "anomalyskin.xyz",
+ "anomalyskinz.xyz",
+ "anoskinzz.xyz",
+ "berrygamble.com",
+ "bit-skins.ru",
+ "bitknife.xyz",
+ "bitskines.ru",
+ "casefire.fun",
+ "challengeme.in",
+ "challengeme.vip",
+ "challengme.ru",
+ "cloud9team.space",
+ "cmepure.com",
+ "cmskillcup.com",
+ "counterpaid.xyz",
+ "counterspin.top",
+ "counterstrikegift.xyz",
+ "cs-beast.xyz",
+ "cs-lucky.xyz",
+ "cs-pill.xyz",
+ "cs-prizeskins.xyz",
+ "cs-prizeskinz.xyz",
+ "cs-simpleroll.xyz",
+ "cs-skinz.xyz",
+ "cs-smoke.xyz",
+ "cs-spinz.xyz",
+ "cs-victory.xyz",
+ "csallskin.xyz",
+ "csbuyskins.in",
+ "cscoat.eu",
+ "csgo-analyst.com",
+ "csgo-cash.eu",
+ "csgo-gifts.com",
+ "csgo-market.ru.com",
+ "csgo-market.ru.com",
+ "csgo-steamanalyst.net",
+ "csgo-swapskin.com",
+ "csgo-trade.net",
+ "csgo-up.com",
+ "csgobeats.com",
+ "csgobelieve.ru",
+ "csgocase.one",
+ "csgocashs.com",
+ "csgocheck.ru.com",
+ "csgocheck.ru",
+ "csgocompetive.com",
+ "csgocupp.ru.com",
+ "csgocybersport.ru.com",
+ "csgodetails.info",
+ "csgodreamer.com",
+ "csgodrs.com",
+ "csgoeasywin.ru.com",
+ "csgoelite.xyz",
+ "csgoencup.com",
+ "csgoevent.xyz",
+ "csgogift49.xyz",
+ "csgoindex.ru.com",
+ "csgoindex.ru",
+ "csgoitemdetails.com",
+ "csgoitemsprices.com",
+ "csgoko.tk",
+ "csgomarble.xyz",
+ "csgomarketplace.net",
+ "csgomarkets.net",
+ "csgoorun.ru",
+ "csgoprocupgo.com",
+ "csgorcup.com",
+ "csgorose.com",
+ "csgoroyalskins1.com",
+ "csgoskill.ru",
+ "csgoskinprices.com",
+ "csgoskinsinfo.com",
+ "csgoskinsroll.com",
+ "csgosteamanalysis.com",
+ "csgosteamanalyst.ru",
+ "csgoteammate.gq",
+ "csgothunby.com",
+ "csgotrades.net",
+ "csgovip.ru",
+ "csgoxgiveaway.ru",
+ "csgozone.net.in",
+ "csgunskins.xyz",
+ "csmoneyskinz.xyz",
+ "csmvcecup.com",
+ "csprices.in",
+ "csskill.com",
+ "csskillpro.xyz",
+ "csskinz.xyz",
+ "cstournament.ru",
+ "csxrnoney.com",
+ "cybergamearena.ru",
+ "d2cups.com",
+ "d2faceit.com",
+ "deamonbets.ru",
+ "demonbets.ru",
+ "denforapasi.cf",
+ "diablobets.com",
+ "dicksod.co",
+ "dicsord.gifts",
+ "dicsord.net",
+ "dicsord.net",
+ "dirscod.com",
+ "dirscod.gift",
+ "discocrd.gift",
+ "discod.gift",
+ "discod.info",
+ "discorb.co",
+ "discorb.ru.com",
+ "discorcl-app.com",
+ "discorcl-gift.xyz",
+ "discorcl.click",
+ "discorcl.link",
+ "discorclapp.com",
+ "discord-accept.com",
+ "discord-airdrop.com",
+ "discord-app.me",
+ "discord-app.net",
+ "discord-app.ru.com",
+ "discord-cpp.com",
+ "discord-gifts.com",
+ "discord-give.com",
+ "discord-halloween.ru",
+ "discord-nitro.click",
+ "discord-nitro.gifts",
+ "discord-nitro.link",
+ "discord.blog",
+ "discord.givaewey.com",
+ "discord.giveawey.com",
+ "discord.moscow",
+ "discord.shop",
+ "discordapp.click",
+ "discordgift.info",
+ "discordgift.ru.com",
+ "discordgivenitro.com",
+ "discordglfts.com",
+ "discordnitrogift.ru",
+ "discords-nitroapp.xyz",
+ "discordsteams.com",
+ "discrod.gift",
+ "discrod.gifts",
+ "discrodnitro.org",
+ "diskord.ru.com",
+ "disrcod.com",
+ "dlscord-app.com",
+ "dlscord-nitro.link",
+ "dlscord.app",
+ "dlscord.info",
+ "dlscord.online",
+ "dlscord.org",
+ "dlscord.press",
+ "dlscord.store",
+ "dlscord.wiki",
+ "dlscord.world",
+ "doatgiveaway.top",
+ "dopeskins.com",
+ "dota2fight.net",
+ "dota2fight.ru",
+ "dota2giveaway.top",
+ "dota2giveaways.top",
+ "dotafights.vip",
+ "dotagiveaway.win",
+ "dragon-up.online",
+ "drop-key.ru",
+ "dsicord.gift",
+ "earnskinz.xyz",
+ "emeraldbets.ru",
+ "eplcups.com",
+ "esea-mdl.com",
+ "esportgaming.ru",
+ "event-games4roll.com",
+ "exchangeuritems.gq",
+ "extraskinscs.xyz",
+ "ezwin24.ru",
+ "facecup.fun",
+ "faceiteasyleague.ru",
+ "fatown.net",
+ "fineleague.fun",
+ "fireopencase.com",
+ "fivetown.net",
+ "free-nitlross.ru",
+ "free-nitro.ru",
+ "free-nitros.ru",
+ "free-skins.ru",
+ "freenitroi.ru",
+ "freenitros.ru",
+ "g2-give.ru",
+ "g2-give.ru",
+ "game4roll.com",
+ "gameluck.ru",
+ "gamerich.xyz",
+ "games-roll.ga",
+ "games-roll.ml",
+ "games-roll.ru",
+ "get-nitro.net",
+ "gift4keys.com",
+ "giftsdiscord.ru",
+ "giveavvay.com",
+ "giveawayskin.com",
+ "glets-nitro.com",
+ "global-skins.gq",
+ "globalcsskins.xyz",
+ "globalskins.tk",
+ "go.rancah.com",
+ "goldendota.com",
+ "goodskins.gq",
+ "gosteamanalyst.com",
+ "gtakey.ru",
+ "hellgiveaway.trade",
+ "hellstores.xyz",
+ "hltvcsgo.com",
+ "hltvgames.net",
+ "iemcup.com",
+ "keydorp.me",
+ "keys-loot.com",
+ "knifespin.top",
+ "knifespin.top",
+ "knifespin.xyz",
+ "knifespins.xyz",
+ "knifez-roll.xyz",
+ "knifez-win.xyz",
+ "league-csgo.com",
+ "lehatop-01.ru",
+ "lootxmarket.com",
+ "loungeztrade.com",
+ "lucky-skins.xyz",
+ "made-nitro.com",
+ "makson-gta.ru",
+ "maxskins.xyz",
+ "mvcsgo.com",
+ "mvpcup.ru",
+ "mvptournament.com",
+ "mygames4roll.com",
+ "naviback.ru",
+ "night-skins.com",
+ "nitro-discord.org",
+ "nitros-gift.com",
+ "nwgwroqr.ru",
+ "oligarph.club",
+ "ownerbets.com",
+ "playerskinz.xyz",
+ "pubggift62.xyz",
+ "rangskins.com",
+ "rave-new.ru",
+ "roll-skins.ru",
+ "roll4knife.xyz",
+ "roll4tune.com",
+ "rollknfez.xyz",
+ "rollskin-simple.xyz",
+ "rushbskins.xyz",
+ "rushskins.xyz",
+ "s1mple-spin.xyz",
+ "sakuralive.ru.com",
+ "scale-navi.pp.ru",
+ "simple-knifez.xyz",
+ "simple-win.xyz",
+ "simplegamepro.ru",
+ "simpleroll-cs.xyz",
+ "simplespinz.xyz",
+ "simplewinz.xyz",
+ "skin-index.com",
+ "skin888trade.com",
+ "skincs-spin.top",
+ "skincs-spin.xyz",
+ "skinmarkets.net",
+ "skins-hub.top",
+ "skins-info.net",
+ "skins-jungle.xyz",
+ "skinsboost.ru",
+ "skinsdatabse.com",
+ "skinsind.com",
+ "skinsmind.ru",
+ "skinspace.ru",
+ "skinsplane.com",
+ "skinsplanes.com",
+ "skinsplanets.com",
+ "skinxinfo.net",
+ "skinxmarket.site",
+ "skinz-spin.top",
+ "skinz-spin.xyz",
+ "skinzjar.ru",
+ "skinzprize.xyz",
+ "skinzspin-cs.xyz",
+ "skinzspinz.xyz",
+ "sleanmconmunltiy.ru",
+ "spin-games.com",
+ "spin4skinzcs.top",
+ "spin4skinzcs.xyz",
+ "spinforskin.ml",
+ "sponsored-simple.xyz",
+ "staemcomnrnunitiy.ru.com",
+ "staemcomrnunity.store",
+ "staermcrommunity.me",
+ "staffstatsgo.com",
+ "starrygamble.com",
+ "stat-csgo.ru",
+ "stats-cs.ru",
+ "stceamcomminity.com",
+ "steam-analyst.ru",
+ "steam-nitro.ru",
+ "steam-trades.icu",
+ "steamanalysts.com",
+ "steamcomcunity.ru",
+ "steamcomminutiu.ru",
+ "steamcomminutiy.ru",
+ "steamcomminuty.com",
+ "steamcomminytiu.com",
+ "steamcomminytiu.ru",
+ "steamcomminytu.ru",
+ "steamcommnunily.com",
+ "steamcommnuninty.com",
+ "steamcommnuntiy.com",
+ "steamcommrutiny.ru",
+ "steamcommuniiy.ru",
+ "steamcommunily.uno",
+ "steamcommunitiyu.com",
+ "steamcommunitlu.com",
+ "steamcommunity.link",
+ "steamcommunityu.com",
+ "steamcommunityu.ru",
+ "steamcommunityw.com",
+ "steamcommunlty.pro",
+ "steamcommunrlity.com",
+ "steamcommunutiy.com",
+ "steamcommunytiu.ru",
+ "steamcommunytu.ru",
+ "steamcommutiny.com",
+ "steamcommynitu.ru",
+ "steamcomnmuituy.com",
+ "steamcomnumity.ru",
+ "steamcomrnunity.ru",
+ "steamcomrrnunity.com",
+ "steamcomrunity.com",
+ "steamcomuniity.ru.com",
+ "steamconmunlty.com",
+ "steamcormmuntiy.com",
+ "steamcornminuty.com",
+ "steamgamesroll.ru",
+ "steamncommuniity.com",
+ "steamncommunity.com",
+ "steamnitro.com",
+ "steamnmcomunnity.co",
+ "steamoemmunity.com",
+ "steamsupportpowered.icu",
+ "steancommunity.link",
+ "steancommynity.ru.com",
+ "steancomnunytu.ru",
+ "steancomunnity.ru",
+ "steancomunyiti.ru",
+ "stearmcommunnitty.online",
+ "stearmmcomunitty.ru",
+ "stearmmcomunity.ru",
+ "stearmmcomuunity.ru",
+ "stearncomminuty.ru",
+ "stearncommunity.ru",
+ "stearncommunytiy.ru",
+ "stearncommuty.com",
+ "stearncormmunity.com",
+ "steemcommnunity.ru",
+ "stemcommunnilty.com",
+ "stemcornmunity.ru",
+ "stermccommunitty.ru",
+ "stermcommuniity.com",
+ "stermcommunnitty.ru",
+ "stewie2k-giveaway-150days.pro",
+ "stiemcommunitty.ru",
+ "stmeacomunnitty.ru",
+ "store-stempowered.com",
+ "streamcommulinty.com",
+ "streamcommuninnity.com",
+ "streamcommuunnity.com",
+ "streamcomnumity.ru",
+ "streamcomunity.com",
+ "streammcomunnity.ru",
+ "streancommunuty.ru",
+ "streancommunuty.ru",
+ "strearmcommunity.ru",
+ "strearmcomunity.ru",
+ "sunnygamble.com",
+ "swapskins.live",
+ "test-domuin2.com",
+ "test-domuin3.ru",
+ "test-domuin4.ru",
+ "test-domuin5.ru",
+ "tf2market.store",
+ "tournamentt.com",
+ "ultimateskins.xyz",
+ "ultracup.fun",
+ "uspringcup.com",
+ "waterbets.ru",
+ "win-skin.top",
+ "win-skin.xyz",
+ "winknifespin.xyz",
+ "winskin-simple.xyz",
+ "winskins.top",
+ "wintheskin.xyz",
+ "xgamercup.com",
+];
diff --git a/src/lib/badwords.ts b/src/lib/badwords.ts
new file mode 100644
index 0000000..c5fbf2d
--- /dev/null
+++ b/src/lib/badwords.ts
@@ -0,0 +1,242 @@
+import { BadWords, Severity } from "./common/automod";
+
+export default {
+ /* -------------------------------------------------------------------------- */
+ /* Slurs */
+ /* -------------------------------------------------------------------------- */
+ "faggot": {
+ severity: Severity.TEMP_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "racial slur",
+ },
+ "nigga": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "racial slur",
+ },
+ "nigger": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "racial slur",
+ },
+ "nigra": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "racial slur",
+ },
+ "retard": {
+ severity: Severity.TEMP_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "ableist slur",
+ },
+ "retarted": {
+ severity: Severity.TEMP_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "ableist slur",
+ },
+ "slut": {
+ severity: Severity.WARN,
+ ignoreSpaces: false,
+ ignoreCapitalization: true,
+ reason: "derogatory term",
+ },
+ "tar baby": {
+ severity: Severity.TEMP_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "racial slur",
+ },
+ "whore": {
+ severity: Severity.WARN,
+ ignoreSpaces: false,
+ ignoreCapitalization: true,
+ reason: "derogatory term",
+ },
+ "卍": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "racist symbol",
+ },
+
+ /* -------------------------------------------------------------------------- */
+ /* Steam Scams */
+ /* -------------------------------------------------------------------------- */
+ 'Я в тильте, в кс дали статус "Ненадежный"': {
+ //? I'm on tilt, in the cop they gave the status "Unreliable"
+ severity: Severity.WARN,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "steam scam phrase",
+ },
+ "hello i am leaving cs:go": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "steam scam phrase",
+ },
+ "hello! I'm done with csgo": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "steam scam phrase",
+ },
+ "hi bro, i'm leaving this fucking game, take my skin": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "steam scam phrase",
+ },
+ "hi friend, today i am leaving this fucking game": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "steam scam phrase",
+ },
+ "hi guys, i'm leaving this fucking game, take my": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "steam scam phrase",
+ },
+ "hi, bro h am leaving cs:go and giving away my skin": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "steam scam phrase",
+ },
+ "hi, bro i am leaving cs:go and giving away my skin": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "steam scam phrase",
+ },
+ "i confirm all exchanges, there won't be enough": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "steam scam phrase",
+ },
+ "i quit csgo": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "steam scam phrase",
+ },
+ "the first three who send a trade": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "steam scam phrase",
+ },
+ "you can choose any skin for yourself": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "steam scam phrase",
+ },
+
+ /* -------------------------------------------------------------------------- */
+ /* Nitro Scams */
+ /* -------------------------------------------------------------------------- */
+ "and there is discord hallween's giveaway": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "discord nitro scam phrase",
+ },
+ "discord nitro for free - steam store": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "discord nitro scam phrase",
+ },
+ "free 3 months of discord nitro": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "discord nitro scam phrase",
+ },
+ "free discord nitro airdrop": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "discord nitro scam phrase",
+ },
+ "get 3 months of discord nitro": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "discord nitro scam phrase",
+ },
+ "get discord nitro for free": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "discord nitro scam phrase",
+ },
+ "get free discord nitro from steam": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "discord nitro scam phrase",
+ },
+ "lol, jahjajha free discord nitro for 3 month!!": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "discord nitro scam phrase",
+ },
+ "steam is giving away 3 months of discord nitro for free to all no limited steam users": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "discord nitro scam phrase",
+ },
+ "Лол, бесплатный дискорд нитро на 1 месяц!": {
+ //? Lol, 1 month free discord nitro!
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "discord nitro scam phrase",
+ },
+ "Airdrop Discord FREE NITRO from Steam —": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "discord nitro scam phrase",
+ },
+
+ /* -------------------------------------------------------------------------- */
+ /* Misc Scams */
+ /* -------------------------------------------------------------------------- */
+ "found a cool software that improves the": {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "misc. scam phrase",
+ },
+ "there is a possible chance tomorrow there will be a cyber-attack event where on all social networks including Discord there will be people trying":
+ {
+ severity: Severity.WARN,
+ ignoreSpaces: false,
+ ignoreCapitalization: true,
+ reason: "annoying copy pasta",
+ },
+
+ /* -------------------------------------------------------------------------- */
+ /* Frequently Advertised Discord Severs */
+ /* -------------------------------------------------------------------------- */
+ "https://discord.gg/7CaCvDXs": {
+ severity: Severity.TEMP_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: "blacklisted server link",
+ },
+} as BadWords;
diff --git a/src/lib/common/autoMod.ts b/src/lib/common/autoMod.ts
new file mode 100644
index 0000000..10bccba
--- /dev/null
+++ b/src/lib/common/autoMod.ts
@@ -0,0 +1,236 @@
+import { Formatters, MessageActionRow, MessageButton, MessageEmbed, TextChannel } from 'discord.js';
+import badLinksArray from '../../lib/badlinks';
+import badLinksSecretArray from '../../lib/badlinks-secret'; // I cannot make this public so just make a new file that export defaults an empty array
+import badWords from '../../lib/badwords';
+import { BushButtonInteraction } from '../extensions/discord.js/BushButtonInteraction';
+import { BushMessage } from '../extensions/discord.js/BushMessage';
+
+export class AutoMod {
+ private message: BushMessage;
+
+ public constructor(message: BushMessage) {
+ this.message = message;
+ void this.handle();
+ }
+
+ private async handle(): Promise<void> {
+ if (this.message.channel.type === 'DM' || !this.message.guild) return;
+ if (!(await this.message.guild.hasFeature('automod'))) return;
+
+ const customAutomodPhrases = (await this.message.guild.getSetting('autoModPhases')) ?? {};
+ const badLinks: BadWords = {};
+ const badLinksSecret: BadWords = {};
+
+ badLinksArray.forEach((link) => {
+ badLinks[link] = {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: 'malicious link'
+ };
+ });
+ badLinksSecretArray.forEach((link) => {
+ badLinks[link] = {
+ severity: Severity.PERM_MUTE,
+ ignoreSpaces: true,
+ ignoreCapitalization: true,
+ reason: 'malicious link'
+ };
+ });
+
+ const result = {
+ ...this.checkWords(customAutomodPhrases),
+ ...this.checkWords((await this.message.guild.hasFeature('excludeDefaultAutomod')) ? {} : badWords),
+ ...this.checkWords(
+ (await this.message.guild.hasFeature('excludeAutomodScamLinks')) ? {} : { ...badLinks, ...badLinksSecret }
+ )
+ };
+
+ if (Object.keys(result).length === 0) return;
+
+ const highestOffence = Object.entries(result)
+ .map(([key, value]) => ({ word: key, ...value }))
+ .sort((a, b) => b.severity - a.severity)[0];
+
+ if (highestOffence.severity === undefined || highestOffence.severity === null)
+ void this.message.guild.sendLogChannel('error', {
+ embeds: [
+ {
+ title: 'AutoMod Error',
+ description: `Unable to find severity information for ${Formatters.inlineCode(
+ util.discord.escapeInlineCode(highestOffence.word)
+ )}`,
+ color: util.colors.error
+ }
+ ]
+ });
+ else {
+ const color = this.punish(highestOffence);
+ void this.log(highestOffence, color, result);
+ }
+ }
+
+ private checkWords(words: BadWords): BadWords {
+ if (Object.keys(words).length === 0) return {};
+
+ const matchedWords: BadWords = {};
+ for (const word in words) {
+ const wordOptions = words[word];
+ if (this.format(this.message.content, wordOptions) === this.format(word, wordOptions)) {
+ }
+ }
+ return matchedWords;
+ }
+
+ private format(string: string, wordOptions: BadWordDetails) {
+ const temp = wordOptions.ignoreCapitalization ? string.toLowerCase() : string;
+ return wordOptions.ignoreSpaces ? temp.replace(/ /g, '') : temp;
+ }
+
+ private punish(highestOffence: BadWordDetails & { word: string }) {
+ let color;
+ switch (highestOffence.severity) {
+ case Severity.DELETE: {
+ color = util.colors.lightGray;
+ void this.message.delete().catch((e) => deleteError.bind(this, e));
+ break;
+ }
+ case Severity.WARN: {
+ color = util.colors.yellow;
+ void this.message.delete().catch((e) => deleteError.bind(this, e));
+ void this.message.member?.warn({
+ moderator: this.message.guild!.me!,
+ reason: `[AutoMod] ${highestOffence.reason}`
+ });
+ break;
+ }
+ case Severity.TEMP_MUTE: {
+ color = util.colors.orange;
+ void this.message.delete().catch((e) => deleteError.bind(this, e));
+ void this.message.member?.mute({
+ moderator: this.message.guild!.me!,
+ reason: `[AutoMod] ${highestOffence.reason}`,
+ duration: 900_000 // 15 minutes
+ });
+ break;
+ }
+ case Severity.PERM_MUTE: {
+ color = util.colors.red;
+ void this.message.delete().catch((e) => deleteError.bind(this, e));
+ void this.message.member?.mute({
+ moderator: this.message.guild!.me!,
+ reason: `[AutoMod] ${highestOffence.reason}`,
+ duration: 900_000 // 15 minutes
+ });
+ break;
+ }
+ default: {
+ throw new Error('Invalid severity');
+ }
+ }
+
+ return color;
+
+ async function deleteError(this: AutoMod, e: Error | any) {
+ this.message.guild?.sendLogChannel('error', {
+ embeds: [
+ {
+ title: 'AutoMod Error',
+ description: `Unable to delete triggered message.`,
+ fields: [{ name: 'Error', value: await util.codeblock(`${e.stack ?? e}`, 1024, 'js', true) }],
+ color: util.colors.error
+ }
+ ]
+ });
+ }
+ }
+
+ private async log(highestOffence: BadWordDetails & { word: string }, color: `#${string}`, offences: BadWords) {
+ void client.console.info(
+ 'autoMod',
+ `Severity <<${highestOffence.severity}>> action performed on <<${this.message.author.tag}>> (<<${
+ this.message.author.id
+ }>>) in <<#${(this.message.channel as TextChannel).name}>> in <<${this.message.guild!.name}>>`
+ );
+
+ return await this.message.guild!.sendLogChannel('automod', {
+ embeds: [
+ new MessageEmbed()
+ .setTitle(`[Severity ${highestOffence.severity}] Automod Action Performed`)
+ .setDescription(
+ `**User:** ${this.message.author} (${this.message.author.tag})\n**Sent From**: <#${
+ this.message.channel.id
+ }> [Jump to context](${this.message.url})\n**Blacklisted Words:** ${util
+ .surroundArray(Object.keys(offences), '`')
+ .join(', ')}`
+ )
+ .addField('Message Content', `${await util.codeblock(this.message.content, 1024)}`)
+ .setColor(color)
+ .setTimestamp()
+ ],
+ components:
+ highestOffence.severity >= 2
+ ? [
+ new MessageActionRow().addComponents(
+ new MessageButton()
+ .setStyle('DANGER')
+ .setLabel('Ban User')
+ .setCustomId(`automod;ban;${this.message.author.id};${highestOffence.reason}`)
+ )
+ ]
+ : undefined
+ });
+ }
+
+ public static async handleInteraction(interaction: BushButtonInteraction) {
+ if (!interaction.memberPermissions?.has('BAN_MEMBERS'))
+ return interaction.reply({
+ content: `${util.emojis.error} You are missing the **Ban Members** permission.`,
+ ephemeral: true
+ });
+ const [action, userId, reason] = interaction.customId.replace('automod;', '').split(';');
+ switch (action) {
+ case 'ban': {
+ await interaction.deferReply();
+ const result = await interaction.guild?.bushBan({ user: userId, reason, moderator: interaction.user.id });
+
+ if (result === 'success')
+ return interaction.reply({
+ content: `${util.emojis.success} Successfully banned **${
+ interaction.guild?.members.cache.get(userId)?.user.tag ?? userId
+ }**.`,
+ ephemeral: true
+ });
+ else
+ return interaction.reply({
+ content: `${util.emojis.error} Could not ban **${
+ interaction.guild?.members.cache.get(userId)?.user.tag ?? userId
+ }**: \`${result}\` .`,
+ ephemeral: true
+ });
+ }
+ }
+ }
+}
+
+export const enum Severity {
+ /** Delete message */
+ DELETE,
+ /** Delete message and warn user */
+ WARN,
+ /** Delete message and mute user for 15 minutes */
+ TEMP_MUTE,
+ /** Delete message and mute user permanently */
+ PERM_MUTE
+}
+
+interface BadWordDetails {
+ severity: Severity;
+ ignoreSpaces: boolean;
+ ignoreCapitalization: boolean;
+ reason: string;
+}
+
+export interface BadWords {
+ [key: string]: BadWordDetails;
+}
diff --git a/src/lib/common/moderation.ts b/src/lib/common/moderation.ts
new file mode 100644
index 0000000..4af6ec2
--- /dev/null
+++ b/src/lib/common/moderation.ts
@@ -0,0 +1,181 @@
+import { Snowflake } from 'discord-api-types';
+import {
+ ActivePunishment,
+ ActivePunishmentType,
+ BushGuildMember,
+ BushGuildMemberResolvable,
+ BushGuildResolvable,
+ Guild,
+ ModLog,
+ ModLogType
+} from '..';
+
+export class Moderation {
+ /**
+ * Checks if a moderator can perform a moderation action on another user.
+ * @param moderator - The person trying to perform the action.
+ * @param victim - The person getting punished.
+ * @param type - The type of punishment - used to format the response.
+ * @param checkModerator - Whether or not to check if the victim is a moderator.
+ */
+ public static async permissionCheck(
+ moderator: BushGuildMember,
+ victim: BushGuildMember,
+ type: 'mute' | 'unmute' | 'warn' | 'kick' | 'ban' | 'unban' | 'add a punishment role to' | 'remove a punishment role from',
+ checkModerator = true,
+ force = false
+ ): Promise<true | string> {
+ if (force) return true;
+
+ // If the victim is not in the guild anymore it will be undefined
+ if ((!victim || !victim.guild) && !['ban', 'unban'].includes(type)) return true;
+
+ if (moderator.guild.id !== victim.guild.id) {
+ throw new Error('moderator and victim not in same guild');
+ }
+
+ const isOwner = moderator.guild.ownerId === moderator.id;
+ if (moderator.id === victim.id && !type.startsWith('un')) {
+ return `${util.emojis.error} You cannot ${type} yourself.`;
+ }
+ if (
+ moderator.roles.highest.position <= victim.roles.highest.position &&
+ !isOwner &&
+ !(type.startsWith('un') && moderator.id === victim.id)
+ ) {
+ return `${util.emojis.error} You cannot ${type} **${victim.user.tag}** because they have higher or equal role hierarchy as you do.`;
+ }
+ if (
+ victim.roles.highest.position >= victim.guild.me!.roles.highest.position &&
+ !(type.startsWith('un') && moderator.id === victim.id)
+ ) {
+ return `${util.emojis.error} You cannot ${type} **${victim.user.tag}** because they have higher or equal role hierarchy as I do.`;
+ }
+ if (checkModerator && victim.permissions.has('MANAGE_MESSAGES') && !(type.startsWith('un') && moderator.id === victim.id)) {
+ if (await moderator.guild.hasFeature('modsCanPunishMods')) {
+ return true;
+ } else {
+ return `${util.emojis.error} You cannot ${type} **${victim.user.tag}** because they are a moderator.`;
+ }
+ }
+ return true;
+ }
+
+ public static async createModLogEntry(
+ options: {
+ type: ModLogType;
+ user: BushGuildMemberResolvable;
+ moderator: BushGuildMemberResolvable;
+ reason: string | undefined | null;
+ duration?: number;
+ guild: BushGuildResolvable;
+ pseudo?: boolean;
+ },
+ getCaseNumber = false
+ ): Promise<{ log: ModLog | null; caseNum: number | null }> {
+ const user = (await util.resolveNonCachedUser(options.user))!.id;
+ const moderator = (await util.resolveNonCachedUser(options.moderator))!.id;
+ const guild = client.guilds.resolveId(options.guild)!;
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
+ const duration = options.duration || undefined;
+
+ // If guild does not exist create it so the modlog can reference a guild.
+ await Guild.findOrCreate({
+ where: {
+ id: guild
+ },
+ defaults: {
+ id: guild
+ }
+ });
+
+ const modLogEntry = ModLog.build({
+ type: options.type,
+ user,
+ moderator,
+ reason: options.reason,
+ duration: duration,
+ guild,
+ pseudo: options.pseudo ?? false
+ });
+ const saveResult: ModLog | null = await modLogEntry.save().catch(async (e) => {
+ await util.handleError('createModLogEntry', e);
+ return null;
+ });
+
+ if (!getCaseNumber) return { log: saveResult, caseNum: null };
+
+ const caseNum = (await ModLog.findAll({ where: { type: options.type, user: user, guild: guild, hidden: 'false' } }))
+ ?.length;
+ return { log: saveResult, caseNum };
+ }
+
+ public static async createPunishmentEntry(options: {
+ type: 'mute' | 'ban' | 'role' | 'block';
+ user: BushGuildMemberResolvable;
+ duration: number | undefined;
+ guild: BushGuildResolvable;
+ modlog: string;
+ extraInfo?: Snowflake;
+ }): Promise<ActivePunishment | null> {
+ const expires = options.duration ? new Date(+new Date() + options.duration ?? 0) : undefined;
+ const user = (await util.resolveNonCachedUser(options.user))!.id;
+ const guild = client.guilds.resolveId(options.guild)!;
+ const type = this.#findTypeEnum(options.type)!;
+
+ const entry = ActivePunishment.build(
+ options.extraInfo
+ ? { user, type, guild, expires, modlog: options.modlog, extraInfo: options.extraInfo }
+ : { user, type, guild, expires, modlog: options.modlog }
+ );
+ return await entry.save().catch(async (e) => {
+ await util.handleError('createPunishmentEntry', e);
+ return null;
+ });
+ }
+
+ public static async removePunishmentEntry(options: {
+ type: 'mute' | 'ban' | 'role' | 'block';
+ user: BushGuildMemberResolvable;
+ guild: BushGuildResolvable;
+ extraInfo?: Snowflake;
+ }): Promise<boolean> {
+ const user = await util.resolveNonCachedUser(options.user);
+ const guild = client.guilds.resolveId(options.guild);
+ const type = this.#findTypeEnum(options.type);
+
+ if (!user || !guild) return false;
+
+ let success = true;
+
+ const entries = await ActivePunishment.findAll({
+ // finding all cases of a certain type incase there were duplicates or something
+ where: options.extraInfo
+ ? { user: user.id, guild: guild, type, extraInfo: options.extraInfo }
+ : { user: user.id, guild: guild, type }
+ }).catch(async (e) => {
+ await util.handleError('removePunishmentEntry', e);
+ success = false;
+ });
+ if (entries) {
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
+ entries.forEach(async (entry) => {
+ await entry.destroy().catch(async (e) => {
+ await util.handleError('removePunishmentEntry', e);
+ });
+ success = false;
+ });
+ }
+ return success;
+ }
+
+ static #findTypeEnum(type: 'mute' | 'ban' | 'role' | 'block') {
+ const typeMap = {
+ ['mute']: ActivePunishmentType.MUTE,
+ ['ban']: ActivePunishmentType.BAN,
+ ['role']: ActivePunishmentType.ROLE,
+ ['block']: ActivePunishmentType.BLOCK
+ };
+ return typeMap[type];
+ }
+}
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index a50cd61..448eaf3 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.