diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..5f4a155 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,38 @@ + +## Run the Bot +* Refer to all sections below before running the bot. +* You should now have `Ollama`, `NodeJS`, ran `npm install`. +* You will also need a discord bot to run. Refer to the [developer portal](https://discord.com/developers/) to learn how to set one up and invite it to your server. If that does not help then look up a YouTube video like this [one](https://www.youtube.com/watch?v=KZ3tIGHU314&ab_channel=UnderCtrl). +* Now run `npm run start` to run the client and ollama at the same time (this must be one in wsl or a Linux distro) + + +## Set up (Development-side) +* Pull the repository using `https://github.com/kevinthedang/discord-ollama.git`. +* Refer to `Ollama Setup` in the readme to set up Ollama. + * This must be set up in a Linux environment or wsl2. +* Install NodeJS `v18.18.2` + * You can check out `Resources` and `To Run` in the readme for a bit of help. + * You can also reference [NodeJS Setup](#nodejs-setup) +* When you have the project pulled from github, open up a terminal and run `npm i` or `npm install` to get all of the packages for the project. +* In some kind of terminal (`git bash` is good) to run the client. You can run Ollama but opening up wsl2 and typing `ollama serve`. + * Refer to `Ollama Setup` if there are any issues. + +## Environment +* You will need two environment files: + * `.env`: for running the bot + * `CLIENT_TOKEN`: the token for the bot to log in + * `CHANNEL_ID`: the id of the channel you wish for the bot to listen in + * `MODEL`: the mode you wish to use + * `BOT_UID`: the user id the bot goes by (the id of the discord user) + * `.env.dev.local`: also runs the bot, but with development variables + * Currently there are no differences between the two, but when needed, you may add environment variables as needed. + +## NodeJS Setup +* Install [nvm](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating) using `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash` + * Ensure this in the profile of what shell you use (for `git bash` it would be `.bash_profile` found in your home directory) +* Ensure it has been install correctly by running `nvm -v` +* Now, install `v18.18.2` by running `nvm install 18.18.2` +* Then run `nvm use 18.18.2 | nvm alias default 18.18.2` or you can run them separately if that does not work. This just sets the default NodeJS to `v18.18.2` when launching a shell. diff --git a/.github/style.md b/.github/style.md new file mode 100644 index 0000000..c4cf3f5 --- /dev/null +++ b/.github/style.md @@ -0,0 +1,5 @@ +## Style Preferences +* Please just make sure that you are using a `Tab Default` of 4 for spacing +* You don't need semicolons at the end of everything. +* Comments for functions would be nice to help explain what they do and what the parameters are for. +* If there are any other issues, just refer to the [Google Style Guide](https://google.github.io/styleguide/tsguide.html) \ No newline at end of file diff --git a/src/client.ts b/src/client.ts index 623ec94..6151287 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,9 +1,9 @@ -import { Client, GatewayIntentBits } from "discord.js"; -import { registerEvents } from "./utils/events.js"; -import Events from "./events/index.js"; +import { Client, GatewayIntentBits } from 'discord.js' +import { registerEvents } from './utils/events.js' +import Events from './events/index.js' // Import keys/tokens -import Keys from "./keys.js"; +import Keys from './keys.js' // initialize the client with the following permissions when logging in const client = new Client({ diff --git a/src/keys.ts b/src/keys.ts index 6be5c89..9b9a91c 100644 --- a/src/keys.ts +++ b/src/keys.ts @@ -1,4 +1,4 @@ -import { getEnvVar } from "./utils/env.js" +import { getEnvVar } from './utils/env.js' export const Keys = { clientToken: getEnvVar('CLIENT_TOKEN'), diff --git a/src/utils/env.ts b/src/utils/env.ts index 6e745e9..813a77c 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -1,8 +1,8 @@ -import { resolve } from "path" -import { config } from "dotenv" +import { resolve } from 'path' +import { config } from 'dotenv' // Find config - ONLY WORKS WITH NODEMON -const envFile = process.env.NODE_ENV === "development" ? ".env.dev.local" : ".env" +const envFile = process.env.NODE_ENV === 'development' ? '.env.dev.local' : '.env' // resolve config file const envFilePath = resolve(process.cwd(), envFile) diff --git a/src/utils/messageEmbed.ts b/src/utils/messageEmbed.ts index 37e94c8..4d7de0d 100644 --- a/src/utils/messageEmbed.ts +++ b/src/utils/messageEmbed.ts @@ -1,5 +1,5 @@ -import { EmbedBuilder, Message } from "discord.js"; -import ollama, { ChatResponse } from "ollama"; +import { EmbedBuilder, Message } from 'discord.js' +import ollama, { ChatResponse } from 'ollama' /** * Method to send replies as normal text on discord like any other user diff --git a/src/utils/messageNormal.ts b/src/utils/messageNormal.ts index fb4e605..1884645 100644 --- a/src/utils/messageNormal.ts +++ b/src/utils/messageNormal.ts @@ -1,5 +1,5 @@ -import { Message } from "discord.js"; -import ollama, { ChatResponse } from "ollama"; +import { Message } from 'discord.js' +import ollama, { ChatResponse } from 'ollama' /** * Method to send replies as normal text on discord like any other user diff --git a/src/utils/streamParse.ts b/src/utils/streamParse.ts index 7ab5d8e..c9ea87c 100644 --- a/src/utils/streamParse.ts +++ b/src/utils/streamParse.ts @@ -1,4 +1,4 @@ -import { AxiosResponse } from "axios"; +import { AxiosResponse } from 'axios' /** * When running a /api/chat stream, the output needs to be parsed into an array of objects