- π Plugin System - Modular, extensible plugin architecture
- β‘ Event Handling - Sophisticated event management with auto-discovery
- π― Command Handling - Support for both slash commands and message commands
# Using npm
npm install cordium discord.js
# Using pnpm
pnpm add cordium discord.js
# Using yarn
yarn add cordium discord.jsimport { Client, GatewayIntentBits } from "discord.js";
import { Core } from "cordium";
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildVoiceStates,
],
});
const core = new Core(client, {
baseDirectory: __dirname,
prefix: ["!", "?"],
owners: ["YOUR_USER_ID"],
autoRegisterCommands: true,
// applicationCommandGuildId: "GUILD_ID", // optional
isPluginEnabled: (pluginName: string, guildId: string) => boolean | Promise<boolean>,
beforeCommandRun: (context: Core.Context) => boolean | Promise<boolean>,
});
await core.init();
client.login("YOUR_BOT_TOKEN");your-project/
βββ plugins/
β βββ moderation/
β β βββ moderation.plugin.ts
β β βββ commands/
β β β βββ ban.command.ts
β β β βββ kick.command.ts
β β βββ events/
β β βββ clientReady.event.ts
β βββ utility/
β β βββ plugin.ts
β β βββ commands/
β β β βββ ping.command.ts
β β β βββ uptime.command.ts
β β βββ events/
β β βββ messageCreate.event.ts
βββ index.ts
βββ package.json
// plugins/example/plugin.ts
import { Plugin } from "cordium";
export class ModerationPlugin extends Plugin {
constructor(buildOptions: Plugin.BuildOptions) {
super(buildOptions, {
name: "Moderation",
});
}
}// plugins/example/commands/hello.command.ts
import { Command } from "cordium";
import {
ChatInputCommandInteraction,
Message,
ContextMenuCommandInteraction,
ApplicationCommandType,
} from "discord.js";
export class HelloCommand extends Command {
constructor(buildOptions: Command.BuildOptions) {
super(buildOptions, {
name: "hello",
description: "Says hello to the user",
aliases: ["hi", "hey"],
});
}
// Build application commands (slash / context menu) using the provided CommandBuilder
buildApplicationCommands(builder: Command.Builder) {
return builder
.addSlashBuilder((slash) =>
slash
.setName(this.name)
.setDescription("Says hello!")
.addUserOption((option) =>
option.setName("user").setDescription("User to greet").setRequired(false)
)
)
.addContextMenuBuilder((context) => context.setName("User Info").setType(ApplicationCommandType.User));
}
// Handle slash command
async onChatInput(interaction: ChatInputCommandInteraction) {
const user = interaction.options.getUser("user") || interaction.user;
await interaction.reply(`Hello, ${user}! π`);
}
// Handle message command
async onMessage(message: Message, ...args: any[]) {
const mention = message.mentions.users.first() || message.author;
await message.reply(`Hello, ${mention}! π`);
}
// Handle context menu command
async onContextMenu(interaction: ContextMenuCommandInteraction) {
const user = interaction.targetUser;
await interaction.reply(`User: ${user.tag}`);
}
}// plugins/example/events/ready.event.ts
import { Event, container } from "cordium";
import { Events } from "discord.js";
export class ClientReadyEvent extends Event {
constructor(buildOptions: Event.BuildOptions) {
super(buildOptions, {
name: Events.ClientReady,
once: true,
});
}
async run() {
console.log(`π Bot is ready! Logged in as ${container.core.client.user?.tag}`);
}
}import { container } from "cordium";
// Access the global container
container.store.set("customData", { foo: "bar" });
const data = container.store.get("customData");
// Access plugin/event/command stores
const allPlugins = Array.from(container.pluginStore);
const allEvents = Array.from(container.eventStore);
const allCommands = Array.from(container.commandStore);// Load specific plugin
await core.handler.loadPlugin("./plugins/moderation/plugin.js");
// Unload all plugins
await core.handler.unloadPlugins();
// Register commands to specific guild
await core.handler.registerCommands("GUILD_ID");# Clone the repository
git clone https://github.com/Kevlid/Cordium.git
# Install dependencies
pnpm install
# Build the framework
pnpm build
# Watch for changes during development
pnpm dev- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Documentation (At some point probably)
- NPM Package
- GitHub Repository
Built with β€οΈ by Kevlid
β Star this repo if you find it useful!