Skip to content

resonite-love/event-manager-2

Repository files navigation

Resonite Event Manager

A Discord bot and API for managing events in Resonite. This system allows users to create, manage, and view events through Discord commands and provides an API for retrieving event information.

English | 日本語

Features

Discord Bot

  • Create, edit, delete, and view events
  • Manage event editors and participants
  • Support for recurring events (daily, weekly, monthly, yearly)
  • Event notifications and reminders
  • Role-based permissions (admin, moderator, user)

API

  • RESTful API for events, categories, users, editors, and participants
  • Filter events by date range, category, creator, etc.
  • Authentication and authorization with JWT
  • Pagination and sorting options

Tech Stack

  • Backend: Express.js with TypeScript
  • Database: PostgreSQL (running in Docker)
  • Discord Bot: discord.js
  • Project Structure: Monorepo with shared code

Getting Started

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/event-manager-2.git
    cd event-manager-2
    
  2. Install dependencies:

    npm install
    
  3. Create a .env file based on .env.example:

    cp .env.example .env
    
  4. Update the .env file with your configuration:

    # Server Configuration
    PORT=3000
    NODE_ENV=development
    API_URL=http://localhost:3000
    CORS_ORIGIN=http://localhost:3000
    
    # Database Configuration
    DB_HOST=localhost
    DB_PORT=5432
    DB_NAME=event_manager
    DB_USER=postgres
    DB_PASSWORD=postgres
    
    # Discord Bot Configuration
    DISCORD_TOKEN=your_discord_bot_token
    DISCORD_CLIENT_ID=your_discord_client_id
    DISCORD_GUILD_ID=your_discord_guild_id
    
    # JWT Secret (for API authentication)
    JWT_SECRET=your_jwt_secret
    JWT_EXPIRES_IN=1d
    

Discord Bot Setup

  1. Create a new Discord application at the Discord Developer Portal
  2. Go to the "Bot" tab and click "Add Bot"
  3. Under the "Token" section, click "Reset Token" and copy the token
  4. Enable the following Privileged Gateway Intents:
    • Server Members Intent
    • Message Content Intent
  5. Go to the "OAuth2" tab, then "URL Generator"
  6. Select the following scopes:
    • bot
    • applications.commands
  7. Select the following bot permissions:
    • Send Messages
    • Embed Links
    • Attach Files
    • Read Message History
    • Use Slash Commands
    • Use External Emojis
  8. Copy the generated URL and open it in your browser to invite the bot to your server
  9. Update your .env file with:
    • DISCORD_TOKEN: The bot token you copied
    • DISCORD_CLIENT_ID: Your application ID (found in General Information)
    • DISCORD_GUILD_ID: Your server ID (enable Developer Mode in Discord, right-click your server and "Copy ID")

Running the Application

Development Mode

  1. Start the database:

    docker-compose up -d postgres
    
  2. Run database migrations:

    npm run migrate
    
  3. Start the application:

    npm run dev
    

Production Mode

  1. Build the application:

    npm run build
    
  2. Start the application with Docker Compose:

    docker-compose up -d
    

Discord Bot Usage

Available Commands

  • /event create - Create a new event
  • /event list - List all events
  • /event view [id] - View event details
  • /event edit [id] - Edit an event
  • /event delete [id] - Delete an event
  • /category create - Create a new category
  • /category list - List all categories
  • /settings - View and change bot settings

Creating an Event

  1. Type /event create in any channel where the bot has access
  2. Fill in the event details in the modal that appears:
    • Title: The name of your event
    • Description: Details about the event
    • Start Time: When the event begins (YYYY-MM-DD HH:MM format)
    • End Time: When the event ends (YYYY-MM-DD HH:MM format)
    • Location: Where the event will take place (optional)
  3. Select a category from the dropdown menu
  4. For recurring events, select the recurrence pattern:
    • Daily: Every day or every X days
    • Weekly: Every week on specific days
    • Monthly: Every month on specific dates
    • Yearly: Every year in specific months
  5. Submit the form

Managing Event Participation

When an event is created, users can interact with it using the following buttons:

  • Attend: Indicate you will attend the event
  • Maybe: Indicate you might attend the event
  • Decline: Indicate you will not attend the event

Event Notifications

The bot will send notifications:

  • When an event is created
  • 24 hours before an event starts
  • 1 hour before an event starts
  • When an event is edited or canceled

API Usage

The API is available at http://localhost:3000/api (or your configured URL).

Authentication

Most API endpoints require authentication. To authenticate:

  1. Obtain a JWT token by making a POST request to /api/auth/login with your credentials
  2. Include the token in the Authorization header of your requests:
    Authorization: Bearer your_jwt_token
    

Events Endpoints

Get All Events

GET /api/events

Query parameters:

  • page: Page number (default: 1)
  • limit: Items per page (default: 10)
  • start_date: Filter events starting after this date (ISO format)
  • end_date: Filter events ending before this date (ISO format)
  • category_id: Filter events by category
  • creator_id: Filter events by creator
  • is_recurring: Filter recurring events (true/false)

