KSS PC Club(茨城県立古河中等教育学校パソコン部)の Discord にて運用している bot です. hono を用いて実装されており、Cloudflare Workers 上で動作します.
$ git clone {this repository}
$ cd {this repository}
$ bun install- Discord Developer Potal から新規に Discord App を登録し、
Application ID,Public Key,Tokenを取得します. - Discord App の OAuth2 から
botスコープを選択し、Manage Roles,Send Messages,Use Slash Commandsの権限を付与します. - 2 で生成された URL にアクセスし、bot をサーバーに追加します.
bun run ./scripts/registerSlashCommands.tsを実行し、Slash Commands を登録します.このとき、.envファイルにDISCORD_APPLICATION_IDを設定してください.- 1 で取得した情報をそれぞれ
DISCORD_APPLICATION_ID,DISCORD_PUBLIC_KEY,DISCORD_TOKENを環境変数として設定します.
$ bunx wrangler secret put DISCORD_APPLICATION_ID
$ bunx wrangler secret put DISCORD_PUBLIC_KEY
$ bunx wrangler secret put DISCORD_TOKENbun run deployでデプロイします.- 5 で生成された URL (
https://kss-pc-bot.***.workers.dev) を Discord Developer Potal のInteractions Endpoint URLに設定します.