Using Discord to Play Music for TTRPGs

This tutorial is to explain how to pipe music into your TTRPG sessions using Discord and Hydra Bot. It leverages some Autohotkey scripts I wrote and some curated Spotify playlists.

Step 1 - Download Autohotkey

This will only work on Windows as Autohotkey is a Windows application.

Download and install Autohotkey from here: https://www.autohotkey.com/

You can read the documentation if you want, it’s not really necessary as the Autohotkey scripts I wrote are self-contained, you just need the program installed on your computer.

Step 2 - Set up a Discord Server

Pretty simple, most of you can skip this step, but here are some screenshots to show you how:

Add Server

Add Server

Add Server

Step 3 - Add Hydra Bot to Discord Server

Head to https://hydra.bot/ and invite Hydra to your server.

Select the server you want to add it to and click “Continue”

Hydra will now have joined your server

Type .setup to initiate the setup, the bot will create a channel to request music in. You can rename this channel by right clicking on it and going to “Edit Channel.”

Step 4 - Download the Autohotkey Scripts

Download the Autohotkey scripts I created here: https://maderschramm.itch.io/discord-ttrpg-music-scripts

They’re all simple files that look like this:

Sample Autohotkey File
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Sleep, 2000

Send, .clear {Enter}

Send, .play https://open.spotify.com/playlist/7cgECSzxFYwjHugNdbur1O -s {Enter}

Send, .skip {Enter}

The scripts are very simple, they simply idle for 2 seconds to give you time to click on the Discord window, then send the .clear command to Hydra to clear the current queue, load a new playlist and shuffle it, then skip to the next song.

An example for how you would use it in-game would be that your PCs are traveling down the road, so you would run the Atmosphere - Road.ahk script. Simply move to the song request channel on your Discord server, double-click the Atmosphere - Road.ahk script, and then click on the message area of the Discord window.

After traveling for some time, your players get into an encounter, so you then double-click the Combat - Standard.ahk script and click on the Discord message area. During the combat, one of the retainers died, so you then double-click the Mood - Somber.ahk script and click on the message area. The party then returns to the nearest city, so you then double-click the Atmosphere - Town.ahk script and click on the Discord message area.

You can edit the scripts to run any spotify playlists you want. I set up these scripts around some I found on reddit here.

The Campaign - Theme.ahk script is a little different than the others. It contains the following commands:

Campaign - Theme.ahk
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Sleep, 2000

Send, .clear {Enter}

Send, .play https://www.youtube.com/watch?v=V2liozIXhJA {Enter}

Send, .loop {Enter} 

It idles for 2 seconds like the other scripts, clears the queue (just in case), then plays only a single song (whatever theme you want for your campaign, mine is the remix of the Morrowind theme), and then loops the queue. You should run this script first and only first as it doesn’t skip songs automatically and looping the queue more than once will toggle between loop queue, loop a single song, and disabled.

For that script, change the https://www.youtube.com/watch?v=V2liozIXhJA song to whatever song you want for your campaign’s theme, and remember to play it before any others if you’d like to utilize a campaign theme. I run it while my players discuss what happened during the previous session.

Hopefully this was helpful for you and allows you to easily incorporate some mood music into your TTRPG sessions running on Discord.

3 Likes

Huh, this is very interesting. I’ve always used Groovy bot, and its worked perfectly so far. So is the main advantage of this method that you can quickly switch between the same tracks without having to copy links?

Correct, by simply double-clicking a script file, Hydra will clear the current queue, load the new playlist, shuffle it, then start playing it, creating a seamless music transition for you and your players with minimal input from the referee.

I had trouble implementing seamless music with Groovy, because its -clear command stops the currently playing song, so there will always be a break in the ambient music while you load the next set of tracks. It also seems that you need to load and start playing a queue before you can -shuffle it, which means then you have a track start, the queue is shuffled, a skip, and then the next track is played. This isn’t ideal 1) because your players will always hear the first track when you load a playlist and 2) there’s a break in the music while it changes songs.

Perhaps there’s a way to do it with Groovy by addressing the issues I had above; however, Hydra provides a seamless music experience and is free, so I don’t see a reason not to use it for this application.

I took more videos to help illustrate what I’m talking about. Make sure you turn the sound on.

Here’s my Hydra Bot:

You’ll notice even when I load the same script, a different song would play as the shuffling takes place when the tracks are loaded.

Here’s Groovy:

1 Like