Skip to content

Self-hosted Slack-like Discord bot for managing Discord channel

License

Notifications You must be signed in to change notification settings

saenyakorn/paradis-bot

Repository files navigation

Paradis Bot

Self-hosted Slack-like Discord bot for collaborative working on Discord

Table of Contents

Features

Channel Management

Normally, everyone in the Discord server would not be able to see any channel that is created by the bot. User need to list the available public channel and join desired channels by themselves.

Basic Commands

  • /channel invite <user|role> - Invite a user or a role to the channel. The invited user would able to read and write messages in the channel, the default notification is All messages
  • /channel leave - Leave the channel you are in
  • /channel kick <user> - Kick the user from the channel. The users would not be able to read or write messages in the channel anymore
  • /channel archive - Archive the channel, the users in the channel are only able to read the messages
  • /channel delete - Delete the channel

Available Commands for Public Channel

  • /channel-public create <channel-name> <category-name>? - Create a public channel
  • /channel-public seek <channel> - Join into the channel with read-only mode, the default notification is Only @mention
  • /channel-public join <channel> - Join into the channel with read-write mode, the default notification is All messages
  • /channel-public list - List all available public channels

Available Commands for Private Channel

  • /channel-private create <channel-name> <category-name>? - Create a private channel

Available Commands for Voice Channel

  • /channel voice-setup <channel-name> <category>? - Setup a voice channel. When the user enter this voice channel, the bot will create another temporary voice channel and move the user into the new channel. The bot will delete the channel when the all users leave the temporary channel

Notification Management

Note: For now, discord API does not support notification management.

  • /noti list - List all notification setting for every channel you are in
  • /noti set <notification> <channel>? - Set the notification for the current or given channel
  • /noti pause <date|time> <channel>? - Pause the notification util the given time, users will not receive any notification during the time

Development

For local development, you need to follow this instructions.

  1. Enter Discord Developer Portal and create discord application
  2. Enter Bot section and create a bot
  3. Click Reset Token to get DISCORD_TOKEN as a secret
  4. Enter OAuth2 > General section, you will get the DISCORD_CLIENT_ID and DISCORD_CLIENT_SECRET
  5. In this project, you need to create .env file from .env.template and fill in the secrets
  6. Run docker compose up -d to create a PostgreSQL database
  7. Run yarn start:dev to start the application, the application will run on localhost:3000 by default

Hosting

This repositoty allow you to host this bot by your own. Basically, it's a NestJS application.

If you are familiar with Docker, you can use the following docker-compose file here to run the application.

version: '3.9'

services:
  paradis-bot:
    image: ghcr.io/saenyakorn/paradis-bot:1.0.0
    container_name: paradis-bot
    # restart: unless-stopped
    environment:
      DISCORD_TOKEN: <secret>
      DISCORD_CLIENT_ID: <client-id>
      DISCORD_CLIENT_SECRET: <secret>
      DATABASE_URL: postgres://postgres:postgres@postgres:5432/paradis-bot
      APP_PORT: 3000
      APP_GLOBAL_PREFIX: api # Now, you can test the simple REST API on http://localhost:3000/api
    depends_on:
      - postgres
    ports:
      - 3000:3000
  postgres:
    image: postgres:14
    restart: unless-stopped
    container_name: postgres
    environment:
      POSTGRES_DB: paradis-bot
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    ports:
      - 5432:5432
    volumes:
      - ./pgdata:/var/lib/postgresql/data

Then, invite the bot to your server by using the following URL. And try to run the simplest command /ping on discord text input.