Step-by-step guide to creating a SudoBot extension with custom commands and event listeners using TypeScript, including project setup and build configuration.
Use this file to discover all available pages before exploring further.
SudoBot extensions let you add custom commands, event listeners, and services to your bot instance without modifying the core source. This guide walks you through creating a TypeScript extension from scratch — from directory setup through to running your first custom command.
import "module-alias/register";import { Extension } from "@sudobot/core/Extension";class HelloExtension extends Extension { // Initialization logic goes here if needed}export default HelloExtension;
7
Add a custom command
Create src/commands/HelloCommand.ts:
src/commands/HelloCommand.ts
import { Command, type CommandMessage } from "@framework/commands/Command";import type Context from "@framework/commands/Context";class HelloCommand extends Command { public override readonly name = "hello"; public override readonly description = "A simple hello-world command."; public override async execute(context: Context<CommandMessage>) { await context.reply("Hello world, from the hello extension!"); }}export default HelloCommand;
8
Add an event listener
Create src/events/MessageCreateEventListener.ts:
src/events/MessageCreateEventListener.ts
import EventListener from "@framework/events/EventListener";import { Events } from "@framework/types/ClientEvents";import type { Message } from "discord.js";class MessageCreateEventListener extends EventListener<Events.MessageCreate> { public override readonly name = Events.MessageCreate; public override async execute(message: Message<boolean>): Promise<void> { if (message.author.bot) return; if (message.content === "ping") { await message.reply("Pong, from the hello extension!"); } }}export default MessageCreateEventListener;
9
Build and run
Build your extension, then start the bot:
npm run build
Then from the SudoBot project root:
./blazew run
SudoBot will automatically discover and load your extension on startup. The /hello command will be available on any server.
Make sure you build SudoBot itself before building your extension. The TypeScript path aliases point to SudoBot’s build/ directory.