> For the complete documentation index, see [llms.txt](https://docs.nighty.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nighty.one/custom-features-tab/understanding-events-and-parameters.md).

# Understanding Events and Parameters

## Discord is constantly sending you events

Let's start with something you do every day.

You open a server, click on **#general**, and you see people chatting. Messages appear on your screen the moment someone sends them.

Have you ever wondered *how* they get there?

Here's what actually happens. Every time someone sends a message, Discord sends a small notification to your Discord app that says, roughly:

> "Hey - something just happened. A new message was created. Here are the details."

<figure><img src="/files/FrbizTq2SxlJnAdRdRAO" alt=""><figcaption></figcaption></figure>

That notification is called an **event**. Your Discord app receives it, reads the details, and draws the message on your screen.

**An event is simply:&#x20;*****something happened*****, plus&#x20;*****the details about it*****.**

You never see events yourself - they happen silently in the background, hundreds of times a day. But they are always there.

### Events are not just messages

New messages are the most obvious example, but Discord sends an event for almost everything that happens around your account:

* A message is sent, edited, or deleted
* Someone reacts to a message with an emoji
* A member joins or leaves a server
* A role is given to or taken from a member
* Someone changes their nickname
* A channel is created, renamed, or deleted
* Someone joins or leaves a group DM
* A user changes their username or avatar

Every single one of those is an event.

### Where Nighty comes in

Nighty listens to the exact same events your Discord app does.

**Custom Features let you say: "When THIS event happens, do THAT."**

That's the core idea. Everything else in this documentation is just detail on top of it.

{% hint style="info" %}
**Important:** a Custom Feature does nothing until its event happens. If you build a feature that reacts to new messages, it sits quietly doing nothing until somebody sends a message. This is normal - it's not broken.
{% endhint %}

## Every event carries parameters

An event isn't just a signal saying "something happened." It also carries **information about what happened**.

Think of an event as a **delivered package**. The package tells you *something arrived*. But what's useful is **what's inside the box**.

The things inside the box are called **parameters**.

When someone sends a message, the **New Message** event arrives carrying these parameters:

| Parameter   | What it is                                                        |
| ----------- | ----------------------------------------------------------------- |
| **message** | The message itself                                                |
| **user**    | The person who sent it - you, a friend, a stranger, or a bot      |
| **channel** | Where it was sent - a text channel like #general, or a DM         |
| **guild**   | The server it was sent in *(only if it wasn't a DM)*              |
| **member**  | The sender, as a member of that server *(only if it wasn't a DM)* |
| **me**      | You - your own Discord account. Always available                  |

Those are the pieces of information Nighty hands you to work with.

{% hint style="info" %}
We say **Guild** where Discord's interface says **Server**. They mean exactly the same thing. Discord's own developers call servers "guilds," and Nighty follows that. Whenever you read **guild** in Nighty, think **server**.
{% endhint %}

## A parameter is not one value - it's a container of details

This is the part that clicks for most people once they see it.

A parameter isn't a single piece of text. It's a **container** holding many details inside it.

<figure><img src="/files/lChGeV29K4h5OeTG6XFY" alt=""><figcaption></figcaption></figure>

Look at the message above on your screen right now. Discord is showing you several separate details at once:

* The **avatar** on the left (User → Avatar)
* The **name** in bold (User → Name)
* The **content** of the message (Message → Content)

Discord got all of those out of the parameters that came with the event - and you can get them out too.

You'll see these details written in blue boxes in the Custom Features Tab, like this:

<figure><img src="/files/AYm4M0gsAOEjqTbBWzOs" alt=""><figcaption></figcaption></figure>

You never have to type them by hand - the editor gives you an Expression Builder and inserts them for you. Read it as **"the `content` detail, taken from the `message` parameter."**

<figure><img src="/files/UvMUaPQhUsP8qMwtB4I9" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
**The mental model:** the **event** tells you *what happened*. The **parameters** tell you *who and where and what was involved*. The **details** inside each parameter are the actual values you use.
{% endhint %}

## Parameters that sound the same but aren't

Some parameters have similar names and it's easy to mix them up. This section is worth reading twice - most beginner confusion lives right here.

### `user` vs `member` - the important one

Both refer to **the same person**. The difference is *which side of them* you're looking at.

**`user` is the general Discord account.** Every human (and bot) on Discord is a user. This is who they are everywhere, across all of Discord. Their username, their avatar, their account age. **A `user` is always available**, no matter where the event happened.

**`member` is that same person&#x20;*****inside one specific server*****.** A member is a user who has joined a server, and being a member comes with server-specific things: their nickname on that server, the roles they have there, when they joined, and what can be done to them there - kick, ban, timeout, add role, remove role.

{% hint style="warning" %}
**`member` only exists when the event happened inside a server.** If someone sends you a direct message, there is no server involved - so there is **no member**, only a **user**.
{% endhint %}

An example. Imagine your friend Anna:

|                    | As a `user`               | As a `member`                         |
| ------------------ | ------------------------- | ------------------------------------- |
| Who                | Anna, the Discord account | Anna, in *this particular server*     |
| Username           | `annabanana`              | *(same — it comes from the user)*     |
| Nickname           | ❌ doesn't exist           | ✅ "Anna 🌸" - but only on this server |
| Roles              | ❌ doesn't exist           | ✅ Moderator, Verified                 |
| Can you kick them? | ❌ no such thing           | ✅ yes, from this server               |
| Available in a DM? | ✅ always                  | ❌ never                               |

Anna is one person. In a server she's both a user *and* a member. In your DMs she's only a user.

**How to choose:**

* Want their username, avatar, ID, or an @mention? → use **`user`**
* Want their nickname, roles, join date, or to kick/ban/timeout them? → use **`member`**

### `channel` vs `server_channel` vs `group_channel`

All three are places where messages live. They differ in *what kind* of place.

| Parameter           | What it means                        | Works in                        |
| ------------------- | ------------------------------------ | ------------------------------- |
| **channel**         | Any channel at all - the general one | Server channels, DMs, group DMs |
| **server\_channel** | A channel that belongs to a server   | Servers only                    |
| **group\_channel**  | A group DM with several people       | Group DMs only                  |

`channel` is the safe general choice. Use `server_channel` when you need something that only server channels have - a topic, a category, server-specific settings.

### `message` vs `message_before_edit` vs `message_replied_to`

These show up on message events and each points at a *different* message:

| Parameter                 | Which message it is                                            |
| ------------------------- | -------------------------------------------------------------- |
| **message**               | The message the event is about                                 |
| **message\_before\_edit** | What that message looked like **before** it was edited         |
| **message\_replied\_to**  | The **older message** this one is replying to, if it's a reply |

So on a **Message Edit** event, `message` is the new version and `message_before_edit` is the old version. Comparing the two is how you build something like an edit-logger.

### "before" and "after" parameters in general

Whenever something *changes*, Nighty gives you both versions, so you can compare them:

* **Nickname changed** → `old_nick` and `new_nick`
* **Channel renamed** → `old_name` and `new_name`
* **Channel topic changed** → `old_topic` and `new_topic`
* **Member changed somehow** → `member_before_update` and `member`
* **User changed somehow** → `user_before_update` and `user`

### `me` - always there

Every single event carries a `me` parameter: **your own Discord account.**

It doesn't matter what happened or where - `me` is always available. Use it when you need your own name, avatar, status, friend count, or server count.

## Not every parameter is available every time

This is the number one reason a feature "doesn't work" for beginners.

**The parameters you get depend on where the event happened.**

Compare the same New Message event in two places:

**A message in a server's #general:**

✅ message ✅ user ✅ channel ✅ guild ✅ member ✅ me

**The exact same message, sent as a DM:**

✅ message ✅ user ✅ channel ❌ guild ❌ member ✅ me

There's no server, so there's no `guild` and no `member`. They simply aren't in the box.

Some parameters are conditional in other ways too. `message_replied_to` only exists if the message is actually a reply to something.

{% hint style="info" %}
**Rule of thumb:** if a feature works in servers but seems to do nothing in DMs, you're almost certainly using `guild` or `member` somewhere. Switch to `user` and `channel`, which always exist.
{% endhint %}

### Special events

These two are different - they don't come from Discord at all.

| Event              | Fires when                                                                                              |
| ------------------ | ------------------------------------------------------------------------------------------------------- |
| **Repeat Action**  | On a timer you choose. "Every 60 seconds", "every 10 minutes." Nothing has to happen on Discord at all. |
| **Custom Feature** | When *another* Custom Feature triggers it on purpose. You decide which parameters get handed over.      |

**Repeat Action** is for anything you want to happen on a schedule - post a message every hour, check something regularly, send yourself a reminder.

**Custom Feature** lets you split a big automation into smaller reusable pieces, and have one call another. You'll get a full page on this later.

*(And remember: every event above also carries **me**.)*
