···11---
22-title: Discord
22+title: Discord (Headless)
33toc_min_heading_level: 2
44toc_max_heading_level: 5
55---
6677import Tabs from '@theme/Tabs';
88import TabItem from '@theme/TabItem';
99-import CodeBlock from '@theme/CodeBlock';
109import JsonConfig from '!!raw-loader!@site/../config/discord.json.example';
11101211This scrobbler uses **[Now Playing](/configuration/clients#now-playing)** functionality to set your Discord [Rich Presence](https://docs.discord.com/developers/rich-presence/overview) to the music you are currently monitoring with multi-scrobbler.
13121413<img src={require('/img/discord_presence_art.png').default} height="127"/>
1414+1515+This integration is **headless**, it does not depend on any specific Discord application to be running.
15161617:::warning[Discord TOS Violation]
1718
···11+---
22+title: Discord (Local)
33+toc_min_heading_level: 2
44+toc_max_heading_level: 5
55+---
66+77+import Tabs from '@theme/Tabs';
88+import TabItem from '@theme/TabItem';
99+import JsonConfig from '!!raw-loader!@site/../config/discord-local.json.example';
1010+1111+This scrobbler uses **[Now Playing](/configuration/clients#now-playing)** functionality to set your Discord [Rich Presence](https://docs.discord.com/developers/rich-presence/overview) to the music you are currently monitoring with multi-scrobbler.
1212+1313+<img src={require('/img/discord_presence_art.png').default} height="127"/>
1414+1515+This integration uses an **existing Discord application** to set your Rich Presence.
1616+1717+## Required Setup
1818+1919+### Discord Application
2020+2121+You must create a [Discord App](https://docs.discord.com/developers/quick-start/overview-of-apps) in order to use this integration. Creating an App is free and simple.
2222+2323+Go to the [Discord Developer Portal](https://discord.com/developers/applications)
2424+2525+* Click on "New Application" and give it a name
2626+* Copy the **Application Id** (Client Id) shown after creation
2727+* Add this Id to your Multi-Scrobbler config
2828+ * Env Config => `DISCORD_APPLICATION_ID=12345678`
2929+ * File Config => `"applicationId": "12345678"`
3030+3131+### Discord Connection
3232+3333+This integration uses an existing, running Discord application to communicate with Discord and set Rich Presence. Multi-scrobbler must be able to communicate with the Discord application, either on the same machine or over a network.
3434+3535+<Tabs groupId="hostType" queryString>
3636+3737+<TabItem value="local" label="Local">
3838+3939+In this scenario you have Multi-Scrobbler running on the same machine as Discord.
4040+4141+<details>
4242+4343+<summary>Local (Non-Docker) Installation</summary>
4444+4545+If MS was [installed locally](/installation#local-installation) (not Docker) then MS should automatically detect Discord. This will work for **any OS**.
4646+4747+</details>
4848+4949+5050+<details>
5151+5252+<summary>Docker Installation</summary>
5353+5454+:::note
5555+5656+This works for **Linux/MacOS only.**
5757+5858+:::
5959+6060+If MS is in a docker container you need to find the location of **unix socket** for discord. This is normally named `discord-ipc-0`.
6161+6262+With Discord running, run this command:
6363+6464+```
6565+$ sudo netstat -apeen | grep discord
6666+6767+unix 2 [ ACC ] STREAM LISTENING 11026149 1641787/Discord /home/foxx/.var/app/com.discordapp.Discord/cache/scoped_dirnnxNIn/SingletonSocket
6868+unix 2 [ ACC ] STREAM LISTENING 11036791 1642030/exe /run/user/1000/discord-ipc-0
6969+```
7070+7171+We see that the path we need is
7272+7373+```
7474+/run/user/1000/discord-ipc-0
7575+```
7676+7777+Pass this file into your docker container as a volume and add this path to `DISCORD_IPC_LOCATIONS` `environment:`
7878+7979+```yaml title="docker-compose.yaml"
8080+8181+ environment:
8282+ # ...
8383+ DISCORD_IPC_LOCATIONS=/run/user/1000/discord-ipc-0
8484+ volumes:
8585+ - /run/user/1000/discord-ipc-0:/run/user/1000/discord-ipc-0
8686+```
8787+8888+</details>
8989+9090+</TabItem>
9191+<TabItem value="remove" label="Remote">
9292+9393+:::note
9494+9595+This works for **Linux/MacOS only.**
9696+9797+:::
9898+9999+100100+:::warning
101101+102102+This method is **insecure.** You should not expose this TCP port over a network unless access to the port is restricted and the network is trusted.
103103+104104+:::
105105+106106+On the machine Discord is running on you need to find the location of **unix socket** for discord. This is normally named `discord-ipc-0`.
107107+108108+With Discord running, run this command:
109109+110110+```
111111+$ sudo netstat -apeen | grep discord
112112+113113+unix 2 [ ACC ] STREAM LISTENING 11026149 1641787/Discord /home/foxx/.var/app/com.discordapp.Discord/cache/scoped_dirnnxNIn/SingletonSocket
114114+unix 2 [ ACC ] STREAM LISTENING 11036791 1642030/exe /run/user/1000/discord-ipc-0
115115+```
116116+117117+We see that the path we need is
118118+119119+```
120120+/run/user/1000/discord-ipc-0
121121+```
122122+123123+Use [`socat`](https://linux.die.net/man/1/socat) to bidirectionally relay communication from Discord's unix socket to a listening TCP port. Likely, you will want to setup a service to start this command on login.
124124+125125+```shell
126126+$ socat -v TCP-LISTEN:6655,reuseaddr,fork UNIX-CONNECT:/run/user/1000/discord-ipc-0
127127+```
128128+129129+Finally, in your MS docker compose file add the `host:port` of the host running Discord to `DISCORD_IPC_LOCATIONS` `environment:`
130130+131131+```yaml title="docker-compose.yaml"
132132+133133+ environment:
134134+ # ...
135135+ DISCORD_IPC_LOCATIONS=192.168.DISCORD_HOST.IP:6655
136136+```
137137+138138+</TabItem>
139139+</Tabs>
140140+141141+## Optional Setup
142142+143143+:::note
144144+145145+Due to the limitations of the Discord local API the activity detection and online status customizations found in [Headless](/configuration/discord/discord-headless#optional-setup) are not available for the Local integration.
146146+147147+:::
148148+149149+### Artwork
150150+151151+Multi-scrobbler can display Album Art in your Discord status. The image that is used differs based on if the image URL is publically accessible.
152152+153153+The order in which multi-scrobbler determines what image to use is the same as the order of the tabs shown below.
154154+155155+#### Artwork URL Types
156156+157157+<Tabs groupId="artworkUrl" queryString>
158158+<TabItem label="External URLs" value="external">
159159+MS can use external URLs for artwork.
160160+161161+<img src={require('/img/discord_presence_art.png').default} height="127"/>
162162+163163+External URLs that are not from known music services are **disabled by default.** This is to preserve *your* privacy because Discord does not host images, it only links to them and the URL is visible to other users.
164164+165165+<details>
166166+167167+<summary>Why Should I Care?</summary>
168168+169169+There are some scenarios where you may not want your artwork URLs to be visible, for example:
170170+171171+* A Source may be accessible only on your LAN (Jellyfin at `http://192.168.0.101`)
172172+* A Source may be internet-facing but you do not want to expose this information to discord/other users
173173+* A Source may be internet-facing but requires authentication to view the image
174174+</details>
175175+176176+MS will use your artwork URLs only if:
177177+178178+* artwork url is from a known music service/[Cover Art Archive](./?artworkUrl=caa#artwork-url-types) or
179179+* artwork url starts with `https` and
180180+ * `artwork` (`DISCORD_ARTWORK`) is
181181+ * `true` => always uses the url
182182+ * a list of custom domains keywords an external artwork url should contain EX
183183+ * ENV => `DISCORD_ARTWORK=mycdn,jellyfin`
184184+ * File Config => `"artwork": ["mycdn","jellyfin"]`
185185+186186+</TabItem>
187187+<TabItem label="Musicbrainz/Cover Art Achive" value="caa">
188188+MS can try to use [Cover Art Archive](http://coverartarchive.org/) to get album art. The URL it retrieves is public which means it acts like an External URL that is always available for you.
189189+190190+<img src={require('/img/discord_presence_art.png').default} height="127"/>
191191+192192+MS will try to use Cover Art Archive if:
193193+194194+* The scrobble data does not contain an album art url (no art in dashboard) or the existing url has failed an [External URL](./?artworkUrl=external#artwork-url-types) condition
195195+* and **the scrobble data contains a [Musicbrainz](/configuration/transforms/musicbrainz) Release (Album) MBID**
196196+197197+Basically, if MS would normally use the [MS Default](./?artworkUrl=ms-default#artwork-url-types) art, it will first try to use Cover Art Archive if the scrobble has a Release MBID.
198198+199199+Some Source, like [Jellyfin](/configuration/sources/jellyfin) and [Plex](/configuration/sources/plex), can automatically provide this ID if the music is "matched" in your library.
200200+201201+For all others, you can [**configure MS to use the Musicbrainz Stage**](/configuration/transforms/musicbrainz#use-metadata-for-discord-album-art) for Discord to try to get this MBID.
202202+</TabItem>
203203+<TabItem label="MS Default" value="ms-default">
204204+When these conditions are true:
205205+206206+* Cannot use an [External URL](./?artworkUrl=external#artwork-url-types) and
207207+* Cannot get album art from [Cover Art Archive](./?artworkUrl=caa#artwork-url-types) and
208208+* Play does not contain artwork information (no artwork shown in dashboard)
209209+210210+The status artwork will use a default URL instead of your artwork URL.
211211+212212+Without any other configuration, the default URL is an icon from the [multi-scrobbler repository](https://github.com/FoxxMD/multi-scrobbler/blob/master/assets/default-artwork.png):
213213+214214+<img src={require('/img/discord_presence_ms_default.png').default} height="127"/>
215215+216216+This default image can be customized:
217217+218218+* ENV Config => `DISCORD_ARTWORK_DEFAULT_URL=https://cooldomain.com/art.png`
219219+* File Config => `"artworkDefaultUrl": "https://cooldomain.com/art.png"`
220220+221221+Remember, this URL need to be accessible on the public internet.
222222+</TabItem>
223223+</Tabs>
224224+225225+## Configuration
226226+227227+<Config config="DiscordClientConfig" fileContent={JsonConfig} client name="discord">
228228+ | Environmental Variable | Required? | Default | Description |
229229+ | :---------------------------- | --------- | ------- | :--------------------------------------------------------------------------------------------------------------- |
230230+ | `DISCORD_APPLICATION_ID` | Yes | | Application ID |
231231+ | `DISCORD_IPC_LOCATIONS` | No | | A commera-separated list of `host:port` network locations or file paths to unix socket for Discord |
232232+ | `DISCORD_ARTWORK` | No | | A boolean indicating if external artwork URLs should be used. Or a comma-separated list of allowed domains |
233233+ | `DISCORD_ARTWORK_DEFAULT_URL` | No | | A URL of an image to use as a fallback if the album art URL cannot be used. Or `false` to use discord's default. |
234234+</Config>
···11+---
22+sidebar_position: 2
33+title: Discord
44+toc_max_heading_level: 4
55+---
66+77+This scrobbler uses **[Now Playing](/configuration/clients#now-playing)** functionality to set your Discord [Rich Presence](https://docs.discord.com/developers/rich-presence/overview) to the music you are currently monitoring with multi-scrobbler.
88+99+<img src={require('/img/discord_presence_art.png').default} height="127"/>
1010+1111+There are two types of Discord integrations to choose from:
1212+1313+## Local
1414+1515+The **Local** integration uses an **existing** Discord application on Linux/MacOS to set Rich Presence.
1616+1717+* Uses "permitted" access to Discord, no TOS issues
1818+* More restricted customization compares to Headless
1919+* Only active when your existing Discord application is open
2020+* For instances where Multi-Scrobbler is not on the same machine as Discord
2121+ * Requires an additional program to relay the Discord connection
2222+ * This is potentially insecure, or less secure, then Headless
2323+2424+[**Local Docs**](#/configuration/client/discord/discord-local)
2525+2626+## Headless
2727+2828+The **Headless** integration uses Discord cloud Gateway/API, directly, to set Rich Presence.
2929+3030+* Does not require an existing Discord application (uses Discord cloud API)
3131+* Using this **Violates Discord TOS** because it requires a user token
3232+* More customization than Local
3333+* Active if **any** Discord application is online
3434+3535+[**Headless Docs**](#/configuration/client/discord/discord-headless)