From 7003351eccfab419a0b0fa7ec0b7d6cbd48b5097 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 21 Jun 2024 15:02:22 -0400 Subject: [PATCH] Updating how autoresponses are handled to be cleaner --- functions.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ main.js | 15 +++++---------- strings.json | 44 ++++++++++++++++++++++++++++++++++++-------- 3 files changed, 90 insertions(+), 18 deletions(-) diff --git a/functions.js b/functions.js index fdb1492..c3b5486 100644 --- a/functions.js +++ b/functions.js @@ -649,6 +649,55 @@ const functions = { return newText + ' <:spongebob:1053398825965985822>'; }, + autoresponses: { // Specific responses for certain keywords in sent messages + checkForAll(messageContent) { + let responses = []; + if (this.bigDoinks(messageContent)) responses.push("bigDoinks"); + if (this.ligma(messageContent)) responses.push("ligma"); + if (this.ong(messageContent)) responses.push("ong"); + return responses; + }, + bigDoinks(messageContent) { + let count = 0; + const { keywords } = strings.autoresponses.bigDoinks; + keywords.forEach(e => { + if (messageContent.includes(e)) count++; + }); + if (count === keywords.length) { + return true; + } + }, + ligma(messageContent) { + let count = 0; + const { keywords } = strings.autoresponses.ligma; + keywords.forEach(e => { + if (messageContent.includes(e)) count++; + }); + if (count > 0) { + return true; + } + }, + ong(messageContent) { + let count = 0; + const { keywords } = strings.autoresponses.ong; + keywords.forEach(e => { + if (messageContent.includes(e)) count++; + }); + if (count > 0) { + return true; + } + }, + send(message, responseType) { + const { responses } = strings.autoresponses[responseType]; + const randomIndex = Math.floor(Math.random() * responses.length); + const response = responses[randomIndex]; + try { + message.reply(response); + } catch(e) { + console.log(new Error(e)); + } + } + }, generateErrorId() { const digitCount = 10; const digits = []; diff --git a/main.js b/main.js index 584a89c..4527304 100644 --- a/main.js +++ b/main.js @@ -221,17 +221,12 @@ client.on('messageCreate', message => { // Some basic checking to prevent running unnecessary code if (message.author.bot) return; - // Wildcard Responses, will respond if any message contains the trigger word(s), excluding self-messages + // Automatic Responses, will respond if any message contains the keyword(s), excluding self-messages const lowerContent = message.content.toLowerCase(); - // big + doinks - if (lowerContent.includes('big') && lowerContent.includes('doinks')) message.reply('gang.'); - // ligma - if (lowerContent.includes('ligma')) message.reply('ligma balls, goteem'); - // frfr, fr fr , bussin, ong - if (lowerContent.includes('frfr') || lowerContent.includes('fr fr') || lowerContent.includes('bussin') || lowerContent.includes(' ong') || lowerContent.startsWith('ong')) { - const randIndex = Math.floor(Math.random() * strings.capbacks.length); - message.reply(strings.capbacks[randIndex]); - } + const autoresponses = fn.autoresponses.checkForAll(lowerContent); + autoresponses.forEach(e => { + fn.autoresponses.send(message, e); + }); // Break the message down into its components and analyze it const commandData = fn.dot.getCommandData(message); diff --git a/strings.json b/strings.json index 94ee7cf..134d225 100644 --- a/strings.json +++ b/strings.json @@ -14,14 +14,6 @@ "urls": { "avatar": "https://cdn.discordapp.com/avatars/513184762073055252/12227aa23a06d5178853e59b72c7487b.webp?size=128" }, - "capbacks": [ - "on god?!", - "fr fr?!", - "no cap?!", - "no cap fr", - "bussin fr, no cap", - "ongggg no :billed_cap: fr fr" - ], "costs": { "gpt": { "gpt-3.5-turbo": 0.2 @@ -39,5 +31,41 @@ "chatResCentsPer": 0.2, "chatResUnits": 1000 }, + "autoresponses": { + "bigDoinks": { + "keywords": ["big", "doinks"], + "responses": [ + "<:bigdoinks:1053706618853924905> Gang.", + "<:bigdoinks:1053706618853924905> Out here in Amish", + "<:bigdoinks:1053706618853924905> Out here in Amish, smoking Big Doinks in Amish... Gang." + ] + }, + "ligma": { + "keywords": ["ligma"], + "responses": [ + "ligma balls lmao gottem", + "ligma balls ahaha", + "https://tenor.com/view/ligma-balls-gif-12236083", + "<:deadmonkey:1139186312444911707>" + ] + }, + "ong": { + "keywords": [ + "frfr", + "fr fr", + "bussin", + "no cap", + " ong " + ], + "responses": [ + "on god?!", + "fr fr?!", + "no cap?!", + "no cap fr", + "bussin fr, no cap", + "ongggg no :billed_cap: fr fr" + ] + } + }, "temp": {} } \ No newline at end of file