diff --git a/docs/custom-commands.md b/docs/custom-commands.md index 5b3805f5..f7a19375 100644 --- a/docs/custom-commands.md +++ b/docs/custom-commands.md @@ -29,7 +29,7 @@ As you can see, each command is grouped into categories, which are represented b !!! tip - When using Node.js v23.6.0 or above, Node.js v22.6.0 or above with the `--experimental-strip-types` flag enabled, Deno, or Bun, it is possible to create commands using TypeScript instead of JavaScript. To do so, simply create a file with a `.ts` extension instead of `.js`; the command will be loaded and handled at runtime as if it were a regular JavaScript command. + When using Node.js v23.6.0 or above, Node.js v22.6.0 or above with the `--experimental-strip-types` flag enabled, or Deno, it is possible to create commands using TypeScript instead of JavaScript. To do so, simply create a file with a `.ts` extension instead of `.js`; the command will be loaded and handled at runtime as if it were a regular JavaScript command. ## Command Structure diff --git a/docs/runtimes.md b/docs/runtimes.md index a26107f0..57047621 100644 --- a/docs/runtimes.md +++ b/docs/runtimes.md @@ -1,40 +1,32 @@ # Runtime Compatibility -esmBot is primarily developed to run on the [Node.js](https://nodejs.org) runtime, using Node.js modules and APIs. However, since esmBot was originally released, two other major runtimes have appeared: [Deno](https://deno.com) and [Bun](https://bun.sh). Despite primarily targeting Node.js, esmBot is capable of running on both of these runtimes as well; this page exists to document specific details regarding running it on Deno and Bun. +esmBot is developed using Node.js modules and APIs, and officially supports both the Node.js and Deno runtimes. This page exists to document specific details and runtime-specific differences when running esmBot. !!! warning - esmBot on other runtimes can be prone to bugs. If you find any issues while running the bot on Bun or Deno, please test if the same issue occurs on Node; if it doesn't, then specify that it's an issue specific to the runtime being used and provide the version you experienced the bug on (you can find this by running `bun --version` on Bun or `deno --version` on Deno). + esmBot primarily targets Node.js, and as such running on Deno could introduce extra bugs. If you find any issues while running the bot on Deno, please test if the same issue occurs on Node; if it doesn't, then specify that it's an issue specific to Deno and provide the version you experienced the bug on (you can find this by running `deno --version`). ## Setup -esmBot requires Node.js 22.0.0, Bun 1.1, or Deno 2.3 minimum to run. +esmBot requires Node.js 22.0.0 or Deno 2.3 minimum to run. -To set up the bot for usage with Deno or Bun, follow the [setup guide](https://docs.esmbot.net/setup) as usual. However, depending on which runtime you choose, the launch command will be different: +To set up the bot for usage with Deno, follow the [setup guide](https://docs.esmbot.net/setup) as usual. However, depending on which runtime you choose, the launch command will be different: - Node.js: `pnpm start` -- Bun: `pnpm start:bun` - Deno: `pnpm start:deno` -Additionally, you can replace `pnpm build` with `pnpm build:natives` when running with Bun or Deno, since they are capable of executing TypeScript directly without transpiling to JavaScript first. +Additionally, you can replace `pnpm build` with `pnpm build:natives` when running with Deno, since they are capable of executing TypeScript directly without transpiling to JavaScript first. ## Differences -esmBot uses some features present in Deno and Bun (but missing in Node.js) when detected to add extra capabilities or improve performance in certain cases. - -Here's the current list of behavior changes when Deno or Bun are detected: - -- The stats command shows the version number of the currently used runtime instead of Node's - -Here's the current list of behavior changes exclusive to Bun: - -- The SQLite database driver uses `bun:sqlite` instead of `better-sqlite3` +esmBot uses some Deno-specific utilities when detected to add extra capabilities or improve performance in certain cases. Here's the current list of behavior changes exclusive to Deno: +- The stats command shows Deno's version number instead of Node's - The SQLite database driver uses `@db/sqlite` from [JSR](https://jsr.io/@db/sqlite) instead of `better-sqlite3` - Database plugins are loaded with the `.ts` extension instead of `.js` ## Known Issues -- You may experience crashes on startup involving native modules (e.g. better-sqlite3, the media natives) when running with Deno or Bun. For Deno, try switching your Node.js version to 22 and running `pnpm rebuild`. For Bun, you should switch to Node.js 24 and then run the same command. +- You may experience crashes on startup involving native modules (e.g. better-sqlite3, the media natives) when running with Deno. If this happens on your end, try switching your Node.js version to 22 and running `pnpm rebuild`. diff --git a/eslint.config.js b/eslint.config.js index 558de201..69ad4c1a 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -26,9 +26,6 @@ export default tseslint.config( settings: { "import-x/resolver": { name: "tsResolver", - options: { - bun: true, - }, resolver: tsResolver, }, }, diff --git a/locales/en-US.json b/locales/en-US.json index 08e3d57c..fe2b878b 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -914,7 +914,6 @@ }, "stats": { "botUptime": "Bot Uptime", - "bunVersion": "Bun Version", "connectionUptime": "Connection Uptime", "denoVersion": "Deno Version", "header": "esmBot Statistics", diff --git a/package.json b/package.json index 14f0568b..35e4c6d5 100644 --- a/package.json +++ b/package.json @@ -26,16 +26,12 @@ "format:check": "prettier --check .", "lint": "eslint .", "start": "node dist/app.js", - "start:bun": "bun src/app.ts", "start:deno": "deno -P src/app.ts", "start:debug": "DEBUG=true node dist/app.js", - "start:bun:debug": "DEBUG=true bun src/app.ts", "start:deno:debug": "DEBUG=true deno -P src/app.ts", "start-api": "node dist/api/index.js", - "start-api:bun": "bun src/api/index.ts", "start-api:deno": "deno -P src/api/index.ts", "start-api:debug": "DEBUG=true node dist/api/index.js", - "start-api:bun:debug": "DEBUG=true bun src/api/index.ts", "start-api:deno:debug": "DEBUG=true deno -P src/api/index.ts" }, "author": "Essem ", @@ -64,7 +60,6 @@ "@eslint/compat": "^2.0.0", "@eslint/js": "^9.39.1", "@types/better-sqlite3": "^7.6.13", - "@types/bun": "^1.3.3", "@types/node": "^22.19.1", "@types/ws": "^8.18.1", "cmake-js": "^7.4.0", @@ -79,7 +74,6 @@ "typescript-eslint": "^8.48.1" }, "optionalDependencies": { - "@sentry/bun": "^10.29.0", "@sentry/deno": "^10.29.0", "@sentry/node": "^10.29.0", "pm2": "^6.0.14" diff --git a/src/database/sqlite.ts b/src/database/sqlite.ts index bcdf035b..5723bb30 100644 --- a/src/database/sqlite.ts +++ b/src/database/sqlite.ts @@ -5,7 +5,6 @@ import type { Options as BSQLite3Options, Statement as BSQLite3Statement, } from "better-sqlite3"; -import type { Database as BunDatabase, Statement as BunStatement } from "bun:sqlite"; import type { Guild, GuildChannel } from "oceanic.js"; import { commands, @@ -19,24 +18,19 @@ import logger from "#utils/logger.js"; import type { Count, DBGuild, Tag } from "#utils/types.js"; import type { DatabasePlugin } from "../database.ts"; -type BunDenoDatabase = typeof BunDatabase | typeof DenoDatabase; - -// bun:sqlite and @db/sqlite are mostly compatible with better-sqlite3, -// but have a few minor type differences that don't really matter in our case +// @db/sqlite is mostly compatible with better-sqlite3, +// but has a few minor type differences that don't really matter in our case // here we attempt to bring them closer together type CombinedConnection = { - prepare: (query: string) => BSQLite3Statement | BunStatement | DenoStatement; + prepare: (query: string) => BSQLite3Statement | DenoStatement; transaction: (func: () => void) => CallableFunction; -} & (BSQLite3Database | BunDatabase | DenoDatabase); +} & (BSQLite3Database | DenoDatabase); type BSQLite3Init = (filename?: string, options?: BSQLite3Options) => BSQLite3Database; -type CombinedConstructor = BunDenoDatabase | BSQLite3Init; +type CombinedConstructor = typeof DenoDatabase | BSQLite3Init; let dbInit: CombinedConstructor; -if (process.versions.bun) { - const { Database } = await import("bun:sqlite"); - dbInit = Database; -} else if (process.versions.deno) { +if (process.versions.deno) { const { Database } = await import("@db/sqlite"); dbInit = Database; } else { @@ -98,11 +92,9 @@ export default class SQLitePlugin implements DatabasePlugin { connection: CombinedConnection; constructor(connectString: string) { - if (process.versions.bun || process.versions.deno) { - this.connection = new (dbInit as BunDenoDatabase)(connectString.replace("sqlite://", ""), { + if (process.versions.deno) { + this.connection = new (dbInit as typeof DenoDatabase)(connectString.replace("sqlite://", ""), { create: true, - readwrite: true, - strict: true, }); } else { this.connection = (dbInit as BSQLite3Init)(connectString.replace("sqlite://", "")); diff --git a/src/utils/detectRuntime.ts b/src/utils/detectRuntime.ts index 7e43dd94..61496494 100644 --- a/src/utils/detectRuntime.ts +++ b/src/utils/detectRuntime.ts @@ -26,13 +26,6 @@ function canLoadTS(): boolean { } export default function detectRuntime() { - if (process.versions.bun) { - return { - type: "bun", - version: process.versions.bun, - tsLoad: true, - }; - } if (process.versions.deno) { return { type: "deno",