| 1 | = Redirect Discord messages to NLP Matrix |
| 2 | |
| 3 | Redirecting selected rooms or servers from Discord to a NLP Matrix space is easy. |
| 4 | You only need to have a user account on both the Discord and NLP Matrix servers and you are ready to go. |
| 5 | |
| 6 | |
| 7 | [[PageOutline(2,The Discord -> Matrix setup consists of the following steps:,inline)]] |
| 8 | |
| 9 | == Find the Discord tokens and IDs |
| 10 | |
| 11 | Connect to the Discord app at https://discord.com/channels/@me |
| 12 | and find out the user token and the room and Discord server (guild) IDs. |
| 13 | |
| 14 | === Discord user token |
| 15 | |
| 16 | Since the Matrix discordbot must operate on Discord on your behalf, you need to provide it with the corresponding `Authorization` token. The steps to find the token are as follows. |
| 17 | |
| 18 | 1. Press `<F12>` to open the ''Browser developer tools''. Go to the |
| 19 | ''Network'' tab and filter the URL list for `api`. Reload the web page. |
| 20 | 1. Choose one of the URLs in the list with type `xml` or `xhr`. Display the ''Request headers''. |
| 21 | 1. Find `Authorization` in the header list - its value, is the **user token**. It should be something like `HEWkw2HE329cdsIOAAKSLFoosd.cspdfpoutwBJDW304DAQWEu0sdyvbsasDV02dfsggd3Ie`. |
| 22 | |
| 23 | === Discord server/guild and room IDs |
| 24 | |
| 25 | Navigate to the selected Discord room within your https://discord.com/channels/@me app. Look at the URL of the room. |
| 26 | It should look like |
| 27 | {{{ |
| 28 | https://discord.com/channels/3254238502750491529/1650295748356024125 |
| 29 | }}} |
| 30 | The two numbers, `3254238502750491529` and `1650295748356024125` are the |
| 31 | **server ID** (also called guild ID) and **channel ID**. |
| 32 | |
| 33 | == Create a NLP Matrix discordbot room |
| 34 | |
| 35 | Login to NLP Matrix and create a new room named e.g. `Discord bridge bot`. |
| 36 | Invite user `@discordbot:nlp.fi.muni.cz` to the room. You should see the message |
| 37 | {{{ |
| 38 | Hello, I'm a Discord bridge bot. |
| 39 | This room has been registered as your bridge management/status room. |
| 40 | Use help for help or login to log in. |
| 41 | }}} |
| 42 | In this room, you will be commanding your Discord bridging bot. You may start with the `help` command. |
| 43 | |
| 44 | == Choose which Discord items should be mirrored |
| 45 | |
| 46 | First, you need to log the `discordbot` to Discord on your behalf. Recall the |
| 47 | ''user token'' that you have found in the previous section and in the NLP Matrix |
| 48 | `Discord bridge bot` room enter the command: |
| 49 | {{{ |
| 50 | login-token user HEWkw2HE329cdsIOAAKSLFoosd.cspdfpoutwBJDW304DAQWEu0sdyvbsasDV02dfsggd3Ie |
| 51 | }}} |
| 52 | where the `HEWk...Ie` is your `Authorization` user token. |
| 53 | |
| 54 | The discord bot should reply with |
| 55 | {{{ |
| 56 | Connecting to Discord as user ID 4029354238562374375 |
| 57 | Successfully logged in as @your.discord.user.name |
| 58 | }}} |
| 59 | |
| 60 | When logged in, you may connect as many Discord servers as you wish. |
| 61 | You don't even need to look for the server/guild ID at Discord. |
| 62 | Just ask discordbot to |
| 63 | {{{ |
| 64 | guilds status |
| 65 | }}} |
| 66 | and it will answer with your list of Discord servers such as |
| 67 | {{{ |
| 68 | |
| 69 | }}} |
| 70 | The easiest way is just to find the and instruct the |
| 71 | discordbot to |
| 72 | {{{ |
| 73 | List of guilds: |
| 74 | |
| 75 | FI MUNI (252345435334213123) - never bridge messages |
| 76 | DigiLing (5562352412313131231) - never bridge messages |
| 77 | ... |
| 78 | }}} |
| 79 | Now instruct discordbot to establish the bridge |
| 80 | {{{ |
| 81 | guilds bridge 252345435334213123 --entire |
| 82 | }}} |
| 83 | shoud lead to |
| 84 | {{{ |
| 85 | Successfully bridged guild |
| 86 | }}} |
| 87 | and discordbot creating a number of new invites for you to NLP Matrix space named `Discord` and to new NLP Matrix room for each Discord room in the bridged Discord server. |
| 88 | |
| 89 | [[br]] |
| 90 | |
| 91 | That's it! Now you can manage Discord and Matrix room in one place! |