Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/noskap/kojima-bot/llms.txt

Use this file to discover all available pages before exploring further.

Kojima Bot can turn any image file into a Discord slash command with zero code. Drop an image into the right folder, redeploy, and the command appears in the slash menu automatically. This makes it trivial to maintain a server-specific meme library without touching the bot’s source code.

How it works

At bot startup, registerMemeSlashHandlers calls scanMemeImageFiles, which walks assets/images/meme/ recursively (skipping hidden files and directories). Every file with a recognised extension is registered as its own slash command. Supported file types: .png, .jpg, .jpeg, .gif, .webp, .bmp, .webm The command name is derived from the filename using memeFileToCommandNameStem:
  1. Take the filename without its extension.
  2. Lowercase the entire string.
  3. Replace every character that is not a–z, 0–9, or _ with an underscore.
  4. Collapse consecutive underscores into one.
  5. Strip leading and trailing underscores.
  6. Truncate to 32 characters (Discord’s slash command name limit).
  7. If the result is empty, fall back to "meme".
Subdirectory names are used as a human-readable label in the command description (shown in the Discord UI as "Meme: subdir/filename.png") but do not affect the command name itself — only the bare filename matters.
/** Discord slash names: lowercase a-z, 0–9, _ ; 1–32 chars */
export function memeFileToCommandNameStem(fileBasenameSansExt: string): string {
    let s = fileBasenameSansExt.toLowerCase().replace(/[^a-z0-9_]/g, "_").replace(/_+/g, "_");
    if (s.length > 32) s = s.slice(0, 32);
    s = s.replace(/^_|_$/g, "");
    return s.length > 0 ? s : "meme";
}

Adding meme commands

1

Add the image file

Copy or move your image into assets/images/meme/ (or any subdirectory inside it). The filename becomes the slash command name, so choose something clear and Discord-safe.
2

Register the command with Discord

Run the deploy script to push the new slash command definition to your guild:
bun run deploy
3

Restart the bot

Start or restart the bot so registerMemeSlashHandlers picks up the new file:
bun start
4

Use the command

In any channel, type /<filename_without_ext> (after Discord refreshes its command list, which typically takes a few seconds). The bot replies with the image as an attachment.

Name collision handling

If two files would produce the same derived command name, a numeric suffix is appended to make each name unique. For example, if funny.png and funny.gif both resolve to funny, the second one becomes funny_2, the third funny_3, and so on. Core command names — kojima, gamble, profile, colonel, ping — are reserved. If a meme file would produce one of those names, registerMemeSlashHandlers logs a warning and skips that file entirely:
[meme] Skip "subdir/kojima.png" → /kojima (same name as a core command)

Guild command cap

Discord allows up to approximately 500 guild slash commands. MEME_GUILD_COMMAND_CAP is set to 500. The bot counts available slots by subtracting the number of already-registered core commands from the cap. If the meme directory exceeds the remaining slots the bot logs a warning and stops registering further files:
[meme] Stopped at guild cap (500 commands). Extra files ignored.
Meme commands are guild-scoped (uses GUILD_ID from .env). Re-run bun run deploy whenever you add or remove images to keep Discord’s command list in sync with your assets/images/meme/ folder.

Build docs developers (and LLMs) love