# Events

Event files load automatically from `src/events`.

## Event format

```js
module.exports = {
  name: 'interactionCreate',
  run: async (client, interaction) => {
    const guildData = await client.database(
      { guildId: interaction.guildId },
      'guilds'
    );

    if (interaction.isButton() && interaction.customId === 'save-name') {
      guildData.ownerName = interaction.user.username;
      await guildData.save();

      await interaction.reply({ content: 'Name saved successfully.' });
    }
  }
};
```

## Notes

* `client.config` exposes the full config object
* Helpers like `client.database()` exist only when the module is enabled
* Keep event files focused on input, services, and response flow


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.discremy.com/documentation/project-structure/events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
