Skip to content

Commit

Permalink
WOKEGPT
Browse files Browse the repository at this point in the history
  • Loading branch information
artifishvr committed Apr 17, 2024
1 parent 1133c0b commit dce67ae
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
37 changes: 35 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { joinVoiceChannel, createAudioPlayer, createAudioResource } from '@disco
import fs from 'fs';
import path from 'path';
import { DateTime } from 'luxon';
import axios from 'axios';

import { io } from "socket.io-client";
import { MsEdgeTTS } from "msedge-tts";
Expand Down Expand Up @@ -53,6 +54,37 @@ function shouldIReply(message) {
return true;
}

async function getPronouns(userid) {
// this is spagetti i'm sorry
try {
const response = await axios.get('/api/v2/lookup', {
baseURL: 'https://pronoundb.org',
params: {
platform: 'discord',
ids: userid
}
});

let pronounsresponse = response.data;



for (let userId in pronounsresponse) {
if (pronounsresponse[userId].sets.hasOwnProperty('en')) {
pronounsresponse[userId] = pronounsresponse[userId].sets['en'].join('/');
} else {
pronounsresponse[userId] = 'they/them';
}
}
if (!pronounsresponse.hasOwnProperty(userid)) {
pronounsresponse[userid] = 'they/them';
}

return pronounsresponse[userid];
} catch (error) {
console.error(error);
}
}

client.on("messageCreate", async message => {
if (message.author.bot) return;
Expand Down Expand Up @@ -94,9 +126,10 @@ client.on("messageCreate", async message => {
await Promise.all(promises);
}

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

let formattedUserMessage = `${message.author.username} (${pronouns}) at ${DateTime.now().setZone('utc').toLocaleString(DateTime.DATETIME_FULL)}: ${message.content}\n${imageDetails}`;
if (message.reference) {
await message.fetchReference().then(async (reply) => {
formattedUserMessage = `> ${reply}\n${formattedUserMessage}`;
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.26.4",
"version": "1.27.0",
"description": "custom AI chatbot for discord",
"main": "index.js",
"type": "module",
Expand All @@ -12,6 +12,7 @@
"license": "AGPL-3.0",
"dependencies": {
"@discordjs/voice": "^0.16.1",
"axios": "^1.6.8",
"discord.js": "^14.13.0",
"dotenv": "^16.3.1",
"ffmpeg-static": "^5.2.0",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dce67ae

Please sign in to comment.