From 27d8ad1f78a82081306df14a6d51972a1afe58be Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Mon, 10 Apr 2023 02:42:58 +0200 Subject: [PATCH] rand --- assets/emptyMessages.js | 2 +- assets/errorMessages.js | 31 +++++++++++++++++++++++-------- assets/resetMessages.js | 2 +- llamabot.js | 6 ++++-- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/assets/emptyMessages.js b/assets/emptyMessages.js index c712f18..9447a7b 100644 --- a/assets/emptyMessages.js +++ b/assets/emptyMessages.js @@ -29,4 +29,4 @@ const emptyResponses = [ "I wish I had some grand insight to share, but alas, I don't have much to offer in that regard." ]; - module.exports = emptyResponses; + module.exports = emptyResponses; \ No newline at end of file diff --git a/assets/errorMessages.js b/assets/errorMessages.js index e6e7055..f1e4cb3 100644 --- a/assets/errorMessages.js +++ b/assets/errorMessages.js @@ -21,12 +21,27 @@ const errorMessages = [ "Oopsie daisy! Give !reset a try and we'll start over." ]; - module.exports = errorMessages; + const busyResponses = [ + "Sorry about that! Looks like I'm tied up at the moment. Please try again later.", + "Oops, I'm currently busy with something else. Please try again later.", + "Looks like I'm already working on something. Can you try again later?", + "I'm currently occupied with another process. Can you try again later?", + "I'm currently unavailable. Can you try again in a bit?", + "Looks like I'm currently busy. Can you check back later?", + "I'm currently engaged with another process. Please try again later.", + "I'm afraid I'm currently occupied with another request. Can you try again later?", + "Sorry, I'm currently busy with another task. Can you try again later?", + "I'm currently tied up with another request. Please try again later.", + "Looks like I'm currently busy with something else. Can you try again later?", + "I'm currently engaged with another task. Please try again later.", + "Sorry, I'm currently occupied with another process. Can you try again later?", + "I'm currently occupied with another task. Can you try again later?", + "I'm currently in the middle of another process. Can you try again later?", + "Sorry, I'm currently engaged with another task. Please try again later.", + "I'm currently in the middle of something else. Please try again later.", + "I'm afraid I'm busy with something else at the moment. Can you try again later?", + "Looks like I'm currently engaged with something else. Please try again later.", + "I'm currently unavailable. Can you try again later?" + ]; - - - - - - - \ No newline at end of file + module.exports = { errorMessages, busyResponses}; \ No newline at end of file diff --git a/assets/resetMessages.js b/assets/resetMessages.js index bc015a1..eac922c 100644 --- a/assets/resetMessages.js +++ b/assets/resetMessages.js @@ -44,4 +44,4 @@ const resetResponses = [ "Conversation reset, confirmed! What do you need help with?" ]; - module.exports = {resetResponses, userResetMessages}; + module.exports = {resetResponses, userResetMessages}; \ No newline at end of file diff --git a/llamabot.js b/llamabot.js index 0e7a6af..3f3365e 100644 --- a/llamabot.js +++ b/llamabot.js @@ -2,7 +2,7 @@ const Discord = require('discord.js'); const fetch = require('node-fetch'); const emptyResponses = require('./assets/emptyMessages.js'); const {resetResponses, userResetMessages} = require('./assets/resetMessages.js'); -const errorMessages = require('./assets/errorMessages.js'); +const {errorMessages, busyResponses} = require('./assets/errorMessages.js'); require('dotenv').config() // hi @@ -49,7 +49,8 @@ client.on('messageCreate', async (message) => { if (conversations.get(message.author.id)?.busy) { message.delete() - await message.author.send("I'm currently busy with another process. Please try again later."); + const busyResponse = busyResponses[Math.floor(Math.random() * busyResponses.length)]; + await message.author.send(busyResponse); // give a notification of reset using a human like response. return; } @@ -152,6 +153,7 @@ async function generateResponse(conversation) { }); const responseData = await response.json(); + console.log(JSON.stringify(responseData)) const choice = responseData.choices[0]; // Remove "user None:" and any text after it from the response