Skip to content

Latest commit

 

History

History
70 lines (51 loc) · 3.62 KB

README.md

File metadata and controls

70 lines (51 loc) · 3.62 KB

Kao.Geek bot

Discord bot for KaoGeek, built with TypeScript and discord.js

Setup

  • Make sure to use same node version as specified in .nvmrc by using nvm

    nvm use

    If not installed, use nvm install to install specified version in .nvmrc (at the time of writing lts/hydrogen)

  • Install dependencies

    pnpm install

Discord Bot & Server Setup (For Development)

  • Open Discord app, create your own Discord server for bot development00
  • Right click at your server's icon, copy server ID (This will be GUILD_ID in your .env)01-copy-server-id
  • Right clict at your text channel, copy channel ID (This will be MOD_CHANNEL_ID in your .env)4
  • Go to Discord Developer Portal and create a new application, name it whatever you want1
  • Go to your application's Bot tab get the bot's token by clicking Reset Token button, copy the token and keep it save, don't share this to anyone! (This will be BOT_TOKEN in your .env)2
  • In the same window under the Privileged Gateway Intents section, enable PRESENCE INTENT, SERVER MEMBERS INTENT, and MESSAGE CONTENT INTENT3
  • Go to OAuth2 -> URL Generator tab, select bot and applications.commands scopes, then select permissions under Bot Permissions section, copy the generated URL and paste it in your browser, then choose your server to add the bot.5
    You can set to Administrator for ease of development, but it's not recommended for production.

Development

  • Copy the .env.example to .env

    cp .env.example .env
  • Then, set all variables in .env file

    ENV Variables
    • BOT_TOKEN Discord bot token
    • GUILD_ID Discord server ID
    • MOD_CHANNEL_ID Discord channel ID for bot to report moderation actions
    • DATABASE_URL Prisma database URL, you can use SQLite for development, set it to file:./dev.db
  • To run the bot in development mode

    pnpm dev

Deploy

  • Run with Docker
    docker build -t kaogeek-discord-bot .
    docker run -d --env-file=.env --name kaogeek-discord-bot kaogeek-discord-bot
  • Run with Node
    pnpm install
    pnpm build
    pnpm start