Terracord is a Discord ↔ Terraria bridge plugin for TShock. The plugin enables the bi-directional flow of messages between a Discord text channel and a TShock server. This project is inspired by DiscordSRV which is a Discord ↔ Minecraft chat relay plugin for PaperMC and Spigot.
Terracord is written in C# and is licensed under the terms of the GPLv3. This project makes use of Discord.Net and the Terraria API.
A DLL built from the latest source code can be found on AppVeyor.
Installation and Configuration
-
Follow the instructions here to create a bot and invite it to your server. Make note of the bot token as you'll need it later.
-
Give the bot the following server-wide permissions:
Permissions
Permission Required Effect Scope Read Text Channels & See Voice Channels/Read Messages ✔ Yes Allows the bot to view channels and messages within a text channel Server/Channel Send Messages ✔ Yes Allows the bot to send messages in a text channel Server/Channel Read Message History ✔ Yes Allows the bot to see previous messages in a text channel Server/Channel Change Nickname ❌ No Allows the bot to change its own nickname when the configuration is reloaded Server Embed Links ❌ No Allows the bot to embed links within a text channel Server/Channel Manage Channel(s) ❌ No Allows the bot to dynamically update the channel topic with info about the Terraria server Server/Channel - Server scope means the permission is added to the bot's role in Server Settings⇒Roles.
- Channel scope means the permission is added to the bot (or its role) directly in the desired text channel using Edit Channel⇒Permissions.
- Server/Channel scope means the permission can either be a Server or Channel permission.
-
Copy the ID of the desired text channel following the instructions here. The owner ID can also be acquired using the same instructions. Make note of both IDs.
-
Copy
Terracord.dll
and its dependencies into your TShockServerPlugins
directory. The dependencies are the following:Discord.Net.Core.dll
,Discord.Net.Rest.dll
,Discord.Net.WebSocket.dll
,Microsoft.Bcl.AsyncInterfaces.dll
,Newtonsoft.Json.dll
,System.Collections.Immutable.dll
,System.Interactive.Async.dll
, andSystem.Threading.Tasks.Extensions.dll
. These files should be contained in any release archive.Ensure that the version of
Newtonsoft.Json.dll
copied to theServerPlugins
directory is ≥ 11.0.2. This is a required dependency of Discord.Net. The instance of this DLL included with TShock 4.4.0 is older (10.0.3) and using it results in the inability to establish a connection to the Discord service. -
Edit
terracord.xml
to set your bot token, Discord channel ID, and owner ID. The Discord Bot section demonstrates how to obtain these items.terracord.xml
should be saved to thetshock > Terracord
directory. Other settings in this configuration file may also be changed to your liking. -
Restart your TShock server to load the plugin. For review or troubleshooting purposes,
terracord.log
can be found in thetshock > Terracord
directory.
net46
or net461
has been confirmed to work with Mono version 6.8 however.
Discord Commands
Command | Description |
---|---|
help |
Display command list |
playerlist |
Display online players |
serverinfo |
Display server details |
setgame [status] |
Set Discord bot game/playing status |
uptime |
Display plugin uptime |
If a command is not in the above list and the issuing Discord user has one of the admin roles or is the bot owner (both configured
in terracord.xml
), the command will be forwarded onto the Terraria server. The server and any relevant plugins will handle the
command at this point and provide output if applicable.
Building
-
Download and install Visual Studio if you do not have the software. The community edition is free and contains the essentials to build Terracord. In particular, you want the ".NET desktop development" workload. The "NuGet package manager" is also required to pull in the Discord.Net dependencies. Other individual components such as debuggers, profilers, "Git for Windows", and the "GitHub extension for Visual Studio" may be useful.
-
Obtain a copy of the Terracord source code if you have not already. This can be performed with
git clone https://github.com/FragLand/terracord.git
. You may alternatively download a zip archive of the source and extract the contents to an arbitrary location. -
Download the latest TShock release.
-
Create a directory named
lib
at the same path whereTerracord.sln
resides. -
Extract
OTAPI.dll
,TerrariaServer.exe
, andTShockAPI.dll
from the TShock zip archive and then place these 3 files under thelib
directory you recently created during step 4. -
Open
Terracord.sln
using Visual Studio. -
NuGet should automatically download Discord.Net and its dependencies based on
Terracord.csproj
. If not, you can manually installDiscord.Net.Core
andDiscord.Net.WebSocket
via NuGet. You may also attempt to right-click the solution in the "Solution Explorer" of Visual Studio and then left-click "Restore NuGet Packages". -
Use Build⇒Build Solution or Ctrl+Shift+b to build Terracord.
-
If all goes well, you should have a shiny new
Terracord.dll
at the path referenced in the build output. Enjoy!
-
Install .NET Core SDK. .NET Core SDK 3.1.100 is known to successfully build Terracord. You can also configure various Linux package managers to install .NET core. This has the added benefit of being able to easily update the software.
-
Obtain a copy of the Terracord source code:
git clone https://github.com/FragLand/terracord.git
Or:
wget https://github.com/FragLand/terracord/archive/master.zip && unzip master.zip
-
Download and extract the latest TShock release:
wget https://github.com/Pryaxis/TShock/releases/download/vx.x.x/tshock_x.x.x.zip && unzip tshock_x.x.x.zip
-
Create a directory named
lib
at the same path whereTerracord.sln
resides:mkdir terracord/lib
-
Copy
OTAPI.dll
,TerrariaServer.exe
, andTShockAPI.dll
tolib
:cp OTAPI.dll TerrariaServer.exe ServerPlugins/TShockAPI.dll terracord/lib
-
Install dependencies:
cd terracord
dotnet restore
-
Begin build:
dotnet build -c <Debug|Release>
-
You should now have a
Terracord.dll
.
Terracord.dll
with Mono may not work considering that Discord.Net does not
support Mono. Therefore, the following steps should be considered experimental. Building a Terracord DLL that targets
net46
or net461
has been confirmed to work with Mono version 6.8.
-
Install Mono and NuGet. Under Debian, this can be achieved via:
apt-get install mono-complete nuget
-
Obtain a copy of the Terracord source code:
git clone https://github.com/FragLand/terracord.git
Or:
wget https://github.com/FragLand/terracord/archive/master.zip && unzip master.zip
-
Download and extract the latest TShock release:
wget https://github.com/Pryaxis/TShock/releases/download/vx.x.x/tshock_x.x.x.zip && unzip tshock_x.x.x.zip
-
Create a directory named
lib
at the same path whereTerracord.sln
resides:mkdir terracord/lib
-
Copy
OTAPI.dll
,TerrariaServer.exe
, andTShockAPI.dll
tolib
:cp OTAPI.dll TerrariaServer.exe ServerPlugins/TShockAPI.dll terracord/lib
-
Install dependencies:
cd terracord
nuget restore Terracord.sln
-
Begin build:
xbuild /p:Configuration=<Debug|Release> Terracord.sln
Or:
msbuild /p:Configuration=<Debug|Release> Terracord.sln
-
With luck, a wild
Terracord.dll
will appear.
@Dids has contributed a Docker image of TShock bundled with Terracord at: https://github.com/Didstopia/terraria-server
Feel free to submit an issue if you require assistance or would like to make a feature request. Any contributions such as plugin testing and pull requests are appreciated. Please see the fork and pull guide for direction if you are not certain how to submit a pull request.