mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
chore: fix more build issues
BREAKING CHANGE: In `@revanced/discord-bot`, its environment variable
`DATABASE_URL` has been renamed to `DATABASE_PATH`
and the `file:` prefix is no longer needed
This commit is contained in:
@@ -25,8 +25,6 @@ The distribution files will be placed inside the `dist` directory. Inside will i
|
|||||||
- The default configuration for the API
|
- The default configuration for the API
|
||||||
- Compiled source files of the API
|
- Compiled source files of the API
|
||||||
|
|
||||||
You'll need to also copy the `node_modules` directory dereferenced if you want to run the distribution files somewhere else.
|
|
||||||
|
|
||||||
## ✈️ Deploying
|
## ✈️ Deploying
|
||||||
|
|
||||||
To deploy the API, you'll need to:
|
To deploy the API, you'll need to:
|
||||||
@@ -44,6 +42,7 @@ To deploy the API, you'll need to:
|
|||||||
|
|
||||||
4. Configure environment variables
|
4. Configure environment variables
|
||||||
As seen in [`.env.example`](../.env.example). You can also optionally use a `.env` file which **Bun will automatically load**.
|
As seen in [`.env.example`](../.env.example). You can also optionally use a `.env` file which **Bun will automatically load**.
|
||||||
|
It is recommended to set `NODE_ENV` to `production` when deploying production builds.
|
||||||
|
|
||||||
5. Finally, you can run the API using these commands
|
5. Finally, you can run the API using these commands
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
DISCORD_TOKEN="YOUR-TOKEN-HERE"
|
DISCORD_TOKEN="YOUR-TOKEN-HERE"
|
||||||
DATABASE_URL=file:./db.sqlite3
|
DATABASE_PATH=./db.sqlite3
|
||||||
@@ -61,10 +61,10 @@ You can set environment variables in your shell or use a `.env` file which **Bun
|
|||||||
|
|
||||||
The Discord bot token.
|
The Discord bot token.
|
||||||
|
|
||||||
#### `DATABASE_URL`
|
#### `DATABASE_PATH`
|
||||||
|
|
||||||
The database URL, since we're using SQLite, we'll be using the `file` protocol.
|
The database path.
|
||||||
Example values are: `file:./revanced.db`, `file:./db.sqlite`, `file:./discord_bot.sqlite`
|
Example values are: `./revanced.db`, `db.sqlite3`, `../some/path/discord_bot.sqlite`
|
||||||
|
|
||||||
## ⏭️ What's next
|
## ⏭️ What's next
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ export default defineConfig({
|
|||||||
dialect: 'sqlite',
|
dialect: 'sqlite',
|
||||||
schema: './src/database/schemas.ts',
|
schema: './src/database/schemas.ts',
|
||||||
dbCredentials: {
|
dbCredentials: {
|
||||||
url: process.env['DATABASE_URL'],
|
url: `file:./${process.env['DATABASE_PATH']}`,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"start": "bun run scripts/generate-indexes.ts && bun run src/index.ts",
|
"start": "bun run scripts/generate-indexes.ts && bun run src/index.ts",
|
||||||
"dev": "bun run scripts/generate-indexes.ts && bun --watch src/index.ts",
|
"dev": "bun run scripts/generate-indexes.ts && bun --watch src/index.ts",
|
||||||
"build:config": "bun build config.ts --outdir=dist",
|
"build:config": "bun build config.ts --outdir=dist",
|
||||||
"build": "bun prepare && bun build:config && bun build src/index.ts -e ./config.js --target=bun --outdir=dist/src && DATABASE_URL=dist/db.sqlite3 drizzle-kit push",
|
"build": "bun prepare && bun build:config && bun build src/index.ts -e ./config.js --target=bun --outdir=dist/src && DATABASE_PATH=dist/db.sqlite3 drizzle-kit push",
|
||||||
"watch": "bun dev",
|
"watch": "bun dev",
|
||||||
"prepare": "bun run scripts/generate-indexes.ts"
|
"prepare": "bun run scripts/generate-indexes.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
// AUTO-GENERATED BY A SCRIPT, DON'T TOUCH
|
// AUTO-GENERATED BY A SCRIPT, DON'T TOUCH
|
||||||
|
|
||||||
import './index'
|
import './index'
|
||||||
import './fun/reply'
|
|
||||||
import './fun/coinflip'
|
import './fun/coinflip'
|
||||||
import './development/eval'
|
import './fun/reply'
|
||||||
import './development/stop'
|
import './moderation/unban'
|
||||||
import './development/exception-test'
|
|
||||||
import './moderation/purge'
|
import './moderation/purge'
|
||||||
import './moderation/cure'
|
import './moderation/cure'
|
||||||
import './moderation/role-preset'
|
|
||||||
import './moderation/mute'
|
|
||||||
import './moderation/unmute'
|
import './moderation/unmute'
|
||||||
import './moderation/unban'
|
import './moderation/mute'
|
||||||
import './moderation/slowmode'
|
|
||||||
import './moderation/ban'
|
import './moderation/ban'
|
||||||
|
import './moderation/role-preset'
|
||||||
|
import './moderation/slowmode'
|
||||||
|
import './development/stop'
|
||||||
|
import './development/exception-test'
|
||||||
|
import './development/eval'
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const api = {
|
|||||||
disconnectCount: 0,
|
disconnectCount: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
const db = new Database(process.env['DATABASE_URL'])
|
const db = new Database(process.env['DATABASE_PATH'])
|
||||||
|
|
||||||
export const database = drizzle(db, {
|
export const database = drizzle(db, {
|
||||||
schema: schemas,
|
schema: schemas,
|
||||||
@@ -61,5 +61,8 @@ export const discord = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
commands: Object.fromEntries(Object.values<Command>(commands).map((cmd) => [cmd.data.name, cmd])) as Record<string, Command>,
|
commands: Object.fromEntries(Object.values<Command>(commands).map(cmd => [cmd.data.name, cmd])) as Record<
|
||||||
|
string,
|
||||||
|
Command
|
||||||
|
>,
|
||||||
} as const
|
} as const
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// AUTO-GENERATED BY A SCRIPT, DON'T TOUCH
|
// AUTO-GENERATED BY A SCRIPT, DON'T TOUCH
|
||||||
|
|
||||||
import './ready'
|
import './ready'
|
||||||
import './disconnect'
|
|
||||||
import './index'
|
import './index'
|
||||||
|
import './disconnect'
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import './ready'
|
|||||||
import './cureRequired'
|
import './cureRequired'
|
||||||
import './index'
|
import './index'
|
||||||
import './messageCreate/messageScanRequired'
|
import './messageCreate/messageScanRequired'
|
||||||
import './messageReactionAdd/correctResponse'
|
|
||||||
import './interactionCreate/chatCommand'
|
|
||||||
import './interactionCreate/correctResponse'
|
|
||||||
import './guildMemberAdd/applyRolePresets'
|
import './guildMemberAdd/applyRolePresets'
|
||||||
|
import './interactionCreate/correctResponse'
|
||||||
|
import './interactionCreate/chatCommand'
|
||||||
|
import './messageReactionAdd/correctResponse'
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { getMissingEnvironmentVariables } from '@revanced/bot-shared'
|
|||||||
import './events/register'
|
import './events/register'
|
||||||
|
|
||||||
// Check if token exists
|
// Check if token exists
|
||||||
const missingEnvs = getMissingEnvironmentVariables(['DISCORD_TOKEN', 'DATABASE_URL'])
|
const missingEnvs = getMissingEnvironmentVariables(['DISCORD_TOKEN', 'DATABASE_PATH'])
|
||||||
if (missingEnvs.length) {
|
if (missingEnvs.length) {
|
||||||
for (const env of missingEnvs) logger.fatal(`${env} is not defined in environment variables`)
|
for (const env of missingEnvs) logger.fatal(`${env} is not defined in environment variables`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
"author": "Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
"author": "Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
||||||
"workspaces": ["packages/*", "apis/*", "bots/*"],
|
"workspaces": ["packages/*", "apis/*", "bots/*"],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "turbo run build",
|
"build:all": "turbo run build",
|
||||||
"build:packages": "turbo run build --filter=\"./packages/*\"",
|
"build:packages": "turbo build --filter=\"./packages/*\"",
|
||||||
"watch": "turbo run watch",
|
"watch": "turbo run watch",
|
||||||
"flint": "biome check --write .",
|
"flint": "biome check --write .",
|
||||||
"flint:check": "biome check .",
|
"flint:check": "biome check .",
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
"Palm <contact@palmdevs.me> (https://palmdevs.me)",
|
||||||
"ReVanced <nosupport@revanced.app> (https://revanced.app)"
|
"ReVanced <nosupport@revanced.app> (https://revanced.app)"
|
||||||
],
|
],
|
||||||
"packageManager": "pnpm@9.4.0",
|
"packageManager": "bun@1.1.18",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "^1.8.2",
|
"@biomejs/biome": "^1.8.2",
|
||||||
"@commitlint/cli": "^19.3.0",
|
"@commitlint/cli": "^19.3.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user