diff --git a/src/commands/pw.ts b/src/commands/pw.ts index be5b983..b9b5ea8 100644 --- a/src/commands/pw.ts +++ b/src/commands/pw.ts @@ -5,20 +5,18 @@ import MessageTool from '../helpers/MessageTool.js'; export default class ProhibitedWords { static async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ if (!MessageTool.isModerator(interaction.member) && !client.config.whitelist.includes(interaction.member.id)) return MessageTool.youNeedRole(interaction, 'admin'); - const word = interaction.options.getString('word'); - const wordExists = await client.prohibitedWords.findWord(word); ({ view: async()=>{ const pwList = await client.prohibitedWords.getAllWords(); interaction.reply({ ephemeral: true, content: `There are currently **${pwList.length}** words in the list`, - files: [ - new client.attachment(Buffer.from(JSON.stringify(pwList.map(x=>x.dataValues.word), null, 2)), {name: 'pwDump.json'}) - ] + files: [new client.attachment(Buffer.from(JSON.stringify(pwList.map(x=>x.dataValues.word), null, 2)), {name: 'pwDump.json'})] }) }, add: async()=>{ + const word = interaction.options.getString('word'); + const wordExists = await client.prohibitedWords.findWord(word); if (wordExists) return interaction.reply({ephemeral: true, content: `\`${word}\` already exists in the list`}); else { await client.prohibitedWords.insertWord(word); @@ -34,6 +32,8 @@ export default class ProhibitedWords { } }, remove: async()=>{ + const word = interaction.options.getString('word'); + const wordExists = await client.prohibitedWords.findWord(word); if (!wordExists) return interaction.reply({ephemeral: true, content: `\`${word}\` does not exist in the list`}); else { await client.prohibitedWords.removeWord(word); diff --git a/src/components/Automod.ts b/src/components/Automod.ts index 41ef517..d661883 100644 --- a/src/components/Automod.ts +++ b/src/components/Automod.ts @@ -36,7 +36,7 @@ export default class Automoderator { clearTimeout(data.timeout); data.timeout = setTimeout(()=>delete client.repeatedMessages[message.author.id], thresholdTime); } - } + }/* static isSpam(client:TClient, message:Discord.Message, threshold:number): boolean { const now = Date.now(); const time = 30000; @@ -55,7 +55,7 @@ export default class Automoderator { data.timeout = setTimeout(()=>delete client.repeatedMessages[message.author.id], time); } return false; - } + }*/ static async imageOnly(message:Discord.Message) { const io_channels = ['468896467688620032']; let deleteReason:string = 'This is an image-only channel and your message did not contain any images.'; diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index f2b6faa..20d6ac1 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -43,7 +43,7 @@ export default class MessageCreate { await Automoderator.repeatedMessages(client, message, 'mute', 30000, 3, 'bw', '30m', 'Prohibited word spam'); } }, - { + /*{ name: 'messageSpam', check: ()=>Automoderator.isSpam(client, message, 6) && !MessageTool.isStaff(message.member as Discord.GuildMember), action: async()=>{ @@ -53,12 +53,12 @@ export default class MessageCreate { await Automoderator.repeatedMessages(client, message, 'mute', 5000, 2, 'spam', '30m', 'Message spam'); delete client.repeatedMessages[message.author.id]; } - }, + },*/ { name: 'discordInvite', - check: ()=>message.content.toLowerCase().includes('discord.gg/') && !MessageTool.isStaff(message.member as Discord.GuildMember), + check: ()=>message.content.toLowerCase().match(/discord\.(gg|com\/invite)\//ig) && !MessageTool.isStaff(message.member as Discord.GuildMember), action: async()=>{ - const validInvite = await client.fetchInvite(message.content.split(' ').find(x=>x.includes('discord.gg/'))).catch(()=>null); + const validInvite = await client.fetchInvite(message.content.split(' ').find(x=>x.match(/discord\.(gg|com\/invite)\//ig))).catch(()=>null); if (validInvite && validInvite.guild?.id !== client.config.dcServer.id) { automodded = true; message.delete().catch(()=>Logger.console('log', `${automodLog}Advertisement`, automodFailReason)); diff --git a/src/index.ts b/src/index.ts index 5fa49fc..05aa1f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ const client = new TClient; client.init(); import cron from 'node-cron'; import Logger from './helpers/Logger.js'; -import YTModule from './modules/YTModule.js'; +//import YTModule from './modules/YTModule.js'; import CacheServer from './components/CacheServer.js'; import MPModule, {refreshTimerSecs} from './modules/MPModule.js'; import UsernameHelper from './helpers/UsernameHelper.js'; @@ -26,7 +26,7 @@ if ((typeof process.argv[4] === 'string' && process.argv[4] === 'true') ?? null) // Interval timers for modules setInterval(async()=>await MPModule(client), refreshTimerSecs); -cron.schedule('0-5 * * * *', ()=>YTModule(client)); // Every minute from 0 through 5 +//cron.schedule('0-5 * * * *', ()=>YTModule(client)); // Every minute from 0 through 5 cron.schedule('5-12 * * * *', async()=>{// Every minute from 5 through 12 const forum = client.guilds.cache.get(client.config.dcServer.id).channels.cache.get(client.config.dcServer.channels.help_forum) as Discord.ForumChannel; await forum.threads.fetch();