Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Docker Branch #15

Open
wants to merge 56 commits into
base: Docker
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8680983
⚒️ Additional info to Safety Error Message
TecEash1 Mar 11, 2024
f9314cd
Add SDXL Models
TecEash1 Mar 23, 2024
89ffe73
Add context menu AI
TecEash1 Mar 24, 2024
7f546d4
Add Model autocomplete
TecEash1 Mar 24, 2024
faf1cb0
Fixes - Context Menu
TecEash1 Mar 24, 2024
9b2e9bb
Implement User Commands
TecEash1 Mar 26, 2024
a62533d
Update Google Generative AI Package
TecEash1 Mar 27, 2024
3b6420e
Fix User Slash command issues
TecEash1 Mar 28, 2024
481b217
Switch to Gemini 1.5 Pro Model [V1.BETA]
TecEash1 Apr 10, 2024
b88c5c1
Fix Thread Errors
TecEash1 Apr 11, 2024
2898342
Update Packages
TecEash1 Apr 11, 2024
435d65c
Format with Prettier
TecEash1 Apr 11, 2024
76f8a1d
Update Error Messages
TecEash1 Apr 11, 2024
7de23b8
Utilise System Instructions
TecEash1 Apr 12, 2024
dadf08d
Notices & Cleanup
TecEash1 Apr 12, 2024
9ac7101
Switch to PNPM (NPM -> PNPM)
TecEash1 Apr 12, 2024
b0f8dc2
Add PNPM Install command to start script
TecEash1 Apr 12, 2024
1fb29a6
Resolves #21
TecEash1 Apr 13, 2024
7cbe98b
Resolves #22
TecEash1 Apr 13, 2024
57f33b2
Resolves #17
TecEash1 Apr 13, 2024
17dd9dd
Utilise client avatar for webhook
TecEash1 Apr 14, 2024
512ea04
Resolves #18
TecEash1 Apr 14, 2024
f9b3bf6
Update README.md
TecEash1 Apr 21, 2024
78ec3b5
Update Packages
TecEash1 Apr 21, 2024
0d515f7
Notice for history - context menu
TecEash1 Apr 22, 2024
d747871
Resolves #24
TecEash1 Apr 23, 2024
dec09a7
Resolves #26
TecEash1 Apr 27, 2024
f674ced
Update Version
TecEash1 Apr 27, 2024
1492306
Resolves #30
TecEash1 Apr 29, 2024
6d61a67
Resolves #29
TecEash1 Apr 29, 2024
33226ac
Fix error when user replies to bot embeds
TecEash1 Apr 29, 2024
540b409
Resolves #31
TecEash1 Apr 30, 2024
50b9651
Formatting
TecEash1 May 2, 2024
e901a31
Fix response too long error
TecEash1 May 2, 2024
74880e6
Update version
TecEash1 May 2, 2024
e433bdf
Update Packages
TecEash1 May 2, 2024
ba696c9
Resolves #35
TecEash1 May 6, 2024
27a6ebe
Update Packages
TecEash1 May 11, 2024
c89fc9c
Update README.md
TecEash1 May 11, 2024
7149bf0
Update README.md
TecEash1 May 11, 2024
8d9ab9f
Upgrade Image Command
TecEash1 May 13, 2024
ba005bf
Resolves #33
TecEash1 May 14, 2024
11fe1c7
Utilise Gemini 1.5 Flash!
TecEash1 May 14, 2024
89c82a7
Update Error Handling
TecEash1 May 14, 2024
185af84
Implement Settings Menu + Other Changes
TecEash1 May 17, 2024
cdfc9a1
Implement Load Balancing
TecEash1 May 17, 2024
5e07692
Update Packages
TecEash1 May 17, 2024
d92b1ab
Update README.md
TecEash1 May 17, 2024
e8cb489
Fix Console Webhook Live Update
TecEash1 May 19, 2024
227abce
Fix Critical Console Error
TecEash1 May 20, 2024
b10ffa2
Improve Image Gen Performance + Fixes
TecEash1 May 22, 2024
75eee97
SafetySettings Disabled/Enabler
TecEash1 May 22, 2024
c136745
Remove API Key
TecEash1 May 22, 2024
f5e13f4
Fix Fallback System
TecEash1 May 26, 2024
3713e21
Remove unused gemini key, fix ai ping error potentially
TecEash1 May 27, 2024
a842afb
Update Status
TecEash1 May 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
.vscode/
.idea/
.node-version
/functions/other/settings.sqlite
/personality.txt

# Logs
logs
Expand Down Expand Up @@ -108,4 +110,4 @@ dist
.dynamodb/

# TernJS port file
.tern-port
.tern-port
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.github
package.json
pnpm-lock.yaml
60 changes: 50 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,70 @@
<img align="right" width="310" alt="image" src="https://github.com/TecEash1/TecEash1/assets/92249532/bd4aca7e-daab-4eeb-9265-e53cc1925e8c">
</p>

