11 Discord bot setup
Nick edited this page 2023-02-12 02:30:12 -05:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(based upon https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token)

Create Bot

First, you need to go here and click “New Application”.

Application Screen

Now give your bot a name.

Create an Application Screen

Click “Create”. On the next screen, you can optionally set an Avatar Icon for your app and description.

New App Screen

Next, click on Bot on the left-hand menu

Bot menu item

hen click “Add Bot”

Add Bot

Click “Yes Do It”

Yes Do It.

On the Bot screen you will generate your token. Click “Reset Token” and “Yes, Do It!” a second time.

Reset Token
Yes, Reset Token

Then you can click “Copy” to put the token it in your clipboard. Keep this for your matterbridge config file.

Token

Here, you can also toggle if the bot is public, which will allow others to invite to their servers. This is off by default and will not do anything unless the matterbridge configuration file lists the servers it has been invited to, so you should just leave this off.

Public Bot

Privileged Gateway Intents

Make sure to also toggle the “Server Members Intent” and “Message Content Intent” options further down under “Privileged Gateway Intents” to allow the bot to see the member list, otherwise youll get an error message similar to Error obtaining server members: HTTP 403 Forbidden, {"message": "Missing Access", "code": 50001}.

Click “Save Changes”

Server Members Intent

Invite bot

Now its time to invite your bot to your server. Dont worry about your bot being started for this next step. You can get this under OAuth2 → General Client ID

Copy the client ID into this URL and go to it


The weird number (536870912 = 0x20000000) corresponds to the "Manage Webhooks" permission. If you don't want to use `AutoWebhooks=true`, then you can use `0` instead, but you will need to configure the necessary webhooks manually.

It will prompt you to select your server

![Add Bot](https://user-images.githubusercontent.com/987487/212195690-97e5c675-b34f-4dba-895e-232eedb2f7f7.png)

and then Authorize it

![Authorize Bot](https://user-images.githubusercontent.com/987487/212195594-6c709139-38fa-4ea9-a153-95fa55e64363.png)

Solve CAPTCHA if necessary

![2020-10-14-133937_317x178_scrot](https://user-images.githubusercontent.com/987487/96025132-b8616680-0e22-11eb-983b-a9e10426965f.png)

Then you should see

![Authorized](https://user-images.githubusercontent.com/987487/212195597-dc4b9a47-87ff-4a03-90b4-b2db034bf606.png)

You can confirm the bot is added by looking in your #general channel for "A wild [bot name] appeared!" or "Welcome [bot name]. We hope you brought pizza." or some other pithy welcome message, and checking under Your Guild > Settings > Integrations > Bots and Apps.


## Invite to channels

For each channel you want to bridge, you need to make sure the bot user is a member.

The bot should be in all public channels in your server by default, but for private channels you must either make sure to give it an appropriate Role, or to directly add it under Edit Channel > Permissions > Roles/Members

![Edit Channel](https://user-images.githubusercontent.com/987487/218298368-a236ede4-c08a-46df-901c-96a7c33b6b13.png)
![Permissions](https://user-images.githubusercontent.com/987487/218298370-70078ee3-bf80-4082-9f72-c6510fd8d99d.png)

It needs to have View and Send permissions

![View Permission](https://user-images.githubusercontent.com/987487/218298416-c5c31b4a-0b90-4bdb-b632-eddb15e5a158.png)

![Send Permission](https://user-images.githubusercontent.com/987487/218298425-dff62127-b27c-44e6-9285-66ad06f94ea3.png)


If you have trouble with this, open an issue and we can improve these docs.


## Matterbridge Config

Take the bot's token (the _token_, not the client ID) and add it to your matterbridge config like so:

[discord.yourbridgeid] Token=“NzY1OTgwMjA2Nzc4Mjg2MTIx.Gpz4tE.HOslqKftF2_bm2y_bIaaACyy3_vLBmbevl02JQ” # …. ```

Then set up your individual bridges.