Move overflow delay from static to .env

This commit is contained in:
Raven Scott 2023-05-05 21:07:39 +02:00
parent cb880f9bc1
commit af13ca3717
2 changed files with 6 additions and 1 deletions

View File

@ -10,6 +10,11 @@ INIT_PROMPT = "Assistant name: ChatAI. You code, write and provide any informati
# Loading Emebed Refresh Timing # Loading Emebed Refresh Timing
REFRESH_INTERVAL=10 REFRESH_INTERVAL=10
# When a message is too large for discord we chunk the response into seperate messages.
# To ensure we do not rate limit the bot we send these at a delay interval.
# DEFAULT: 3 a good setting is between 3 and 7 seconds.
OVERFLOW_DELAY=3
# Max Content to fetch from given URLs # Max Content to fetch from given URLs
MAX_CONTENT_LENGTH=2000 MAX_CONTENT_LENGTH=2000

View File

@ -157,7 +157,7 @@ client.on('messageCreate', async (message) => {
for (let i = 0; i < chunks.length; i++) { for (let i = 0; i < chunks.length; i++) {
setTimeout(() => { setTimeout(() => {
message.channel.send(chunks[i]); message.channel.send(chunks[i]);
}, i * 3000); // delay of 3 seconds between each chunk to save on API requests }, i * (process.env.OVERFLOW_DELAY || 3) * 1000); // delay of 3 seconds between each chunk to save on API requests
} }
} else { } else {
// We are good to go, send the response // We are good to go, send the response