## 🤔 What is this bot?
The **Taurus Discord Bot** is a small bot, it can be used for several things such as:
- Image Generation
- AI GPT chats and personality customisations
# 🤔 What is Taurus?

The Taurus Discord Bot is a small bot with a big impact. It offers several features, including advanced image generation, AI chats, and more.

<details>
<summary>💬 AI Chats</summary>

- Powered by Google's [Gemini 1.5 Model](https://deepmind.google/technologies/gemini/#gemini-1.5)
- Has a configurable global personality via the ``/personalise`` slash command
- Remembers past messages

**Ways to interact:**
- Context Menus
- Mention the Bot with your message
- Utilise the ``/taurus`` slash command

</details>

<details>
<summary>🖼️ Advanced Image Generation</summary>

- 70+ Models
- 17 Style Presets
- Negative Prompt Customisation
- A toggleable NSFW image blocker
- Supports different languages
- And much more!

</details>

<details>
<summary>🔧 Additional Features</summary>

- Live Console Logging in Discord
- Personality update logs in Discord
- User Commands - Use the bot anywhere on Discord
- An optional CLI via the start scripts
- A Settings Menu in Discord
</details>

## 💾 Install

1. fill in the token and other values in ``config.json.example``
1. fill in the token and other values in `config.json.example`

2. Rename the file to `config.json`

2. Rename the file to ``config.json``
3. Run `pnpm i`

3. Run ``npm i``
4. Run `node .`

4. Run ``node bot``
5. In Discord run ``/settings`` and fill in the values

**Note** - Alternatively **instead of steps 3 & 4** you can **run one of the startbot/start scripts.**
> [!NOTE]
> - Alternatively **instead of steps 3 & 4** you can **run one of the startbot/start scripts.** *(Reccomended)*
> - If you do not have pnpm installed you will need to run: ``npm install -g pnpm``

- All PR's are welcome for improvements.

### ℹ️ Getting API Keys:

- https://ai.google.dev
- https://app.prodia.com/api

### 🏗️ Additional Credits

