Clone Repository
git clone https://github.com/oceanroleplay/discord.ts-example
Enter bot directory
cd discord.ts-example
Install Dependencies
npm install
Build your bot
npm run build
Set your bot token
For windows user only
# For command prompt
set BOT_TOKEN=REPLACE_THIS_WITH_YOUR_TOKEN
# For powershell
$env:BOT_TOKEN = "REPLACE_THIS_WITH_YOUR_TOKEN"
For linux user only
export BOT_TOKEN=REPLACE_THIS_WITH_YOUR_TOKEN
Start your bot
npm run serve
you are done, you will see your bot up and running. For detailed installation guide, please see this
This repository uses guild commands instead of global commands by default. This is because global command needs approximately 15 minutes to update itself every time.
comment this line in main.ts
use @Guild decorator on @Slash, check more information
This repo is targed to use ECMAScript modules by default. Follow these steps to use CommonJS.
{
// ...
"type": "commonjs",
// ...
"scripts": {
"build": "tsc",
"dev": "ts-node src/main.ts",
"start": "nodemon --exec ts-node src/main.ts",
"serve": "node build/main.js"
}
// ...
}
{
"compilerOptions": {
"target": "ESNext",
"module": "CommonJS"
// ...
}
}
async function run() {
// with cjs
await importx(__dirname + "/{events,commands}/**/*.{ts,js}");
// with ems
// await importx(dirname(import.meta.url) + "/{events,commands}/**/*.{ts,js}");
client.login(process.env.BOT_TOKEN ?? ""); // provide your bot token
}
There are only a few lines of basic code, which you need to either comment out or remove to disable the API server
- Delete the
api
folder from the src folder - Remove api reference from importx path in main.ts#L57
- Comment out or remove the code from main.ts#L5 and main.ts#L66 - main.ts#L81
- Run
npm uninstall koa @koa/router @discordx/koa @types/koa @types/koa__router
The API server has been removed from the discord bot
Ask in discord server or open a issue
Show your support for discordx by giving us a star on github.