Connect a Garry's Mod Server with a Discord Server!
When you die in Garry's Mod Trouble in Terrorist Town, you normally are not allowed to speak anymore. You will be muted automatically in game and can't talk anymore until you respawn. Since some people use Discord as an alternative voice chat with higher quality the in game voice chat is less in use. In Discord you have to mute yourself or be silent "manually" to avoid disturbance. TTTDiscordLink is a setup that connects your Garry's Mod server and your Discord server to automatically mute players who die and unmute them when they get revived or respawn.
Basically there are three components that work together to make the magic happen:
- The Garry's Mod server script
- The webpage & database
- The Discord bot
And this is how they work together:
- When someone dies or respawns in game the server script will send a request to my (or your) webpage including the info which player to target and whether to mute or unmute them.
- The webpage will edit the specific table corresponding to your Discord server which was created by the Discord bot.
- The Discord bot will periodically check if a player has to be muted or unmuted by observing the database.
Whether you want a quick setup using my service or want to setup everything by yourself you have two options:
- Install the server script.
- Add my Discord bot to your Discord server.
- Configurate the Discord bot.
- Install the server script.
- Setup your own Discord bot.
- Add your own Discord bot to your Discord server.
- Configurate the Discord bot.
- Setup your own database and webpage.
Here are a couple of additional documentations that may help you.
- Link SteamID64 With DiscordID (also mentioned below)
- Commands (including manually token generation)
- Move TTTDiscordLink.lua to GMOD_SERVER_DIRECTORY/garrysmod/garrysmod/lua/autorun/server.
- Insert your Discord server ID into the quotation marks at
local DiscordID = ""
. - Insert your token you received from the Discord bot into the quotation marks at
local Token = ""
. - Restart your Garry's Mod server.
- [OPTIONAL] Only if you want to use your own Discord server & database:
- Change the URL in the quotation marks to your own URL pointing to TTTDiscordLink.php at
local Webpage = "https://old.zlyfer.net/sites/games/gmod_ttt/TTTDiscordLink.php"
.
- Change the URL in the quotation marks to your own URL pointing to TTTDiscordLink.php at
- Use this link to add my bot TTTDiscordLink to your Discord server: Discord Bot Invite.
- Keep in mind that the bot needs following rights: MUTE_MEMBERS and VIEW_CHANNEL.
- The permission for SEND_MESSAGES is not mandatory but extremely recommended!
- See Discord Bot Permissions for reference.
- Upon invitation the bot will send you a token. As mentioned, you need to insert this token inside of TTTDiscordLink.lua.
Every player has to tell the bot which SteamID64 they have.
Basically you have to use the command ~zltd~link [SteamID64]
to link your DiscordID with your SteamID64 so the bot can
mute you when you die.
I made an in depth tutorial which should help on how to access your SteamID64 and how to properly link it with your DiscordID.
- Rename token_template.json to token.json and insert your Discord bot token into the quotation marks.
- Rename db_config.template.json to db_config.json and add your database credentials.
- Install bot dependencies and start the bot.
Using npm
npm install
npm start
Using yarn
yarn install
yarn start
- Move TTTDiscordLink.php to a directory on your webserver. Make sure it is exactly where
local Webpage
in TTTDiscordLink.lua is pointing to. - Fill in your database credentials using the variables in TTTDiscordLink.php.
- Create a database called 'TTTDiscordLink' and invite your Discord bot to your Discord server.
- If you already invited the bot to the server simply restart the Discord bot.
If you don't know how to make your own Discord bot, install npm or similar you should stick to the Simple Way.
In case you want to use the Advanced Way anyway the links below might help you but please read the Disclaimer first.
- How to make a Discord bot and invite it to your Discord server.
- What is npm or yarn.
- Yarn vs npm.
- How to install npm or yarn on Windows.
- How to install npm or yarn on Linux.
- How to open the Command Prompt or PowerShell on Windows.
- How to open the Terminal on Linux.
- Switch from botPrefix + command messages to /commands.
- In case you didn't receive a token when you invited the Discord bot to your Discord server you can use the command
~zltd~token
to generate a new token.
The links and tutorials are quickly searched in a haste. I am not responsible if you mess anything up but you can always open an issue if you have questions. In case you are unsure or worried, please use the Simple Way as mentioned.
The bot will be able to server-side un/mute people on your discord server!
At the moment everyone can mute people on your Discord server if they know it's ID and the SteamID64 of a specific
person on your Discord server (if linked in database). - Tokens are now a thing!