Skip to content

Commit

Permalink
PermissionFlagsBits
Browse files Browse the repository at this point in the history
  • Loading branch information
Erisfiregamer1 committed Apr 4, 2024
1 parent c8bc496 commit 4f939e5
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 83 deletions.
5 changes: 3 additions & 2 deletions bots/chatgpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const tools: types.Tool[] = [{
},
}];

export const information = {
llmFileVersion: 1.0,
export const information: types.information = {
llmFileVersion: "1.0",
env: ["OPENAI_API_KEY"],
functions: true,
functionsData: tools,
Expand All @@ -32,6 +32,7 @@ export const information = {
name: "GPT-3.5",
description:
"OpenAI's original flagship chat model, a low cost and quick to use model for general purposes.",
highCostLLM: false
};

async function doTools(
Expand Down
5 changes: 3 additions & 2 deletions bots/gpt_4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const tools: types.Tool[] = [{
},
}];

export const information = {
llmFileVersion: 1.0,
export const information: types.information = {
llmFileVersion: "1.0",
env: ["OPENAI_API_KEY"],
functions: true,
functionsData: tools,
Expand All @@ -32,6 +32,7 @@ export const information = {
name: "GPT-4",
description:
"An upgraded version of ChatGPT (GPT-3.5). Much better at answering questions!",
highCostLLM: true
};

async function doTools(
Expand Down
5 changes: 3 additions & 2 deletions bots/gpt_4_vision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const tools: types.Tool[] = [{
},
}];

export const information = {
llmFileVersion: 1.0,
export const information: types.information = {
llmFileVersion: "1.0",
env: ["OPENAI_API_KEY"],
functions: true,
functionsData: tools,
Expand All @@ -31,6 +31,7 @@ export const information = {
id: "gpt4v",
name: "GPT-4 Vision",
description: "A further upgraded version of GPT-4 with vision capabilities.",
highCostLLM: true
};

async function doTools(
Expand Down
5 changes: 3 additions & 2 deletions bots/mixtral.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as types from "../main.d.ts";

export const information = {
llmFileVersion: 1.0,
export const information: types.information = {
llmFileVersion: "1.0",
env: ["GROQ_API_KEY"],
functions: false,
multiModal: false,
Expand All @@ -10,6 +10,7 @@ export const information = {
id: "mixtral-groq",
name: "Mixtral (Groq)",
description: "Mistral's MOE model. Powered by Groq!",
highCostLLM: false
};

// const db = await Deno.openKv("./db.sqlite")
Expand Down
1 change: 1 addition & 0 deletions main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export type information = {
id: string;
name: string;
description: string;
highCostLLM: boolean;
};

export type Requirements = {
Expand Down
50 changes: 39 additions & 11 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
/// <reference lib="deno.unstable" />

import * as types from "./main.d.ts";

type messageData = {
id: string;
messages: types.Message[];
};

import client from "./client.ts";

import { walk, existsSync } from "https://deno.land/std@0.221.0/fs/mod.ts";

import importLLMFile from "./importLLMFile.ts";
Expand All @@ -25,13 +16,22 @@ for await (const entry of await walk("./bots")) {
}
}

import * as types from "./main.d.ts";

type messageData = {
id: string;
messages: types.Message[];
};

import client from "./client.ts";


console.log(
"Everything looks good!",
Object.keys(availableLLMs).length,
"LLMs were imported.",
);


await import("./slashcode.ts");

import { ChannelType, Message } from "npm:discord.js";
Expand Down Expand Up @@ -127,10 +127,24 @@ const getImagesFromMessage = async (message: Message<boolean>) => {
};

client.on("messageCreate", async (message) => {
let isBotChannel = (await db.get<boolean>([
"channels",
message.channel.id
])).value;

if (isBotChannel === null) {
await db.set(
["channels", message.channel.id],
false,
);

isBotChannel = false
}

if (message.author.bot || JSON.stringify(message.flags) === "4096") return; // The "4096" flag is the @silent flag on discord.
if (
message.channel.type === ChannelType.DM ||
message.channel.id === "1083904151479652392"
isBotChannel
) {
let error = false; // Tracks if we've already pestered the user with an error / message :\

Expand All @@ -153,6 +167,20 @@ client.on("messageCreate", async (message) => {
return
}

if (availableLLMs[llm].information.highCostLLM && Deno.env.get("PREMIUM_ENFORCEMENT") === "true") {
const guild = client.guilds.resolve(Deno.env.get("PRIMARY_GUILD") || "0");
if (guild) {
const member = await guild?.members.fetch(message.author.id);
if (!member.premiumSince && Deno.env.get("PRIMARY_GUILD") !== message.guild?.id) {
message.reply("This LLM is for premium users only! Boost the server to gain access to this LLM, or join the bot host's primary server!")
return
}
} else {
message.reply("your developer is terrible at his job (Premium lock config not set properly! This LLM is marked as high-cost, have the owner of the bot finish setup.)")
return
}
}

let isMessageProcessing = (await db.get<boolean>([
"users",
message.author.id,
Expand Down
Loading

0 comments on commit 4f939e5

Please sign in to comment.