# Discord

> Add By Dawn to a Discord server, the permissions the bot asks for, what works in Discord today, and disconnecting.

This page is for org admins. It shows you how to add By Dawn to a Discord server. Once it's added, people can create and
search tickets with `/saw`, turn a message into a ticket, and manage the channel's subscriptions. Each member then
links their own account (see [Connect your chat account](https://docs.bydawn.com/chat-accounts/)).

## Before you start

- You need to be an org admin in By Dawn.
- In Discord, you need the **Manage Server** permission on the server you're adding By Dawn to.

## Connect

1. In By Dawn, open **Organization settings › Chat integrations** and choose **Connect** on **Discord**. If a server is
   already connected, the button reads **Add a server**.

2. Discord asks which server to add By Dawn to, and shows the permissions below. Pick the server and choose
   **Authorize**.

3. You're back in By Dawn, and the server is listed as **Connected**.

Finish within 10 minutes of choosing **Connect**, or start again. Next, a project admin binds channels (see [Bind a
channel](https://docs.bydawn.com/chat-channels/)). By Dawn can be bound to the server's text and announcement channels.

## What the bot asks for

By Dawn asks to add a bot with application commands (`bot applications.commands`), and these permissions:

- View Channels
- Send Messages and Send Messages in Threads
- Create Public Threads
- Embed Links and Attach Files
- Read Message History

None of them is a privileged permission, and By Dawn doesn't ask for the **Message Content** intent. By Dawn works through
Discord's interactions: Discord sends By Dawn a command, a button click or a form, and nothing else. By Dawn never sees the
rest of the channel.

When a member links their account, Discord asks them to share their username (`identify`), and By Dawn checks they're a
member of the connected server.

## What works in Discord today

The [command reference](https://docs.bydawn.com/chat-commands/#discord) lists everything. In short:

- `/saw create` opens the create form, and **Create SAW ticket** (a message's **Apps** menu) turns a message into a
  ticket, with its files.
- `/saw search` finds tickets, privately.
- `/saw subscribe` lists, adds and removes the channel's subscriptions. Only project admins can change them.
- Subscriptions and chat DMs arrive as messages with buttons. Discord has no confirm dialog, so a button that needs
  one asks "Are you sure?" privately first.

`/saw` works only in servers, not in DMs with the bot.

Because By Dawn doesn't read channel messages, these don't work in Discord yet: @SAW, the 🎫 reaction, request channels
(**Every message**), synced threads and ticket link previews. Someone without a linked account can still file a
request in a bound channel, through the create form.

## When Discord stops accepting By Dawn

If the bot is removed from the server, or loses access, By Dawn notices the next time it tries to post there. The server
then shows **Needs reconnecting** in **Organization settings › Chat integrations**, and nothing posts there until an
admin chooses **Reconnect** and adds the bot again.

## Disconnect

Choose **Disconnect** next to the server. The bot leaves the server, and By Dawn:

- unbinds every channel in it from its project, with the channels' subscriptions;
- unlinks every member's Discord account in it, and revokes what they let By Dawn do as them;
- stops updating its cards.

Removing the bot in Discord doesn't do this: By Dawn keeps the server's bindings and links, marked **Needs
reconnecting**, until you disconnect it here. Comments already made from Discord stay on their tickets.

> **Note:** The bot's token belongs to By Dawn's own Discord application, not to your server, so there's no token of yours to revoke.

## Where to go next

- [Bind a channel](https://docs.bydawn.com/chat-channels/).
- [Chat command reference](https://docs.bydawn.com/chat-commands/#discord).
- [Chat integrations](https://docs.bydawn.com/chat/): who may do what, and what By Dawn keeps.

Source: https://docs.bydawn.com/chat-discord/
