Discord.js v14 を使用した Bun 向けの Discord BOTサンプル
TypeScriptです
bun-bot/
├─ src/
├─ assets/ # 画像や静的ファイル
├─ commands/ # スラッシュコマンド
├─ events/ # Discordイベントハンドラ
├─ lib/ # 外部API呼び出しや共通ライブラリ
├─ utils/ # ユーティリティ関数
├─ types/ # 型定義ファイル
├─ types.ts # Bot 全体で使う共通型定義
├─ index.ts # エントリーポイント(BOT起動ファイル)
├─ registerCommands.ts # コマンド登録処理
├─ .env
├─ .gitignore
├─ bun.lock
├─ package.json
└─ tsconfig.json
Linux / macOS
curl -fsSL https://bun.sh/install | bash
Windows (PowerShell)
powershell -c "irm bun.sh/install.ps1 | iex"
パス反映
source ~/.bashrc
インストールできたか確認(versionでれば成功)
bun --version
git clone https://github.com/veda00133912/bun-bot.git
cd bun-bot
bun installプロジェクトルートに.envを作成して設定
DISCORD_TOKEN=BOTのTOKEN
CLIENT_ID=BOTのID
GUILD_ID=DiscordサーバーID
XGD_API_KEY=x.gdのAPIキー
変更があった場合自動で再起動してくれるやつ
npm run dev
普通に起動
npm start