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.
- 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)
- 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
- Backend: Express.js with TypeScript
- Database: PostgreSQL (running in Docker)
- Discord Bot: discord.js
- Project Structure: Monorepo with shared code
- Node.js (v18 or higher)
- Docker and Docker Compose
- Discord Bot Token (see Discord Developer Portal)
-
Clone the repository:
git clone https://github.com/yourusername/event-manager-2.git cd event-manager-2
-
Install dependencies:
npm install
-
Create a
.env
file based on.env.example
:cp .env.example .env
-
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
- Create a new Discord application at the Discord Developer Portal
- Go to the "Bot" tab and click "Add Bot"
- Under the "Token" section, click "Reset Token" and copy the token
- Enable the following Privileged Gateway Intents:
- Server Members Intent
- Message Content Intent
- Go to the "OAuth2" tab, then "URL Generator"
- Select the following scopes:
bot
applications.commands
- Select the following bot permissions:
- Send Messages
- Embed Links
- Attach Files
- Read Message History
- Use Slash Commands
- Use External Emojis
- Copy the generated URL and open it in your browser to invite the bot to your server
- Update your
.env
file with:DISCORD_TOKEN
: The bot token you copiedDISCORD_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")
-
Start the database:
docker-compose up -d postgres
-
Run database migrations:
npm run migrate
-
Start the application:
npm run dev
-
Build the application:
npm run build
-
Start the application with Docker Compose:
docker-compose up -d
/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
- Type
/event create
in any channel where the bot has access - 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)
- Select a category from the dropdown menu
- 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
- Submit the form
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
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
The API is available at http://localhost:3000/api
(or your configured URL).
Most API endpoints require authentication. To authenticate:
- Obtain a JWT token by making a POST request to
/api/auth/login
with your credentials - Include the token in the Authorization header of your requests:
Authorization: Bearer your_jwt_token
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 categorycreator_id
: Filter events by creatoris_recurring
: Filter recurring events (true/false)
GET /api/events/:id
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
}
PUT /api/events/:id
DELETE /api/events/:id
GET /api/categories
- Get all categoriesGET /api/categories/:id
- Get category by IDPOST /api/categories
- Create a new categoryPUT /api/categories/:id
- Update a categoryDELETE /api/categories/:id
- Delete a category
- Ensure PostgreSQL is running:
docker ps
- Check database credentials in
.env
- Try restarting the database:
docker-compose restart postgres
- 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
- 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
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
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
└── ...
- Create a new file in
packages/backend/src/discord/commands/
- Implement the command following the Command interface
- Register the command in
packages/backend/src/discord/commands/index.ts
- Create a controller in
packages/backend/src/api/controllers/
- Create routes in
packages/backend/src/api/routes/
- Register the routes in
packages/backend/src/api/routes/index.ts
- Create a migration in
packages/backend/src/db/migrations/
- Create a model in
packages/backend/src/db/models/
- Register the model in
packages/backend/src/db/models/index.ts
Run tests with:
npm test
This project is licensed under the MIT License - see the LICENSE file for details.
- イベントの作成、編集、削除、表示
- イベント編集者と参加者の管理
- 繰り返しイベントのサポート(毎日、毎週、毎月、毎年)
- イベント通知とリマインダー
- ロールベースの権限(管理者、モデレーター、ユーザー)
- イベント、カテゴリ、ユーザー、編集者、参加者のRESTful API
- 日付範囲、カテゴリ、作成者などによるイベントのフィルタリング
- JWTによる認証と認可
- ページネーションとソートオプション
/event create
- 新しいイベントを作成/event list
- すべてのイベントを一覧表示/event view [id]
- イベントの詳細を表示/event edit [id]
- イベントを編集/event delete [id]
- イベントを削除/category create
- 新しいカテゴリを作成/category list
- すべてのカテゴリを一覧表示/settings
- ボット設定の表示と変更
- ボットがアクセスできるチャンネルで
/event create
と入力 - 表示されるモーダルにイベントの詳細を入力:
- タイトル: イベントの名前
- 説明: イベントの詳細
- 開始時間: イベントの開始時間(YYYY-MM-DD HH:MM形式)
- 終了時間: イベントの終了時間(YYYY-MM-DD HH:MM形式)
- 場所: イベントの開催場所(任意)
- ドロップダウンメニューからカテゴリを選択
- 繰り返しイベントの場合、繰り返しパターンを選択:
- 毎日: 毎日または特定の日数ごと
- 毎週: 毎週特定の曜日
- 毎月: 毎月特定の日
- 毎年: 毎年特定の月
- フォームを送信
イベントが作成されると、ユーザーは以下のボタンで参加状況を示すことができます:
- 参加: イベントに参加することを示す
- 未定: イベントに参加するかもしれないことを示す
- 不参加: イベントに参加しないことを示す
ボットは以下のタイミングで通知を送信します:
- イベントが作成されたとき
- イベント開始の24時間前
- イベント開始の1時間前
- イベントが編集またはキャンセルされたとき