Skip to content

Commit

Permalink
refactor reply handling, provide datetime to cai!
Browse files Browse the repository at this point in the history
Closes #29 (record time!)
  • Loading branch information
artifishvr committed Apr 14, 2024
1 parent 5957c29 commit 6d7109a
Show file tree
Hide file tree
Showing 3 changed files with 1,586 additions and 13 deletions.
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Client, GatewayIntentBits } from 'discord.js'

import fs from 'fs'
import path from 'path';
import { DateTime } from 'luxon';

import { io } from "socket.io-client";
import CharacterAI from 'node_characterai';
Expand Down Expand Up @@ -96,14 +97,13 @@ client.on("messageCreate", async message => {
}

// Send message to CharacterAI
let formattedUserMessage;
let formattedUserMessage = `${message.author.username} at ${DateTime.now().setZone('utc').toLocaleString(DateTime.DATETIME_FULL)}: ${message.content}\n${imageDetails}`;

if (message.reference) {
await message.fetchReference().then((reply) => {
formattedUserMessage = `> ${reply}\n${message.author.displayName}: ${message.content}\n${imageDetails}`;
await message.fetchReference().then(async (reply) => {
formattedUserMessage = `> ${reply}\n${formattedUserMessage}`;
});
} else {
formattedUserMessage = `${message.author.displayName}: ${message.content}\n${imageDetails}`;
}
};

message.channel.sendTyping();
let response = await chat.sendAndAwaitResponse(formattedUserMessage, true);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spongegpt",
"version": "1.24.5",
"version": "1.25.0",
"description": "custom AI chatbot for discord",
"main": "index.js",
"type": "module",
Expand All @@ -14,6 +14,7 @@
"discord.js": "^14.13.0",
"dotenv": "^16.3.1",
"locate-chrome": "^0.1.1",
"luxon": "^3.4.4",
"node_characterai": "^1.2.7",
"socket.io-client": "^4.7.2"
},
Expand Down
Loading

0 comments on commit 6d7109a

Please sign in to comment.