- General Overview
- Discord Developer Configuration
- Project Setup
- Complete Setup Guide
- Available Commands
- Project Structure
- config.ts Configuration
Auto Kick Bot is a Discord bot developed with Discord.js and TypeScript that detects inactive members (those who haven't sent messages) on a server and facilitates their management.
- ✅ Detects inactive members on the server
- ✅ Saves member data in JSON files
- ✅ Verifies moderation permissions
- ✅ Real-time message monitoring
- ✅ Scalable system based on Clean Architecture
- Access Discord Developer Portal: https://discord.com/developers/applications
- Click "New Application"
- Assign a name to the bot (e.g., "Auto Kick Bot")
- Accept the terms and create the application
- Go to the "Bot" section in the left menu
- Click "Add Bot"
- Under the TOKEN section, click "Copy"
- Save this token securely (it's like a password)
- In the "General Information" section
- Copy the CLIENT ID (this is your APP_ID)
- Go to "OAuth2" → "URL Generator"
- In Scopes, select:
- ✅
bot
- ✅
- In Permissions, select:
- ✅
Read Messages/View Channels - ✅
Send Messages - ✅
Read Message History - ✅
Kick Members(to kick members) - ✅
Manage Messages
- ✅
- Copy the generated URL and open it in your browser
- Select the server where you want to add the bot
- Open Discord and go to your server
- Enable "Developer Mode":
- Windows:
Ctrl+Shift+I→ User Settings → Advanced → Developer Mode - Mac:
Cmd+Shift+I→ User Settings → Advanced → Developer Mode
- Windows:
- Right-click on the channel you want to monitor
- Select "Copy Channel ID"
- Node.js (v16 or higher): https://nodejs.org
- npm (included with Node.js)
- Git (optional, to clone the repository)
- Discord Developer credentials
git clone <repository-url>
cd auto-kick-botnpm installThis will install:
discord.js- Library to interact with Discorddotenv- Environment variables managementtypescript- Typed languagets-node- TypeScript executor in developmentnodemon- Automatic change monitor
In the project root, create a file named .env with the following content:
DISCORD_TOKEN=your_token_here
APP_ID=your_app_id_here
ID_CHANNEL=your_channel_id_hereComplete example:
DISCORD_TOKEN=dsaddsadas.dsadasdas.dasjda90121j00ssjsd0as
APP_ID=1283091iodsaoidj10
ID_CHANNEL=0912oindsondosa- Never commit the
.envfile to Git - Verify that
.gitignoreincludes.env - Keep your credentials secure
# 1. Install dependencies
npm install
# 2. Create .env file with your credentials
# 3. Run in development mode with hot-reload
npm run devThe bot will automatically restart when you make code changes.
Expected output:
✅ Bot is ready! What are we gonna do?
# 1. Compile TypeScript to JavaScript
npm run build
# 2. Run the compiled bot
npm startThis will generate compiled files in the dist/ folder.
Description: Verifies that the bot is active
Usage: Type !hello in any channel
Response: ESTOY ACTIVO PUTO IMBECIL ✅
User: !hello
Bot: ESTOY ACTIVO PUTO IMBECIL ✅
Description: Scans all server members and detects inactive ones
Usage: Type !check in a configured channel
Requirements:
- The bot needs message read permissions
- A JSON file will be saved with the data
Result: Creates file data/members-<timestamp>.json with inactive members
Generated JSON structure:
{
"id": "user_id_discord",
"username": "username",
"joinedAt": "2024-01-15T10:30:00.000Z",
"messageCount": 0
}Description: Checks if you have moderation permissions
Usage: Type !checkme
Responses:
- ✅ If you have permissions:
✅ Tienes el permiso 'KICK_MEMBERS'. - ❌ If you don't have permissions:
❌ No tienes el permiso 'KICK_MEMBERS'.
User (with permissions): !checkme
Bot: ✅ Tienes el permiso `KICK_MEMBERS`.
User (without permissions): !checkme
Bot: ❌ No tienes el permiso `KICK_MEMBERS`.
auto-kick-bot/
├── src/
│ ├── config/
│ │ └── config.ts # Central configuration
│ ├── domain/
│ │ ├── models/
│ │ │ ├── user.models.ts # User interface
│ │ │ └── stats.model.ts # Statistics interface
│ │ └── repository/
│ │ └── member.repository.ts # Repository interface
│ ├── application/
│ │ └── use-cases/
│ │ └── inactive-members.use-case.ts # Inactive members logic
│ ├── infrastructure/
│ │ └── discord/
│ │ └── discord-member.repository.ts # Discord implementation
│ ├── adapters/
│ │ └── save-members-command.adapter.ts # Command adapter
│ ├── utils/
│ │ └── channels.ts # Channel utilities
│ └── main.ts # Bot entry point
├── data/ # Generated JSON files
├── dist/ # Compiled files (production)
├── .env # Environment variables (DO NOT commit)
├── .gitignore # Ignore files
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── DOCUMENTATION.md # This documentation
The project implements Clean Architecture to separate responsibilities:
- Domain: Models and interfaces (no external dependencies)
- Application: Use cases (business logic)
- Infrastructure: Implementation with Discord
- Adapters: Layer connectors
- Config: Centralized configuration
import dotenv from "dotenv"
dotenv.config();
export const config = {
token: process.env.DISCORD_TOKEN,
appId: process.env.APP_ID,
channelId: process.env.ID_CHANNEL,
messageLength: 0,
days: null,
}- Type:
string - Source: Environment variable
DISCORD_TOKEN - Description: Bot authentication token on Discord
- Usage: Used in
main.tswithclient.login(config.token) - Example:
dsaddsadas.dsadasdas.dasjda90121j00ssjsd0as ⚠️ Critical: Never expose it publicly
- Type:
string - Source: Environment variable
APP_ID - Description: Unique application ID on Discord (Client ID)
- Usage: To identify the application on Discord
- Example:
12131312s12312dsa122123 - Where to find it: Discord Developer Portal → General Information → CLIENT ID
- Type:
string - Source: Environment variable
ID_CHANNEL - Status: Deprecated - Not used in the current application
- Description: ID of the Discord channel where members are monitored
⚠️ Important: This value in config.ts DOES NOT WORK.
Instead, use the file src/utils/channels.ts:
// src/utils/channels.ts
export const CHANNELS_IDS = [
"3213123214sas123213213",
]To add more channels, simply add IDs to the array:
export const CHANNELS_IDS = [
"3123213123213213",
"3213123213213213213",
"12312321321321312",
]- How to get channel IDs:
- Enable Developer Mode in Discord (Ctrl+Shift+I)
- Right-click on the channel → Copy Channel ID
- Add the ID to the array in
src/utils/channels.ts
- Type:
number - Current value:
0 - Description: Maximum message threshold to consider a user as inactive
- Usage: In
inactive-members.use-case.tsto filter inactive users - Logic:
// If messageLength = 0: const inactive = data.users.filter(user => user.messageCount === 0); // Filters only users with 0 messages
- Configuration examples:
0→ Inactive = users with 0 messages5→ Inactive = users with 0-5 messages10→ Inactive = users with 0-10 messages
- Type:
null(currently unused) - Current value:
null - Description: Number of inactivity days (future feature)
- Usage: Reserved to filter by inactivity time
- Future implementation:
// Pseudo-code for future use: if (config.days) { const dayLimit = Date.now() - (config.days * 24 * 60 * 60 * 1000); const inactive = users.filter(u => u.lastMessageDate < dayLimit); }
| Variable | Description | Example | Where to get it |
|---|---|---|---|
DISCORD_TOKEN |
Bot token | MTMz... |
Developer Portal → Bot → TOKEN |
APP_ID |
Client ID | 312312321312312312 |
Developer Portal → General Information |
ID_CHANNEL |
Channel ID | 312321321321321312 |
Right-click on channel → Copy ID |
Cause: The .env file doesn't exist or doesn't have the DISCORD_TOKEN variable
Solution:
- Create the
.envfile in the root - Add:
DISCORD_TOKEN=your_token_here
Cause: Invalid or expired token Solution:
- Regenerate the token in Developer Portal
- Update the
.envfile
Cause:
- The bot doesn't have permissions on the server
- The channel isn't configured correctly Solution:
- Check permissions in Discord → Server → Bot Roles
- Run
!checkmeto verify permissions - Check that
CHANNELS_IDSinsrc/utils/channels.tsis correct
Cause: Dependencies not installed Solution:
npm installStarts the bot in development mode with automatic restart
npm run devCompiles TypeScript to JavaScript
npm run build
# Generates files in the 'dist/' folderRuns the compiled bot (production)
npm startRuns tests (currently not configured)
npm test- ✅ Implement filtering logic by days (
config.days) - ✅ Add
!kickcommand to remove inactive users - ✅ Implement persistent database
- ✅ Add more granular roles and permissions
- ✅ Web dashboard to visualize data
- ✅ Per-server configuration
For bug reports or suggestions, contact the project developer.
Last updated: January 2026
Version: 1.0.0
License: ISC