Get Event by ID

GET /api/events/:id

Create Event

POST /api/events

Request body:

{
  "title": "Event Title",
  "description": "Event Description",
  "start_time": "2025-04-01T14:00:00Z",
  "end_time": "2025-04-01T16:00:00Z",
  "location": "Resonite World Name",
  "category_id": "category_uuid",
  "is_recurring": false,
  "recurrence_rule": null
}

Update Event

PUT /api/events/:id

Delete Event

DELETE /api/events/:id

Categories Endpoints

  • GET /api/categories - Get all categories
  • GET /api/categories/:id - Get category by ID
  • POST /api/categories - Create a new category
  • PUT /api/categories/:id - Update a category
  • DELETE /api/categories/:id - Delete a category

Troubleshooting

Common Issues

Database Connection Errors

  • Ensure PostgreSQL is running: docker ps
  • Check database credentials in .env
  • Try restarting the database: docker-compose restart postgres

Discord Bot Not Responding

  • Verify the bot token in .env
  • Check if the bot has the necessary permissions
  • Ensure the bot is online in your Discord server
  • Check the application logs for errors

API Authentication Issues

  • Ensure your JWT token is valid and not expired
  • Check that you're including the token in the Authorization header
  • Verify you have the necessary permissions for the requested resource

Logs

Application logs are available:

  • In the console when running in development mode
  • In the Docker logs when running in production: docker-compose logs -f backend

Development

Project Structure

event-manager-2/
├── packages/
│   ├── shared/           # Shared code
│   │   └── src/
│   │       ├── types/    # Shared type definitions
│   │       └── utils/    # Shared utilities
│   │
│   └── backend/          # Backend code
│       ├── src/
│       │   ├── api/      # API endpoints
│       │   ├── config/   # Configuration
│       │   ├── db/       # Database models and migrations
│       │   ├── discord/  # Discord bot
│       │   └── utils/    # Utilities
│       └── ...
│
├── docker/               # Docker configuration
├── Dockerfile            # Main Dockerfile
├── docker-compose.yml    # Docker Compose configuration
└── ...

Adding New Features

Creating a New Command

  1. Create a new file in packages/backend/src/discord/commands/
  2. Implement the command following the Command interface
  3. Register the command in packages/backend/src/discord/commands/index.ts

Adding a New API Endpoint

  1. Create a controller in packages/backend/src/api/controllers/
  2. Create routes in packages/backend/src/api/routes/
  3. Register the routes in packages/backend/src/api/routes/index.ts

Adding a New Database Model

  1. Create a migration in packages/backend/src/db/migrations/
  2. Create a model in packages/backend/src/db/models/
  3. Register the model in packages/backend/src/db/models/index.ts

Testing

Run tests with:

npm test

License

This project is licensed under the MIT License - see the LICENSE file for details.


機能

Discordボット

  • イベントの作成、編集、削除、表示
  • イベント編集者と参加者の管理
  • 繰り返しイベントのサポート(毎日、毎週、毎月、毎年)
  • イベント通知とリマインダー
  • ロールベースの権限(管理者、モデレーター、ユーザー)

API

  • イベント、カテゴリ、ユーザー、編集者、参加者のRESTful API
  • 日付範囲、カテゴリ、作成者などによるイベントのフィルタリング
  • JWTによる認証と認可
  • ページネーションとソートオプション

Discordボットの使い方

利用可能なコマンド

  • /event create - 新しいイベントを作成
  • /event list - すべてのイベントを一覧表示
  • /event view [id] - イベントの詳細を表示
  • /event edit [id] - イベントを編集
  • /event delete [id] - イベントを削除
  • /category create - 新しいカテゴリを作成
  • /category list - すべてのカテゴリを一覧表示
  • /settings - ボット設定の表示と変更

イベントの作成

  1. ボットがアクセスできるチャンネルで /event create と入力
  2. 表示されるモーダルにイベントの詳細を入力:
    • タイトル: イベントの名前
    • 説明: イベントの詳細
    • 開始時間: イベントの開始時間(YYYY-MM-DD HH:MM形式)
    • 終了時間: イベントの終了時間(YYYY-MM-DD HH:MM形式)
    • 場所: イベントの開催場所(任意)
  3. ドロップダウンメニューからカテゴリを選択
  4. 繰り返しイベントの場合、繰り返しパターンを選択:
    • 毎日: 毎日または特定の日数ごと
    • 毎週: 毎週特定の曜日
    • 毎月: 毎月特定の日
    • 毎年: 毎年特定の月
  5. フォームを送信

イベント参加の管理

イベントが作成されると、ユーザーは以下のボタンで参加状況を示すことができます:

  • 参加: イベントに参加することを示す
  • 未定: イベントに参加するかもしれないことを示す
  • 不参加: イベントに参加しないことを示す

イベント通知

ボットは以下のタイミングで通知を送信します:

  • イベントが作成されたとき
  • イベント開始の24時間前
  • イベント開始の1時間前
  • イベントが編集またはキャンセルされたとき

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published