> ## Documentation Index
> Fetch the complete documentation index at: https://illegalcord.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Build Your First Plugin

> Create a small Illegalcord plugin inside the local source tree.

This guide creates `PrefixEveryMessage`, a small plugin that adds a configurable prefix to outgoing messages. It uses the declarative `onBeforeMessageSend` field, so `PluginManager` handles registration and cleanup.

## Create the folder

Create:

```text theme={null}
src/userplugins/prefixEveryMessage/index.ts
```

## Add the plugin

```typescript theme={null}
/*
 * Vencord, a Discord client mod
 * Copyright (c) 2026 Vendicated and contributors
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

import { definePluginSettings } from "@api/Settings";
import type { MessageObject } from "@api/MessageEvents";
import { EquicordDevs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";

const settings = definePluginSettings({
    enabled: {
        type: OptionType.BOOLEAN,
        description: "Add the prefix to outgoing messages.",
        default: true
    },
    prefix: {
        type: OptionType.STRING,
        description: "Text to add before each outgoing message.",
        default: "[Illegalcord] "
    }
});

export default definePlugin({
    name: "PrefixEveryMessage",
    description: "Adds a configurable prefix to messages you send.",
    authors: [EquicordDevs.irritably],
    settings,

    onBeforeMessageSend(_channelId: string, message: MessageObject) {
        const { enabled, prefix } = settings.store;
        if (!enabled || !message.content.trim()) return;

        message.content = prefix + message.content;
    }
});
```

Replace `EquicordDevs.irritably` with your own author entry before submitting the plugin.

## Build and test

Run:

```bash theme={null}
pnpm build
pnpm inject
```

Restart Discord, open **Illegalcord Settings > Plugins**, search for `PrefixEveryMessage`, and enable it.

## Configure it

Open the plugin cog wheel and edit:

| Setting                                       | Default          |
| --------------------------------------------- | ---------------- |
| **Add the prefix to outgoing messages.**      | `true`           |
| **Text to add before each outgoing message.** | `[Illegalcord] ` |

Send a test message in a private test channel.

## Clean up

This plugin uses a declarative field, so no manual `stop()` cleanup is needed. If you later add timers, event listeners, manual API registrations, or Flux subscriptions outside declarative fields, clean them up in `stop()`.

<Warning>
  Do not keep this plugin enabled in normal chats unless you intentionally want every sent message modified.
</Warning>
