Discord bot implemented using the Bun runtime and Discord JS, using Typescript for type safety. The bot is made to have as little external dependencies as possible, so a lot of things are manually implemented. The bot was written long ago, going under the nickname "Suno" (sus noodle), so I'm migrating much of that code using modern tools and releasing it as FOSS for others to use and learn from it. Yes, the logo is the Bun logo, modified to look like Discord.
Currently the bot is a work in progress.
-
Follow the instructions from https://discordjs.guide/preparations/setting-up-a-bot-application.html and https://discordjs.guide/preparations/adding-your-bot-to-servers.html to create the basic bot.
-
Clone the repo and install dependencies:
Make sure Bun is installed and at its latest version.
git clone https://github.com/document10/dumpling-bot
cd dumpling-bot
bun install-
Setup environment variables (
.env) according to the instructions fromexample.env. -
Register the commands to the Discord API using:
bun deploy-globalor just to the development guild using:
bun deploy-localIt's recommended to use the local deployment during development to avoid rate limits.
- Setup the database
Using databases other than PostgresSQL requires v1.2.21 or newer.
bun db-setupOptionally set DATABASE_SECRETS to YES so that all sensitive info (like API keys) are stored and loaded from the database instead of .env. Then load them from the .env file:
bun db-secrets- Start the bot:
bun startor in dev mode for restarting on changes:
bun devOptionally, you can update the following fields in package.json to reflect the current state of the bot (when using the /about command):
author
author_website
source_host
homepage
keywords
version
bun dev: Start the bot in development mode, automatically restarting on changes.bun db-export: Backs up the database contents to a file.bun db-purge: Removes all tables related to the bot from the database. (VERY DANGEROUS)bun db-help: Displays help information for the database commands.bun format: Formats the codebase using Deno.