- This bot utilizes a modified version of the [discord bot template](https://github.com/NamVr/DiscordBot-Template) made
by [Naman Vrati](https://github.com/NamVr)! [\[Apache License 2.0\]](https://github.com/NamVr/DiscordBot-Template/blob/master/LICENSE)
by [Naman Vrati](https://github.com/NamVr)! [\[Apache License 2.0\]](https://github.com/NamVr/DiscordBot-Template/blob/master/LICENSE)
140 changes: 122 additions & 18 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const {
GatewayIntentBits,
Partials,
REST,
Routes
Routes,
SlashCommandBuilder,
} = require("discord.js");
const { token, client_id } = require("./config.json");

Expand Down Expand Up @@ -57,7 +58,7 @@ for (const file of eventFiles) {
} else {
client.on(
event.name,
async (...args) => await event.execute(...args, client)
async (...args) => await event.execute(...args, client),
);
}
}
Expand All @@ -66,8 +67,11 @@ for (const file of eventFiles) {
// Define Collection of Slash/Modal Commands and Cooldowns

client.slashCommands = new Collection();
client.buttonCommands = new Collection();
client.modalCommands = new Collection();
client.contextCommands = new Collection();
client.cooldowns = new Collection();
client.autocompleteInteractions = new Collection();
client.functions = new Collection();

/**********************************************************************/
Expand All @@ -93,6 +97,78 @@ for (const module of slashCommands) {
}
}

/**********************************************************************/
// Registration of Autocomplete Interactions.

/**
* @type {String[]}
* @description All autocomplete interactions.
*/

const autocompleteInteractions = fs.readdirSync("./interactions/autocomplete");

// Loop through all files and store autocomplete interactions in autocompleteInteractions collection.

for (const module of autocompleteInteractions) {
const files = fs
.readdirSync(`./interactions/autocomplete/${module}`)
.filter((file) => file.endsWith(".js"));

for (const interactionFile of files) {
const interaction = require(
`./interactions/autocomplete/${module}/${interactionFile}`,
);
client.autocompleteInteractions.set(interaction.name, interaction);
}
}

/**********************************************************************/
// Registration of Context-Menu Interactions

/**
* @type {String[]}
* @description All Context Menu commands.
*/

const contextMenus = fs.readdirSync("./interactions/context-menus");

// Loop through all files and store context-menus in contextMenus collection.

for (const folder of contextMenus) {
const files = fs
.readdirSync(`./interactions/context-menus/${folder}`)
.filter((file) => file.endsWith(".js"));
for (const file of files) {
const menu = require(`./interactions/context-menus/${folder}/${file}`);
const keyName = `${folder.toUpperCase()} ${menu.data.name}`;
client.contextCommands.set(keyName, menu);
}
}

/**********************************************************************/
// Registration of Button-Command Interactions.

/**
* @type {String[]}
* @description All button commands.
*/

const buttonCommands = fs.readdirSync("./interactions/buttons");

// Loop through all files and store button-commands in buttonCommands collection.

for (const module of buttonCommands) {
const commandFiles = fs
.readdirSync(`./interactions/buttons/${module}`)
.filter((file) => file.endsWith(".js"));

for (const commandFile of commandFiles) {
const command = require(`./interactions/buttons/${module}/${commandFile}`);
for (const id of command.id) {
client.buttonCommands.set(id, command);
}
}
}

/**********************************************************************/
// Registration of Modal-Command Interactions.
Expand All @@ -113,7 +189,13 @@ for (const module of modalCommands) {

for (const commandFile of commandFiles) {
const command = require(`./interactions/modals/${module}/${commandFile}`);
client.modalCommands.set(command.id, command);
if (Array.isArray(command.id)) {
for (const id of command.id) {
client.modalCommands.set(id, command);
}
} else {
client.modalCommands.set(command.id, command);
}
}
}

Expand All @@ -125,25 +207,37 @@ for (const module of modalCommands) {
* @description All functions.
*/

const functionFiles = fs.readdirSync("./functions");

// Loop through all files and store functions in functions collection.
client.once("ready", () => {
const functionFiles = fs.readdirSync("./functions");

for (const functionFile of functionFiles) {
if (functionFile.endsWith(".js")) {
const func = require(`./functions/${functionFile}`);
client.functions.set(functionFile.replace('.js', ''), func);
func(client);
}
}
for (const functionFile of functionFiles) {
if (functionFile.endsWith(".js")) {
const func = require(`./functions/${functionFile}`);
client.functions.set(functionFile.replace(".js", ""), func);
func(client);
}
}
});

/**********************************************************************/
// Registration of Slash-Commands in Discord API

const rest = new REST({ version: "9" }).setToken(token);

const commandJsonData = [
...Array.from(client.slashCommands.values()).map((c) => c.data.toJSON()),
...Array.from(client.slashCommands.values()).map((c) => {
const commandData =
c.data instanceof SlashCommandBuilder ? c.data.toJSON() : c.data;
commandData.integration_types = [0, 1];
commandData.contexts = [0, 1, 2];
return commandData;
}),
...Array.from(client.contextCommands.values()).map((c) => {
const commandData = c.data;
commandData.integration_types = [0, 1];
commandData.contexts = [0, 1, 2];
return commandData;
}),
];

(async () => {
Expand All @@ -153,7 +247,7 @@ const commandJsonData = [
await rest.put(
Routes.applicationCommands(client_id),

{ body: commandJsonData }
{ body: commandJsonData },
);

console.log("Successfully reloaded application (/) commands.");
Expand All @@ -168,10 +262,20 @@ client.login(token);

/**********************************************************************/
// Anti Crash script

process.on("unhandRejection", (reason, promise) => {
process.on("unhandledRejection", (reason, promise) => {
console.error(`🚫 Critical Error detected:\n\n`, reason, promise);

// Uncomment the below lines below to see the full error details. - ADVANCED DEBUGGING //

// console.dir(reason, { showHidden: true, depth: null });
// console.log("Promise: ", promise);
});

process.on("uncaughtException", (error, origin) => {
console.error(`🚫 Critical Error detected:\n\n`, error, origin);
});

// Uncomment the below lines below to see the full error details. - ADVANCED DEBUGGING //

// console.dir(error, { showHidden: true, depth: null });
// console.log("Origin: ", origin);
});
17 changes: 8 additions & 9 deletions config.json.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"token": "...",
"owner": ["719815864135712799","483359783831732255"],
"client_id": "...",
"guild_id_logs": "...",
"channel_id_logs": "...",
"webhook_url_console_logs": "...",
"Gemini_API_KEY": "...",
"XProdiaKey": "...",
"Block_NSFW_Images": true
"token": "...",
"owner": ["719815864135712799","483359783831732255", "OWNER USER IDS HERE"],
"client_id": "...",
"emojis": {
"loading": "⭕",
"working": "🟢",
"failed": "🔴"
}
}
46 changes: 46 additions & 0 deletions events/autocompleteInteraction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @file Autocomplete Interaction Handler
* @author Naman Vrati
* @since 3.3.0
* @version 3.3.2
*/

const { Events } = require("discord.js");

module.exports = {
name: Events.InteractionCreate,

/**
* @description Executes when an interaction is created and handle it.
* @author Naman Vrati
* @param {import('discord.js').AutocompleteInteraction & { client: import('../typings').Client }} interaction The interaction which was created
*/

async execute(interaction) {
// Deconstructed client from interaction object.
const { client } = interaction;

// Checks if the interaction is an autocomplete interaction (to prevent weird bugs)

if (!interaction.isAutocomplete()) return;

// Checks if the request is available in our code.

const request = client.autocompleteInteractions.get(
interaction.commandName,
);

// If the interaction is not a request in cache return.

if (!request) return;

// A try to execute the interaction.

try {
await request.execute(interaction);
} catch (err) {
console.error(err);
return Promise.reject(err);
}
},
};
Loading