> For the complete documentation index, see [llms.txt](https://docs.wornoffkeys.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wornoffkeys.com/features/what-is-a-feature.md).

# Features

{% embed url="<https://youtu.be/_67r4wq23BA?t=788>" %}

Sometimes you want files to be ran without them being a command or a DJS event listener. WOKCommands refers to these files as "feature files". You can specify a "features" directory and all exported functions from files in that directory will be ran when your bot starts up.

Here is an example of how to specify your "features" folder:

{% tabs %}
{% tab title="JavaScript" %}
{% code title="index.js" %}

```javascript
const { Client, IntentsBitField, Partials } = require("discord.js");
const path = require("path");
const WOK = require("wokcommands");
require("dotenv/config");

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

client.on("ready", () => {
  console.log("The bot is ready");

  new WOK({
    client,
    mongoUri: process.env.MONGO_URI || "",
    commandsDir: path.join(__dirname, "commands"),
    featuresDIr: path.join(__dirname, "features"),
  });
});

client.login(process.env.TOKEN);
```

{% endcode %}
{% endtab %}

{% tab title="TypeScript" %}
{% code title="index.ts" %}

```typescript
import { Client, IntentsBitField, Partials } from "discord.js";
import path from "path";
import WOK from "wokcommands";
require("dotenv/config");

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

client.on("ready", () => {
  console.log("The bot is ready");

  new WOK({
    client,
    mongoUri: process.env.MONGO_URI || "",
    commandsDir: path.join(__dirname, "commands"),
    featuresDIr: path.join(__dirname, "features"),
  });
});

client.login(process.env.TOKEN);
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Example File

All functions that are exported from files in the "features" folder will now be ran whenever your bot starts up. The WOKCommands "instance" object and your bot's "client" object will be sent to this function. Example:

{% tabs %}
{% tab title="JavaScript" %}
{% code title="feature-example.js" %}

```javascript
module.exports = (instance, client) => {
  console.log("Hello World!");
};
```

{% endcode %}
{% endtab %}

{% tab title="TypeScript" %}
{% code title="feature-example.ts" %}

```typescript
export default (instance: WOK, client: Client) => {
  console.log("Hello World!");
};
```

{% endcode %}
{% endtab %}
{% endtabs %}
