add filter & !polycatgen
This commit is contained in:
parent
1908a4f79e
commit
ef133512a3
5 changed files with 65 additions and 14 deletions
23
commands.ts
23
commands.ts
|
@ -1,4 +1,6 @@
|
|||
import type { Client, Message } from 'discord.js';
|
||||
import pLimit from 'p-limit';
|
||||
import { POLYCAT_CHANNEL_ID } from './constants';
|
||||
|
||||
type Commands = {
|
||||
[cmd: string]: (c: Client, e: Message) => void | Promise<void>;
|
||||
|
@ -97,6 +99,27 @@ We probably can't fully fix this. If you find out which mod is causing this, tel
|
|||
],
|
||||
});
|
||||
},
|
||||
|
||||
'!polycatgen': async (c, e) => {
|
||||
if (!e.guild) return;
|
||||
if (e.channelId !== POLYCAT_CHANNEL_ID) return;
|
||||
|
||||
await e.guild.emojis.fetch();
|
||||
const polycat = e.guild.emojis.cache.find(
|
||||
(emoji) => emoji.name?.toLowerCase() === 'polycat'
|
||||
);
|
||||
|
||||
const lim = pLimit(2);
|
||||
const prom = [];
|
||||
for (let i = 0; i < 10; i++) {
|
||||
prom.push(
|
||||
lim(() =>
|
||||
e.channel.send(`${polycat}${polycat}${polycat}${polycat}${polycat}`)
|
||||
)
|
||||
);
|
||||
}
|
||||
await Promise.all(prom);
|
||||
},
|
||||
};
|
||||
|
||||
export const aliases: { [a: string]: string } = {
|
||||
|
|
|
@ -1,2 +1,7 @@
|
|||
export const GUILD_ID = '923671181020766230';
|
||||
export const DEBUG_CHANNEL_ID = '977401259260788756';
|
||||
export const POLYCAT_CHANNEL_ID = '977797790749032448';
|
||||
|
||||
export const BAD_WORDS = <string[]>(
|
||||
['ruls_tset'].map((r) => [...r].reverse().join(''))
|
||||
);
|
||||
|
|
38
index.ts
38
index.ts
|
@ -2,7 +2,7 @@ import { Client, Intents } from 'discord.js';
|
|||
import { commands, aliases } from './commands';
|
||||
|
||||
import * as BuildConfig from './constants';
|
||||
// import Filter from 'bad-words';
|
||||
import Filter from 'bad-words';
|
||||
import { isBad } from './badLinks';
|
||||
|
||||
import { green, bold, blue, underline } from 'kleur/colors';
|
||||
|
@ -69,24 +69,34 @@ client.once('ready', async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
// const profane = new Filter({ exclude: ['damn'] }).isProfane(e.content);
|
||||
const profaneFilter = new Filter({
|
||||
emptyList: true,
|
||||
});
|
||||
|
||||
// if (profane) {
|
||||
// e.reply({
|
||||
// embeds: [
|
||||
// {
|
||||
// title: 'Profanity detected!',
|
||||
// description: 'Please try not to use these words 😄',
|
||||
// color: 'FUCHSIA',
|
||||
// },
|
||||
// ],
|
||||
// });
|
||||
// }
|
||||
profaneFilter.addWords(...BuildConfig.BAD_WORDS);
|
||||
|
||||
if (profaneFilter.isProfane(e.content)) {
|
||||
await e.reply({
|
||||
embeds: [
|
||||
{
|
||||
title: 'Profanity detected!',
|
||||
description: "Please don't use these words.",
|
||||
color: 'FUCHSIA',
|
||||
},
|
||||
],
|
||||
});
|
||||
await e.delete();
|
||||
|
||||
if (!e.member) return;
|
||||
await e.member.disableCommunicationUntil(Date.now() + 5 * 60 * 1000);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
const urlMatches = [...e.content.matchAll(urlRegex())];
|
||||
|
||||
if (urlMatches) {
|
||||
if (urlMatches.length) {
|
||||
console.log('Found links in message from', e.author.tag);
|
||||
|
||||
for (const match of urlMatches) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"discord.js": "^13.7.0",
|
||||
"kleur": "^4.1.4",
|
||||
"node-fetch": "^3.2.4",
|
||||
"p-limit": "^4.0.0",
|
||||
"url-regex": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
12
yarn.lock
12
yarn.lock
|
@ -1645,6 +1645,13 @@ p-cancelable@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-1.1.0.tgz#d078d15a3af409220c886f1d9a0ca2e441ab26cc"
|
||||
integrity sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==
|
||||
|
||||
p-limit@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-4.0.0.tgz#914af6544ed32bfa54670b061cafcbd04984b644"
|
||||
integrity sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==
|
||||
dependencies:
|
||||
yocto-queue "^1.0.0"
|
||||
|
||||
package-json@^6.3.0:
|
||||
version "6.5.0"
|
||||
resolved "https://registry.yarnpkg.com/package-json/-/package-json-6.5.0.tgz#6feedaca35e75725876d0b0e64974697fed145b0"
|
||||
|
@ -2136,3 +2143,8 @@ yallist@^4.0.0:
|
|||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
|
||||
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
|
||||
|
||||
yocto-queue@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.0.0.tgz#7f816433fb2cbc511ec8bf7d263c3b58a1a3c251"
|
||||
integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue