1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 00:10:58 -05:00

Compare commits

...

4 Commits

Author SHA1 Message Date
AnxietyisReal
09b0f1e88f Move automoderation to dedicated file 2023-09-04 15:04:34 +10:00
AnxietyisReal
e68fa129d2 Update packages part 2 2023-09-04 14:43:59 +10:00
AnxietyisReal
ee5d597928 Update packages 2023-09-04 14:43:19 +10:00
AnxietyisReal
003f5f1edb Strip code comments from JS files 2023-09-04 13:34:08 +10:00
6 changed files with 172 additions and 127 deletions

109
.pnp.cjs generated
View File

@ -28,21 +28,21 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
[null, {\
"packageLocation": "./",\
"packageDependencies": [\
["@discord-player/extractor", "npm:4.4.1"],\
["@discord-player/extractor", "npm:4.4.2"],\
["@discordjs/opus", "npm:0.9.0"],\
["@octokit/auth-token", "npm:4.0.0"],\
["@octokit/rest", "npm:20.0.1"],\
["@types/ms", "npm:0.7.31"],\
["@types/node", "npm:20.5.7"],\
["@types/node", "npm:20.5.9"],\
["canvas", "npm:2.11.2"],\
["discord-player", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.6.2"],\
["discord-player", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.6.3"],\
["discord.js", "npm:14.13.0"],\
["libsodium-wrappers", "npm:0.7.11"],\
["moment", "npm:2.29.4"],\
["mongoose", "npm:7.5.0"],\
["ms", "npm:2.1.3"],\
["prism-media", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:1.3.5"],\
["systeminformation", "npm:5.21.1"],\
["systeminformation", "npm:5.21.4"],\
["typescript", "patch:typescript@npm%3A5.2.2#~builtin<compat/typescript>::version=5.2.2&hash=f3b441"],\
["xml-js", "npm:1.6.11"],\
["youtube-sr", "npm:4.3.4"],\
@ -61,10 +61,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@discord-player/extractor", [\
["npm:4.4.1", {\
"packageLocation": "./.yarn/cache/@discord-player-extractor-npm-4.4.1-0e54ee9101-5a2a2315dc.zip/node_modules/@discord-player/extractor/",\
["npm:4.4.2", {\
"packageLocation": "./.yarn/cache/@discord-player-extractor-npm-4.4.2-3362ec12c1-9009c5d1d9.zip/node_modules/@discord-player/extractor/",\
"packageDependencies": [\
["@discord-player/extractor", "npm:4.4.1"],\
["@discord-player/extractor", "npm:4.4.2"],\
["file-type", "npm:16.5.4"],\
["genius-lyrics", "npm:4.4.3"],\
["isomorphic-unfetch", "npm:4.0.2"],\
@ -86,6 +86,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"linkType": "HARD"\
}]\
]],\
["@discord-player/opus", [\
["npm:0.1.2", {\
"packageLocation": "./.yarn/cache/@discord-player-opus-npm-0.1.2-e4f925bdf7-41ceb8f64e.zip/node_modules/@discord-player/opus/",\
"packageDependencies": [\
["@discord-player/opus", "npm:0.1.2"]\
],\
"linkType": "HARD"\
}]\
]],\
["@discord-player/utils", [\
["npm:0.2.2", {\
"packageLocation": "./.yarn/cache/@discord-player-utils-npm-0.2.2-06a295dbb3-1e82767fa6.zip/node_modules/@discord-player/utils/",\
@ -194,20 +203,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"linkType": "HARD"\
}]\
]],\
["@discordjs/voice", [\
["npm:0.16.0", {\
"packageLocation": "./.yarn/cache/@discordjs-voice-npm-0.16.0-37f8ab283f-521824475c.zip/node_modules/@discordjs/voice/",\
"packageDependencies": [\
["@discordjs/voice", "npm:0.16.0"],\
["@types/ws", "npm:8.5.5"],\
["discord-api-types", "npm:0.37.54"],\
["prism-media", "virtual:37f8ab283fb7abcf3fda3c5d430948901f33b8d771da32a273933562670e34608b1daf4394905868d946d64bc91643fb158184deae5131f973a7fcfafbc06afc#npm:1.3.5"],\
["tslib", "npm:2.6.1"],\
["ws", "virtual:31c533a2eb37dc1746b7d976d500ca13eb00e91bf180b840d65754f8c6e137fa3abf10279db8d10554ceb81785dfffeb6b725d592c9bfa5b4309edf4781c592e#npm:8.13.0"]\
],\
"linkType": "HARD"\
}]\
]],\
["@discordjs/ws", [\
["npm:1.0.1", {\
"packageLocation": "./.yarn/cache/@discordjs-ws-npm-1.0.1-31c533a2eb-d34f176466.zip/node_modules/@discordjs/ws/",\
@ -536,10 +531,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
],\
"linkType": "HARD"\
}],\
["npm:20.5.7", {\
"packageLocation": "./.yarn/cache/@types-node-npm-20.5.7-b5e80f1922-fc284c8e16.zip/node_modules/@types/node/",\
["npm:20.5.9", {\
"packageLocation": "./.yarn/cache/@types-node-npm-20.5.9-0b27ddedcc-717490e941.zip/node_modules/@types/node/",\
"packageDependencies": [\
["@types/node", "npm:20.5.7"]\
["@types/node", "npm:20.5.9"]\
],\
"linkType": "HARD"\
}]\
@ -921,21 +916,21 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"packageLocation": "./",\
"packageDependencies": [\
["daggerbot-ts", "workspace:."],\
["@discord-player/extractor", "npm:4.4.1"],\
["@discord-player/extractor", "npm:4.4.2"],\
["@discordjs/opus", "npm:0.9.0"],\
["@octokit/auth-token", "npm:4.0.0"],\
["@octokit/rest", "npm:20.0.1"],\
["@types/ms", "npm:0.7.31"],\
["@types/node", "npm:20.5.7"],\
["@types/node", "npm:20.5.9"],\
["canvas", "npm:2.11.2"],\
["discord-player", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.6.2"],\
["discord-player", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.6.3"],\
["discord.js", "npm:14.13.0"],\
["libsodium-wrappers", "npm:0.7.11"],\
["moment", "npm:2.29.4"],\
["mongoose", "npm:7.5.0"],\
["ms", "npm:2.1.3"],\
["prism-media", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:1.3.5"],\
["systeminformation", "npm:5.21.1"],\
["systeminformation", "npm:5.21.4"],\
["typescript", "patch:typescript@npm%3A5.2.2#~builtin<compat/typescript>::version=5.2.2&hash=f3b441"],\
["xml-js", "npm:1.6.11"],\
["youtube-sr", "npm:4.3.4"],\
@ -1030,35 +1025,36 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
],\
"linkType": "HARD"\
}],\
["npm:0.37.54", {\
"packageLocation": "./.yarn/cache/discord-api-types-npm-0.37.54-375905cfce-f149961be9.zip/node_modules/discord-api-types/",\
["npm:0.37.56", {\
"packageLocation": "./.yarn/cache/discord-api-types-npm-0.37.56-c9192a9164-797be690af.zip/node_modules/discord-api-types/",\
"packageDependencies": [\
["discord-api-types", "npm:0.37.54"]\
["discord-api-types", "npm:0.37.56"]\
],\
"linkType": "HARD"\
}]\
]],\
["discord-player", [\
["npm:6.6.2", {\
"packageLocation": "./.yarn/cache/discord-player-npm-6.6.2-fc0519baf7-1f3efa295c.zip/node_modules/discord-player/",\
["npm:6.6.3", {\
"packageLocation": "./.yarn/cache/discord-player-npm-6.6.3-4a62083a91-c98d853980.zip/node_modules/discord-player/",\
"packageDependencies": [\
["discord-player", "npm:6.6.2"]\
["discord-player", "npm:6.6.3"]\
],\
"linkType": "SOFT"\
}],\
["virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.6.2", {\
"packageLocation": "./.yarn/__virtual__/discord-player-virtual-34bade91e7/0/cache/discord-player-npm-6.6.2-fc0519baf7-1f3efa295c.zip/node_modules/discord-player/",\
["virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.6.3", {\
"packageLocation": "./.yarn/__virtual__/discord-player-virtual-5d4dbc4bbe/0/cache/discord-player-npm-6.6.3-4a62083a91-c98d853980.zip/node_modules/discord-player/",\
"packageDependencies": [\
["discord-player", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.6.2"],\
["discord-player", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:6.6.3"],\
["@discord-player/equalizer", "npm:0.2.2"],\
["@discord-player/extractor", "npm:4.4.1"],\
["@discord-player/extractor", "npm:4.4.2"],\
["@discord-player/ffmpeg", "npm:0.1.0"],\
["@discord-player/utils", "npm:0.2.2"],\
["@discordjs/voice", "npm:0.16.0"],\
["@types/discord-player__extractor", null],\
["@types/discord.js", null],\
["@types/youtube-sr", null],\
["discord-voip", "npm:0.1.3"],\
["discord.js", "npm:14.13.0"],\
["ip", "npm:1.1.8"],\
["libsodium-wrappers", "npm:0.7.11"],\
["youtube-sr", "npm:4.3.4"]\
],\
@ -1073,6 +1069,22 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"linkType": "HARD"\
}]\
]],\
["discord-voip", [\
["npm:0.1.3", {\
"packageLocation": "./.yarn/cache/discord-voip-npm-0.1.3-73b0766e7a-9dd87e1871.zip/node_modules/discord-voip/",\
"packageDependencies": [\
["discord-voip", "npm:0.1.3"],\
["@discord-player/ffmpeg", "npm:0.1.0"],\
["@discord-player/opus", "npm:0.1.2"],\
["@types/ws", "npm:8.5.5"],\
["discord-api-types", "npm:0.37.56"],\
["prism-media", "virtual:73b0766e7a4cf73948665373bb541aaafcf2ff3b41b87b7d0b923b08eff45cdd2f00f45a05efcface0fa1d93425f73fd06ec491103e358bb07f7a87da12ccb8d#npm:1.3.5"],\
["tslib", "npm:2.6.1"],\
["ws", "virtual:31c533a2eb37dc1746b7d976d500ca13eb00e91bf180b840d65754f8c6e137fa3abf10279db8d10554ceb81785dfffeb6b725d592c9bfa5b4309edf4781c592e#npm:8.13.0"]\
],\
"linkType": "HARD"\
}]\
]],\
["discord.js", [\
["npm:14.13.0", {\
"packageLocation": "./.yarn/cache/discord.js-npm-14.13.0-cee9413e4c-c273645ac2.zip/node_modules/discord.js/",\
@ -1510,6 +1522,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["ip", [\
["npm:1.1.8", {\
"packageLocation": "./.yarn/cache/ip-npm-1.1.8-abea558b72-a2ade53eb3.zip/node_modules/ip/",\
"packageDependencies": [\
["ip", "npm:1.1.8"]\
],\
"linkType": "HARD"\
}],\
["npm:2.0.0", {\
"packageLocation": "./.yarn/cache/ip-npm-2.0.0-204facb3cc-cfcfac6b87.zip/node_modules/ip/",\
"packageDependencies": [\
@ -2230,10 +2249,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
],\
"linkType": "HARD"\
}],\
["virtual:37f8ab283fb7abcf3fda3c5d430948901f33b8d771da32a273933562670e34608b1daf4394905868d946d64bc91643fb158184deae5131f973a7fcfafbc06afc#npm:1.3.5", {\
"packageLocation": "./.yarn/__virtual__/prism-media-virtual-01fa1f4255/0/cache/prism-media-npm-1.3.5-f727c60102-a4fbe5c91f.zip/node_modules/prism-media/",\
["virtual:73b0766e7a4cf73948665373bb541aaafcf2ff3b41b87b7d0b923b08eff45cdd2f00f45a05efcface0fa1d93425f73fd06ec491103e358bb07f7a87da12ccb8d#npm:1.3.5", {\
"packageLocation": "./.yarn/__virtual__/prism-media-virtual-f7e8cf73ea/0/cache/prism-media-npm-1.3.5-f727c60102-a4fbe5c91f.zip/node_modules/prism-media/",\
"packageDependencies": [\
["prism-media", "virtual:37f8ab283fb7abcf3fda3c5d430948901f33b8d771da32a273933562670e34608b1daf4394905868d946d64bc91643fb158184deae5131f973a7fcfafbc06afc#npm:1.3.5"],\
["prism-media", "virtual:73b0766e7a4cf73948665373bb541aaafcf2ff3b41b87b7d0b923b08eff45cdd2f00f45a05efcface0fa1d93425f73fd06ec491103e358bb07f7a87da12ccb8d#npm:1.3.5"],\
["@discordjs/opus", null],\
["@types/discordjs__opus", null],\
["@types/ffmpeg-static", null],\
@ -2598,10 +2617,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["systeminformation", [\
["npm:5.21.1", {\
"packageLocation": "./.yarn/unplugged/systeminformation-npm-5.21.1-9b1e539abd/node_modules/systeminformation/",\
["npm:5.21.4", {\
"packageLocation": "./.yarn/unplugged/systeminformation-npm-5.21.4-5c8623f45e/node_modules/systeminformation/",\
"packageDependencies": [\
["systeminformation", "npm:5.21.1"]\
["systeminformation", "npm:5.21.4"]\
],\
"linkType": "HARD"\
}]\

View File

@ -29,19 +29,19 @@
"engineStrict": true,
"packageManager": "yarn@3.6.3",
"dependencies": {
"@discord-player/extractor": "4.4.1",
"@discord-player/extractor": "4.4.2",
"@discordjs/opus": "0.9.0",
"@octokit/auth-token": "4.0.0",
"@octokit/rest": "20.0.1",
"canvas": "2.11.2",
"discord-player": "6.6.2",
"discord-player": "6.6.3",
"discord.js": "14.13.0",
"libsodium-wrappers": "0.7.11",
"moment": "2.29.4",
"mongoose": "7.5.0",
"ms": "2.1.3",
"prism-media": "1.3.5",
"systeminformation": "5.21.1",
"systeminformation": "5.21.4",
"typescript": "5.2.2",
"xml-js": "1.6.11",
"youtube-sr": "4.3.4",
@ -49,6 +49,6 @@
},
"devDependencies": {
"@types/ms": "0.7.31",
"@types/node": "20.5.7"
"@types/node": "20.5.9"
}
}

View File

@ -2,49 +2,21 @@ import Discord from 'discord.js';
import TClient from '../client.js';
import Response from '../funcs/ResponseSystem.js';
import LogPrefix from '../helpers/LogPrefix.js';
import Automoderator from '../funcs/Automod.js';
export default {
async run(client:TClient, message:Discord.Message){
if (message.author.bot) return;
if (!message.inGuild()) return (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({content: `<:fish_unamused:1083675172407623711> <@${client.config.whitelist[0]}>\n**${message.author.username}** tried to send me a DM, their message is:\`\`\`${message.content}\`\`\``, allowedMentions: {parse: ['users']}});
const msgarr = message.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]/g, '').split(' ');
let automodded: boolean;
//const Whitelist = [] // Array of channel ids for automod to be disabled in (Disables bannedWords and advertisement, mind you.)
async function repeatedMessages(thresholdTime:number, thresholdAmount:number, type:string, muteTime:string, muteReason:string){
if (client.repeatedMessages[message.author.id]){
// Add message to the list
client.repeatedMessages[message.author.id].data.set(message.createdTimestamp, {type, channel: message.channelId});
// Reset the timeout
clearTimeout(client.repeatedMessages[message.author.id].timeout);
client.repeatedMessages[message.author.id].timeout = setTimeout(()=>delete client.repeatedMessages[message.author.id], thresholdTime);
// Message sent after (now - threshold), so purge those that were sent earlier
client.repeatedMessages[message.author.id].data = client.repeatedMessages[message.author.id].data.filter((x,i)=>i>=Date.now() - thresholdTime);
// A spammed message is one that has been sent within the threshold parameters
const spammedMessage = client.repeatedMessages[message.author.id].data.find(x=>{
return client.repeatedMessages[message.author.id].data.filter(y=>x.type===y.type).size >= thresholdAmount;
});
if (spammedMessage){
delete client.repeatedMessages[message.author.id];
await client.punishments.addPunishment('mute', {time: muteTime}, (client.user as Discord.User).id, `[AUTOMOD] ${muteReason}`, message.author, message.member as Discord.GuildMember);
}
} else {
client.repeatedMessages[message.author.id] = {data: new client.collection(), timeout: setTimeout(()=>delete client.repeatedMessages[message.author.id], thresholdTime)};
client.repeatedMessages[message.author.id].data.set(message.createdTimestamp, {type, channel: message.channelId});
}
}
if (client.config.botSwitches.automod && !message.member.roles.cache.has(client.config.mainServer.roles.admin) && message.guildId == client.config.mainServer.id){
const automodFailReason = 'msg got possibly deleted by another bot.';
if (await client.bannedWords._content.findById(msgarr)/* && !Whitelist.includes(message.channelId) */){
if (await client.bannedWords._content.findById(Automoderator.scanMsg(message))/* && !Whitelist.includes(message.channelId) */){
automodded = true;
message.delete().catch(()=>console.log(LogPrefix('AUTOMOD-BANNEDWORDS'), automodFailReason));
message.channel.send('That word isn\'t allowed here.').then(x=>setTimeout(()=>x.delete(), 10000));
await repeatedMessages(30000, 3, 'bw', '30m', 'Constant swearing');
await Automoderator.repeatedMessages(client, message, 30000, 3, 'bw', '30m', 'Constant swearing');
} else if (message.content.toLowerCase().includes('discord.gg/') && !client.isStaff(message.member as Discord.GuildMember)){
const url = message.content.split(' ').find(x=>x.includes('discord.gg/'));
const validInvite = await client.fetchInvite(url).catch(()=>undefined);
@ -52,7 +24,7 @@ export default {
automodded = true;
message.delete().catch(()=>console.log(LogPrefix('AUTOMOD-ADVERT'), automodFailReason));
message.channel.send('Please don\'t advertise other Discord servers.').then(x=>setTimeout(()=>x.delete(), 15000));
await repeatedMessages(60000, 2, 'adv', '1h', 'Discord advertisement');
await Automoderator.repeatedMessages(client, message, 60000, 2, 'adv', '1h', 'Discord advertisement');
}
}
}
@ -85,8 +57,8 @@ export default {
if (incomingArrays.cantRead.some(e=>message.content.toLowerCase().includes(e))) message.reply('https://tenor.com/view/aristocats-george-pen-cap-meticulous-gif-5330931');
if (message.content.toLowerCase().includes('is daggerbot working')) message.reply('https://tenor.com/view/i-still-feel-alive-living-existing-active-singing-gif-14630579');
if (incomingArrays.deadChat.some(e=>message.content.toLowerCase().includes(e))) message.reply('https://cdn.discordapp.com/attachments/925589318276382720/1011333656167579849/F57G5ZS.png');
if (msgarr.includes('nawdic') && incomingArrays.theyBrokeIt.some(e=>msgarr.includes(e)) && client.isStaff(message.member) && message.channelId !== '516344221452599306') message.reply({embeds: [new client.embed().setTitle('*Nawdic has done an oopsie*').setImage('https://c.tenor.com/JSj9ie_MD9kAAAAC/kopfsch%C3%BCtteln-an-kopf-fassen-oh-no.gif').setColor(client.config.embedColor)]});
if (msgarr.includes('monster') && incomingArrays.theyBrokeIt.some(e=>msgarr.includes(e)) && client.isStaff(message.member) && message.channelId !== '516344221452599306') message.reply({embeds: [new client.embed().setTitle('*Monster has broken something*').setImage('https://media.tenor.com/ZIzIjb_wvEoAAAAC/face-palm.gif').setColor(client.config.embedColor)]});
if (Automoderator.scanMsg(message).includes('nawdic') && incomingArrays.theyBrokeIt.some(e=>Automoderator.scanMsg(message).includes(e)) && client.isStaff(message.member) && message.channelId !== '516344221452599306') message.reply({embeds: [new client.embed().setTitle('*Nawdic has done an oopsie*').setImage('https://c.tenor.com/JSj9ie_MD9kAAAAC/kopfsch%C3%BCtteln-an-kopf-fassen-oh-no.gif').setColor(client.config.embedColor)]});
if (Automoderator.scanMsg(message).includes('monster') && incomingArrays.theyBrokeIt.some(e=>Automoderator.scanMsg(message).includes(e)) && client.isStaff(message.member) && message.channelId !== '516344221452599306') message.reply({embeds: [new client.embed().setTitle('*Monster has broken something*').setImage('https://media.tenor.com/ZIzIjb_wvEoAAAAC/face-palm.gif').setColor(client.config.embedColor)]});
// Failsafe thingy (Toastproof maybe)
if (message.content.startsWith('!!_wepanikfrfr') && client.config.whitelist.includes(message.author.id)) (client.guilds.cache.get(message.guildId) as Discord.Guild).commands.set(client.registry).then(()=>message.reply('How did you manage to lose the commands??? Anyways, it\'s re-registered now.')).catch((e:Error)=>message.reply(`Failed to deploy slash commands:\n\`\`\`${e.message}\`\`\``));
}

36
src/funcs/Automod.ts Normal file
View File

@ -0,0 +1,36 @@
import Discord from 'discord.js';
import TClient from '../client.js';
export default class Automoderator {
static Whitelist(message:Discord.Message, ...arr:string[]){// Array of channel ids for automod to be disabled in (Disables bannedWords and advertisement, mind you.)
return arr.includes(message.channelId);
}
static scanMsg(message:Discord.Message){
return message.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]/g, '').split(' ')
}
static async repeatedMessages(client:TClient, message:Discord.Message, thresholdTime:number, thresholdAmount:number, type:string, muteTime:string, muteReason:string){
if (client.repeatedMessages[message.author.id]){
// Add message to the list
client.repeatedMessages[message.author.id].data.set(message.createdTimestamp, {type, channel: message.channelId});
// Reset the timeout
clearTimeout(client.repeatedMessages[message.author.id].timeout);
client.repeatedMessages[message.author.id].timeout = setTimeout(()=>delete client.repeatedMessages[message.author.id], thresholdTime);
// Message sent after (now - threshold), so purge those that were sent earlier
client.repeatedMessages[message.author.id].data = client.repeatedMessages[message.author.id].data.filter((x,i)=>i>=Date.now() - thresholdTime);
// A spammed message is one that has been sent within the threshold parameters
const spammedMessage = client.repeatedMessages[message.author.id].data.find(x=>{
return client.repeatedMessages[message.author.id].data.filter(y=>x.type===y.type).size >= thresholdAmount;
});
if (spammedMessage){
delete client.repeatedMessages[message.author.id];
await client.punishments.addPunishment('mute', {time: muteTime}, (client.user as Discord.User).id, `[AUTOMOD] ${muteReason}`, message.author, message.member as Discord.GuildMember);
}
} else {
client.repeatedMessages[message.author.id] = {data: new client.collection(), timeout: setTimeout(()=>delete client.repeatedMessages[message.author.id], thresholdTime)};
client.repeatedMessages[message.author.id].data.set(message.createdTimestamp, {type, channel: message.channelId});
}
}
}

View File

@ -1,6 +1,7 @@
{
"compilerOptions": {
"skipLibCheck": true,
"removeComments": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"emitDecoratorMetadata": true,

103
yarn.lock
View File

@ -12,9 +12,9 @@ __metadata:
languageName: node
linkType: hard
"@discord-player/extractor@npm:4.4.1":
version: 4.4.1
resolution: "@discord-player/extractor@npm:4.4.1"
"@discord-player/extractor@npm:4.4.2":
version: 4.4.2
resolution: "@discord-player/extractor@npm:4.4.2"
dependencies:
file-type: ^16.5.4
genius-lyrics: ^4.4.3
@ -22,9 +22,9 @@ __metadata:
node-html-parser: ^6.1.4
reverbnation-scraper: ^2.0.0
soundcloud.ts: ^0.5.0
spotify-url-info: ^3.2.5
spotify-url-info: ^3.2.6
youtube-sr: ^4.3.4
checksum: 5a2a2315dc88c70285a9b70b3bd4a12e50eca14ad95b9d25c98599e0465acd7e3ba1c05adbf54a71d13a4bb04bce70dfe1b4cbad361d77b741fc864d5d7dc258
checksum: 9009c5d1d9be3f4eeda850d4dff580612678e25d7034de64fc85ed3756889f03b23655e1f510a3057c955292fe8857cb938cd950924061decee8c9a7ed31657e
languageName: node
linkType: hard
@ -35,6 +35,13 @@ __metadata:
languageName: node
linkType: hard
"@discord-player/opus@npm:^0.1.2":
version: 0.1.2
resolution: "@discord-player/opus@npm:0.1.2"
checksum: 41ceb8f64e5ee071789ca0042445664a02a62b5184b0e652f86c3851f4785c324cd2b3223791d690f6dcf33c6d0e7e5b20a88fb75781a3d96645558ec1cbcc19
languageName: node
linkType: hard
"@discord-player/utils@npm:^0.2.2":
version: 0.2.2
resolution: "@discord-player/utils@npm:0.2.2"
@ -135,19 +142,6 @@ __metadata:
languageName: node
linkType: hard
"@discordjs/voice@latest":
version: 0.16.0
resolution: "@discordjs/voice@npm:0.16.0"
dependencies:
"@types/ws": ^8.5.4
discord-api-types: ^0.37.37
prism-media: ^1.3.5
tslib: ^2.5.0
ws: ^8.13.0
checksum: 521824475c5257cf2098b7e7303e44c7906c2126603c7d85de14ad5f6ec12e61e459e18af92b97a11d504db91209aeb5b3e0c324b1f4f790c20e8db925fd66e9
languageName: node
linkType: hard
"@discordjs/ws@npm:^1.0.1":
version: 1.0.1
resolution: "@discordjs/ws@npm:1.0.1"
@ -402,10 +396,10 @@ __metadata:
languageName: node
linkType: hard
"@types/node@npm:20.5.7":
version: 20.5.7
resolution: "@types/node@npm:20.5.7"
checksum: fc284c8e16ddc04569730d58e87eae349eb1c3dd9020cb79a1862d9d9add6f04e7367a236f3252db8db2572f90278e250f4cd43d27d264972b54394eaba1ed76
"@types/node@npm:20.5.9":
version: 20.5.9
resolution: "@types/node@npm:20.5.9"
checksum: 717490e94131722144878b4ca1a963ede1673bb8f2ef78c2f5b50b918df6dc9b35e7f8283e5c2a7a9f137730f7c08dc6228e53d4494a94c9ee16881e6ce6caed
languageName: node
linkType: hard
@ -426,7 +420,7 @@ __metadata:
languageName: node
linkType: hard
"@types/ws@npm:^8.5.4, @types/ws@npm:^8.5.5":
"@types/ws@npm:^8.5.5":
version: 8.5.5
resolution: "@types/ws@npm:8.5.5"
dependencies:
@ -741,21 +735,21 @@ __metadata:
version: 0.0.0-use.local
resolution: "daggerbot-ts@workspace:."
dependencies:
"@discord-player/extractor": 4.4.1
"@discord-player/extractor": 4.4.2
"@discordjs/opus": 0.9.0
"@octokit/auth-token": 4.0.0
"@octokit/rest": 20.0.1
"@types/ms": 0.7.31
"@types/node": 20.5.7
"@types/node": 20.5.9
canvas: 2.11.2
discord-player: 6.6.2
discord-player: 6.6.3
discord.js: 14.13.0
libsodium-wrappers: 0.7.11
moment: 2.29.4
mongoose: 7.5.0
ms: 2.1.3
prism-media: 1.3.5
systeminformation: 5.21.1
systeminformation: 5.21.4
typescript: 5.2.2
xml-js: 1.6.11
youtube-sr: 4.3.4
@ -826,27 +820,43 @@ __metadata:
languageName: node
linkType: hard
"discord-api-types@npm:^0.37.37":
version: 0.37.54
resolution: "discord-api-types@npm:0.37.54"
checksum: f149961be9129673a0e3764285c8f47da22a30ea3e2466db06ffad44d1823094f7011ffe2d3d89b1b5ddd9940651afc72b3a05f84ce443a59f8480e2578dd1e1
"discord-api-types@npm:^0.37.50":
version: 0.37.56
resolution: "discord-api-types@npm:0.37.56"
checksum: 797be690af70a846422f955d918a5713a2c8c37bea646e2120996522afbb47fc5893122c1ddcb8f57a285ace6e1fb0237d1e63105444ae52534f0570a2f87f34
languageName: node
linkType: hard
"discord-player@npm:6.6.2":
version: 6.6.2
resolution: "discord-player@npm:6.6.2"
"discord-player@npm:6.6.3":
version: 6.6.3
resolution: "discord-player@npm:6.6.3"
dependencies:
"@discord-player/equalizer": ^0.2.2
"@discord-player/ffmpeg": ^0.1.0
"@discord-player/utils": ^0.2.2
"@discordjs/voice": latest
discord-voip: ^0.1.3
ip: ^1.1.8
libsodium-wrappers: ^0.7.10
peerDependencies:
"@discord-player/extractor": ^4.4.1
"@discord-player/extractor": ^4.4.2
discord.js: 14.x
youtube-sr: 4.x
checksum: 1f3efa295c5607c31a4e488be4e4ae35c6e6a7e47c0c98016349ad2ad1eb6cee73b3c8ad6589c3ba94aa820c3eee786c795fdea1681332f4a112bccec64fb430
checksum: c98d8539805bf09359a4966ce9af46581839d7dbfd659eb0e992a3834962ba4b9a4a3f582f17f34d847516903a86748ebc314f181e76304f863ad700e215da9d
languageName: node
linkType: hard
"discord-voip@npm:^0.1.3":
version: 0.1.3
resolution: "discord-voip@npm:0.1.3"
dependencies:
"@discord-player/ffmpeg": ^0.1.0
"@discord-player/opus": ^0.1.2
"@types/ws": ^8.5.5
discord-api-types: ^0.37.50
prism-media: ^1.3.5
tslib: ^2.6.1
ws: ^8.13.0
checksum: 9dd87e18713a90bec80050ab3c1e61c4e14fe99653040cdfae3841da976efc7ed4a569d4690b35a63a96a6cc30aa756a650a9e6048d1678f2854bf116aef0ca8
languageName: node
linkType: hard
@ -1238,6 +1248,13 @@ __metadata:
languageName: node
linkType: hard
"ip@npm:^1.1.8":
version: 1.1.8
resolution: "ip@npm:1.1.8"
checksum: a2ade53eb339fb0cbe9e69a44caab10d6e3784662285eb5d2677117ee4facc33a64679051c35e0dfdb1a3983a51ce2f5d2cb36446d52e10d01881789b76e28fb
languageName: node
linkType: hard
"ip@npm:^2.0.0":
version: 2.0.0
resolution: "ip@npm:2.0.0"
@ -2090,7 +2107,7 @@ __metadata:
languageName: node
linkType: hard
"spotify-url-info@npm:^3.2.5":
"spotify-url-info@npm:^3.2.6":
version: 3.2.6
resolution: "spotify-url-info@npm:3.2.6"
dependencies:
@ -2175,12 +2192,12 @@ __metadata:
languageName: node
linkType: hard
"systeminformation@npm:5.21.1":
version: 5.21.1
resolution: "systeminformation@npm:5.21.1"
"systeminformation@npm:5.21.4":
version: 5.21.4
resolution: "systeminformation@npm:5.21.4"
bin:
systeminformation: lib/cli.js
checksum: e08e56ea3bf0efc54c7bc0d2a675c4c181d7413d0b26fc80590433f24957e7e3c28fa35c46fae6c066bde4b73d9fccc6305c3b02616b35117df297356f793aa0
checksum: 2324456d1fee85efd3f5408d989afc29f4c8e1cc071f9c1082fc500cc3a4acb7d3be4e5706e706acf1558a4637bd8db028cafd5dcb3ccfd11514177ff0b870aa
conditions: (os=darwin | os=linux | os=win32 | os=freebsd | os=openbsd | os=netbsd | os=sunos | os=android)
languageName: node
linkType: hard
@ -2232,7 +2249,7 @@ __metadata:
languageName: node
linkType: hard
"tslib@npm:^2.5.0, tslib@npm:^2.6.1":
"tslib@npm:^2.6.1":
version: 2.6.1
resolution: "tslib@npm:2.6.1"
checksum: b0d176d176487905b66ae4d5856647df50e37beea7571c53b8d10ba9222c074b81f1410fb91da13debaf2cbc970663609068bdebafa844ea9d69b146527c38fe