Garry's Mod

Garry's Mod

評價次數不足
[EN] TTT Discord
由 marcel 與 1 位協作者共同發表
"Dead players can't speak!" - This also applies to TTT players in Discord.
In this guide, I'll show you step by step how to set up the TTT Discord Bot on your server.

Dieser Guide ist auch in Deutsch verfügbar.

Workshop object: http://steamproxy.com/sharedfiles/filedetails/?id=1350367721
Github repository: https://github.com/marceltransier/ttt_discord_bot
   
獎勵
加入最愛
已加入最愛
移除最愛
Introduction
"Dead players can't speak!" - That's a fundamental rule for the Garry's Mod gamemode TTT.
But sometimes dead players shout out the name of their murderer right after they died.
To prevent this, dead players can't talk with living players in the ingame voice chat.
But because the voice quality is so bad in the ingame voice chat, the most players use applications like teamspeak or discord to talk. For teamspeak, there is the [TTT] TS3 Bridge that automatically mutes the dead players.
For discord there was so far no such bridge.
That's why I have set myself the task of developing a discord bot that interacts with a Garry's mod addon, that mutes dead TTT players in discord.
Prerequisites
To follow this guide, you must already have installed a garrysmod server this discord of course.
In this guidance I'll show you the installation based on the operating system Debian 8 (Jessie).
But all steps should be applicable to other OSs too.
Installation
At first you need to connect to your server.
I open a terminal windows and connect to my server via ssh.

Install node.js
Next, you have to install node.js.
For that I run this two commands:
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash - sudo apt-get install -y nodejs
If you use an other OS on your server, you can look up here[nodejs.org] how to install node.js on it.
Dowload the bot
To download the bot, you can either simply clone the Github repository or downlaod it as .zip file[github.com] and unpack it.
To clone it you have to install git (if it isn't already installed).
After that, you can clone the repository.
Navigate to the 'discord_bot' directory in the cloned repo.
cd ttt_discord_bot/discord_bot

Install dependencies
If you are in the 'discord_bot' directory you can install the needed packages with this command:
npm install

Create config
Rename the config template named as 'config.json.example' to 'config.json'.
We'll come back later to this file.

Create the discord bot
To create a discord bot, follow this link[discordapp.com] and login if you aren't logged in.
Create a new app by clicking on 'New App'.

Choose a name for your bot and upload a app icono (if you want).
I named him 'TTT Discord Bot' and took this[github.com] as app icon. The app icon will be the profile picture of the bot.

After clicking on 'Create App', scroll down and click on 'Create a Bot User'.

You can uncheck the 'Public Bot' option because the bot will anyway only work with one discord server.
Click on 'click to reveal' at 'Token' to show the bot token.
Copy this token and paste it into the config.json at 'token'.
I use vim but you can use any other editor too.
vim config.json
At linux you can pate with ctrl+shift+v the content of your clipboard in a terminal.
If you use Putty, you can paste with a simple rightclick.

The 'guild' and 'channel' in still missing in the config.
At 'guild', you have to insert the id of your discord guilde (server).
To get this you have to enable the developer mode in you discord settings at appearance.
After doing this you can easily copy the id of the guilde by clicking rightclick on the guild and then on 'Copy ID' to paste it in the config.
Do the same with the voice-channel in which the bot should work and insert this id at 'channel' in the config.

Your config should now look like this one:

Add the bot to your discord server
The bot must of course get added to your discord server.
To do this, copy following link and replace YOUR_CLIENT_ID_HERE with the bot's client id.
You'll find it at the top of your bot settings at 'App Details'.
https://discordapp.com/oauth2/authorize?&client_id=YOUR_CLIENT_ID_HERE&scope=bot&permissions=4194304
Open the modified link in your browser and choose the server you want to add this bot in. Keep 'Mute Members' checked and klick on 'Authorize'

Start the bot
To start the bot, run node with the 'discord_bot' directory as argument.
Because we are already in this directory, we use '.' as argument to refer to the current directory.
node .
If the bot is started successfully, it will look like this:
To keep the bot running after disconnect this ssh session, I use tmux[github.com].

Add the addon
The garrysmod addon have to be added to the gmod server.
You can do this by either easily add it to the server's collection:
http://steamproxy.com/sharedfiles/filedetails/?id=1350367721

Or you can move the 'gmod_addon' folder into the 'garrysmod/addons' directory and remane it suitable. (e.g. 'ttt_discord_bot')

Currently you have to use the second way because the addon in the steam workshop is an other version of the bot than on github.

Re/start the Server
And last but not least: Start the garrysmod server! (or restart it if it's still runnig)
Usage
As soon you joined the server, you'll get a message that says that you're not connected with discord yet.
You can get connected by writing '!discord YourDiscordTag' in the chat.
E.g.
!discord marceljs#4402
Mostly it's enough to use the code after the # (discriminator), if there is nobody else with your discriminator on the discord server.
As soon as you're connected, your discord-id will be assigned to your steam-id.
So whenever you connect to the server, you're still connected.

If you're in the configured voice channel, the game state is in progress, you're connected with discord and you die in TTT, the bot will mute you!
Feedback
If you have any questions to this guide, ask them in the comments.
I would be very happy about feedback and suggestions.
Please use this discussion for it.
If you make a tutorial about the installing or the usage of this bot on youtube and want me to link it in here, I'll gladly do it.
Other TTT must-haves ;)
Take a traitor's blood to turn an innocent into a traitor:
http://steamproxy.com/sharedfiles/filedetails/?id=1341745907
A traitoritem to fing yourself onto other players to kill them:
http://steamproxy.com/sharedfiles/filedetails/?id=1326870555
A passive traitoritem which causes the death of players who look at the weapons you'll drop after buying this.
http://steamproxy.com/sharedfiles/filedetails/?id=1330555436
6 則留言
Harambe 2023 年 1 月 13 日 下午 3:40 
Does this work with peer to peer servers?
Snoweuph 2021 年 6 月 27 日 上午 8:10 
II got the addon from the github. i setub the bot per heroku. I have one problem: on the github is something from server convars iin thee server.cfg file written, but they dont work
ch4rz3n 2021 年 1 月 18 日 下午 7:18 
Does this work with peer to peer servers? It would be so nice to have when playing with my friends
FAKO 2019 年 9 月 13 日 上午 8:26 
what SSH server I have to connect to ?
Michi 2019 年 7 月 8 日 下午 11:17 
Can someone help me with this?
Dodger 2018 年 8 月 28 日 下午 7:24 
Cheers mate, works a charm