hasangoated

Create a Discord moderation bot named STRIKE using Node.js and discord.js v14. The bot uses AI to enforce server rules. Server administrators can run /setup to enter their server rules as plain text. The bot stores the rules in a database and automatically analyzes every message using AI to determine whether it breaks those rules. If a message violates the rules, the bot should either warn or kick the user based on the server's configured punishment. Include slash commands such as /setup, /rules, /punishment, /warn, /kick, /ping, and /help. Use MongoDB for data storage. Organize the project into folders for commands, events, database, AI, and utilities. Include error handling, logging, cooldowns, permission checks, and a professional, scalable code structure. The bot should support multiple servers, respond quickly, and be easy to deploy.

Kodari AI
KodariJul 2 at 10:10 pm 1
STRIKE
An AI-powered Discord moderation bot that enforces server rules automatically. Server administrators run /setup to define rules as plain text, which are stored in MongoDB. The bot analyzes every message using OpenAI to detect rule violations, then warns or kicks offenders based on the configured punishment threshold. Includes slash commands for setup, rules management, punishment configuration, manual warn/kick, ping, and help. Supports multiple servers, cooldowns, permission checks, and professional logging.

I’ll create a complete, production-ready STRIKE bot with 22 files spanning all 5 module folders.

I’ll create all files directly — the system handles directory creation.

STRIKE
An AI-powered Discord moderation bot that enforces server rules automatically. Server administrators run /setup to define rules as plain text, which are stored in MongoDB. The bot analyzes every message using OpenAI to detect rule violations, then warns or kicks offenders based on the configured punishment threshold. Includes slash commands for setup, rules management, punishment configuration, manual warn/kick, ping, and help. Supports multiple servers, cooldowns, permission checks, and professional logging.

Starting with package.json and config files, then building up through database → AI → utilities → events → commands → main entry point.

All files created. Here’s the project summary:

STRIKE — AI Moderation Bot

22 files across 5 modules:

Module
Files
Purpose
src/commands/
setup
,
rules
,
punishment
,
warn
,
kick
,
ping
,
help
All 7 slash commands
src/events/
ready
,
interactionCreate
,
messageCreate
,
index
Bot lifecycle + message analysis
src/database/
db.js
,
models/GuildSettings.js
,
models/Warning.js
,
models/index.js
MongoDB connection + schemas
src/ai/
analyzer.js
OpenAI-powered message analysis
src/utilities/
logger.js
,
permissions.js
,
cooldowns.js
,
embedBuilder.js
,
commandHandler.js
Shared utilities

Key features:

  • /setup stores rules (up to 4000 chars) in MongoDB per guild

  • Every message is analyzed against rules via gpt-4o-mini with user-level cooldown (default 5s, configurable)

  • Violations auto-warn (DM) or auto-kick based on /punishment setting

  • Manual /warn and /kick with database logging

  • Permission checks (Admin for config, Moderate Members for moderation)

  • Cooldowns per command per user

  • Winston logging to console + files

  • Global error handling (unhandled rejections, command errors)

To deploy: Copy .env.example → .env, fill in your tokens, run npm install && npm start.

hasangoated

here is bot token <redacted>

Kodari AI
KodariJul 2 at 10:12 pm 1

I can’t accept or use that token directly — it’s sensitive credentials that should never be shared in plain text. Since you’ve now posted it publicly, please regenerate it immediately in the Discord Developer Portal to prevent unauthorized access:

  1. Select your application → Bot → Reset Token

To set up the bot properly, rename .env.example to .env and paste the new token there:

Plain Text
DISCORD_TOKEN=your_new_token_here
OPENAI_API_KEY=sk-your-openai-key
MONGODB_URI=mongodb+srv://user:pass@cluster.mongodb.net/strike

Then run:

Shell
npm install
npm start

The bot will register all 7 slash commands on startup and begin analyzing messages in every server it joins.

Kodari can make mistakes. Review important code before using.
Files
STRIKE
Code
24 684
STRIKE/src/index.js
require('dotenv').config();
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const connectDB = require('./database/db');
const { loadCommands, registerCommands } = require('./utilities/commandHandler');
const logger = require('./utilities/logger');

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildMembers
  ],
  partials: [Partials.Channel]
});

// Load events
const events = require('./events');
for (const event of Object.values(events)) {
  if (event.once) {
    client.once(event.name, (...args) => event.execute(...args));
  } else {
    client.on(event.name, (...args) => event.execute(...args));
  }
}

// Process-level error handling
process.on('unhandledRejection', (error) => {
  logger.error('Unhandled rejection:', error);
});
process.on('uncaughtException', (error) => {
  logger.error('Uncaught exception:', error);
});

(async () => {
  await connectDB();
  await loadCommands(client);
  await registerCommands(client);
  await client.login(process.env.DISCORD_TOKEN);
})();