Midoridan is a Discord bot developed using TypeScript and Discord.js. Currently, the bot offers a greeting message and can send messages to the Stable Diffusion API when prompted. The primary functionality includes generating and posting images to Discord.
- Node.js
- TypeScript
You'll need to set up some environment variables for the bot to work correctly. An example .env-sample
file is provided in the repository.
- Create a discord bot at the Discord Developer Portal.
- Create an account at Stable Diffusion.
- Grab your Discord client ID and secret and your bot token and add them to the
.env
file. - Grab your Stable Diffusion API key and add it to the
.env
file. - Adjust the links if needed (e.g. if you want to use a different API version) but as of October 2023, the links are very up to date.
You should be good to go. Further details on the configuration can be found in the Configuration section.
- Diffuse: A feature that allows you to generate images from text and post them to Discord using the Stable Diffusion API.
- Help: Provides help documentation for the bot's commands.
- Setup: Sets up the bot for your server.
- Utils: Various utility functions to make life easier for the developer.
/diffuse [options]
: Uses the Stable Diffusion API to convert text to an image and post it to the current channel./help
: Shows the currently implemented functions.
src/app.ts
: Main application file that initializes the bot.src/setup.ts
: Sets up the Discord client and REST API.src/commands/diffuse.ts
: Handles thediffuse
command (planned feature).
- ESLint: Follow the rules defined in the configuration file.
- Prettier: Code formatting is handled by Prettier.
- Node.js (version 18.18.x or higher)
- npm (version 9.8.0 or higher)
-
Clone the repository:
git clone https://github.com/soulwax/Midoridan.git
-
Navigate to the project directory:
cd Midoridan
-
Install dependencies:
npm install
To run the application, execute:
npm start
-
Copy
.env-sample
to.env
:cp .env-sample .env
-
Edit
.env
to include your specific configuration. The following environment variables can be set:
DISCORD_CLIENT_ID
: Your Discord client ID.DISCORD_CLIENT_SECRET
: Your Discord client secret.DISCORD_TOKEN
: Your Discord bot token.STABLE_DIFFUSION_API_KEY
: Your API key for Stable Diffusion API.GENERAL_CHANNEL_ID
: Currently unused but one could limit the bot to post only there.TEXT_TO_IMAGE_API_URL
: The URL of the Stable Diffusion API for Text to Image.IMAGE_TO_IMAGE_API_URL
: The URL of the Stable Diffusion API for Image to Image.
This project uses ESLint for linting. To run the linter, execute:
npm run lint
During development, you should run npm run watch
to compile on the fly while you're working on the code.
Provided the correct use of the .vscode/launch.json file, you can debug the code and react to changes immediately while watching is running, without having to restart the bot all the time. This is especially useful when working on the bot's commands.
This project uses Prettier for code formatting. To format the code, execute: Current rules can be seen in the .prettierrc file.
The project is currently tested manually. Automated testing will be implemented in the future. Pull requests are welcome.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.
This project is licensed under the GPL-3.0 License.