# Discord

> Operate a Discord bot in your server.

Lets an agent operate a Discord bot in a server (guild) you control.

## What it can do

| Method | What it does |
| --- | --- |
| `discord_get_me` | Get the bot's own profile (user @me). |
| `discord_get_guild` | Get a server (guild) by id; with_counts optional. |
| `discord_list_guild_channels` | List all channels in a server (text, voice, categories, threads). |
| `discord_list_guild_roles` | List all roles in a server. |
| `discord_get_channel` | Get a channel object by channel_id. |
| `discord_list_messages` | Read a channel's recent messages (limit, before, after, around). |
| `discord_send_message` | Send a message; supports content, embeds, and reply via message_reference. |
| `discord_edit_message` | Edit a message previously sent by the bot. |
| `discord_delete_message` | Delete a message (requires permission). |
| `discord_bulk_delete_messages` | Bulk-delete 2-100 messages newer than 14 days. |
| `discord_add_reaction` | Add a reaction (emoji unicode or name:id). |
| `discord_remove_own_reaction` | Remove the bot's own reaction from a message. |
| `discord_create_thread_from_message` | Create a thread from a message in a text channel. |
| `discord_join_thread` | Join a thread by thread_id. |
| `discord_leave_thread` | Leave a thread by thread_id. |
| `discord_list_active_threads` | List active threads in a server. |
| `discord_list_public_archived_threads` | List public archived threads in a parent channel. |
| `discord_list_guild_members` | List server members (paginated by `after` + limit). |
| `discord_get_guild_member` | Get a server member by user_id. |
| `discord_trigger_typing` | Show the typing indicator in a channel for ~10 seconds. |
| `discord_pin_message` | Pin a message in a channel. |
| `discord_unpin_message` | Unpin a previously pinned message. |
| `discord_list_pins` | List pinned messages in a channel. |
| `discord_crosspost_message` | Publish a message from an announcement channel. |
| `discord_create_forum_thread` | Create a post in a forum channel (initial message in `message`). |
| `discord_get_message` | Get one message by channel_id + message_id. |
| `discord_get_user` | Get a user profile by Discord snowflake. |
| `discord_create_dm` | Create a DM channel with a user; returns channel id for send_message. |
| `discord_create_channel_invite` | Create an invite for a channel. |
| `discord_list_guild_invites` | List invites for a server (requires MANAGE_GUILD). |
| `discord_list_channel_webhooks` | List webhooks attached to a channel. |
| `discord_create_webhook` | Create a webhook in a channel. |
| `discord_execute_webhook` | Send a message via webhook (no bot token required). |
| `discord_list_guild_emojis` | List custom emojis defined on a server. |
| `discord_add_guild_member_role` | Grant a role to a member. |
| `discord_remove_guild_member_role` | Remove a role from a member. |
| `discord_modify_guild_member` | Patch a member: nickname, roles, mute/deafen, timeout, voice channel. |
| `discord_remove_guild_member` | Kick a member from a server. |
| `discord_create_guild_channel` | Create a new channel on a server. |
| `discord_delete_channel` | Delete a channel by id. |
| `discord_modify_channel` | Modify a channel (name, topic, slowmode, parent, etc). |
| `discord_list_scheduled_events` | List scheduled events in a server. |
| `discord_get_scheduled_event` | Get one scheduled event by id. |
| `discord_create_scheduled_event` | Create a scheduled event (stage, voice, or external with end_time + location). |
| `discord_list_thread_members` | List members of a thread. |
| `discord_get_thread_member` | Get a thread member by user_id. |
| `discord_list_private_archived_threads` | List private archived threads in a channel (requires permission). |

## How to get credentials

1. Open the
   [Discord Developer Portal](https://discord.com/developers/applications).
2. **New Application** → name it → open **Bot** → **Reset Token** →
   copy.
3. Under **Bot**, enable intents you plan to use
   (Message Content, Server Members, etc.).
4. Under **OAuth2 → URL Generator**, pick scope `bot` and the
   permissions you want, open the URL, and add the bot to your server.
5. Back in Discord: enable *Developer Mode* in **User Settings →
   Advanced**, right-click your server, **Copy Server ID**.

## Fields to fill in FlyMyAI

| FlyMyAI field | Where it comes from |
| --- | --- |
| `DISCORD_TOKEN` | Developer Portal → Bot → Token |
| `DISCORD_GUILD_ID` | Right-click server → Copy Server ID |

## Troubleshooting

- **`Missing Access`** - the bot lacks permission on the target channel.
  Edit channel permissions or give the bot role the needed flags.
- **`Missing Intents`** - enable the required privileged intent in the
  Developer Portal and restart.

## Links

- [Discord Developer Portal](https://discord.com/developers/applications)
- [API reference](https://discord.com/developers/docs/reference)
