Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Configuration

Lloyd Dilley edited this page Feb 24, 2021 · 5 revisions

What is XML?

XML is the eXtensible Markup Language. It is an established standard for defining document format. It is commonly used to represent data.

Why Use XML for Terracord?

The first choice would have been to use YAML for the configuration file. However, C# lacks native support for parsing YAML documents. One of the initial design goals of this project was to reduce reliance on 3rd-party libraries. C# also has native support for parsing XML documents. XML was used in favor of JSON due to JSON's syntax being potentially more prone to errors when end users are expected to maintain the file (fussy placement and use of {}, [], and commas).

Breakdown of terracord.xml

This is the header of an XML file. It is required for the XML parser. It defines the version of XML along with the character encoding used in the file.

<?xml version="1.0" encoding="UTF-8" ?>

Anything between <!-- and --> is considered a comment in XML. This particular line denotes the version of Terracord that this configuration file is compatible with.

<!-- Terracord configuration version 1.2.2 -->

This is the opening group section aptly named configuration. An open element must also be closed later much like in HTML.

<configuration>

A bot token is unique and identifies your bot to Discord's authentication service. You can use this process to create a Discord bot and generate a token.

<!-- Discord bot token -->
<bot token="ABC" />

A unique channel ID is associated with any text channel you create within a Discord server. You can acquire the channel ID of a text channel using this process.

<!-- Discord channel ID -->
<channel id="123" />

Setting the owner ID enables the Discord bot to know who administers it. This will allow you to submit remote TShock commands. You can obtain a Discord user ID using a process similar to retrieving a Discord text channel ID.

<!-- Discord bot owner ID -->
<owner id="123" />

The bot prefix comes before Discord text channel commands (for example: !help). The prefix can consist of one or more characters.

  <!-- Bot command prefix -->
  <command prefix="!" />

This option value determines whether (true) or not (false) commands sent from Discord will be visible to Terraria players.

<!-- Relay bot commands from Discord to players -->
<relay commands="true" />

Should Terracord accept TShock commands from Discord? Set this option to true if so or false otherwise.

<!-- Toggle execution of TShock commands submitted remotely by Discord bot owner -->
<remote commands="true" />

This option value can contain 0 or more space-separated Discord roles. Membership of any of these roles will permit the Discord user to send commands from Discord to TShock.

<!-- List of space-separated Discord roles authorized to execute TShock commands remotely -->
<authorized roles="Administrators Moderators" />

This option sets the Discord bot status. For example, the bot within Discord would show a status of "Playing Terraria".

<!-- Discord bot game for "playing" status -->
<game status="Terraria" />

This option defines the frequency in seconds that the Discord bot should update the Discord text channel topic with the TShock server status. This includes the number of players online, the maximum number of allowed players, the server uptime, and the last topic update time. An interval value of 300 (seconds) would be 5 minutes for example. The bot will set the offline value as the text channel topic when the relay shuts down.

⚠️ Do not set this value too low or you may be rate limited.

<!-- Topic update interval in seconds and topic to set when relay is offline -->
<topic interval="300" offline="Relay offline" />

This option defines the color of Terraria chat messages sent from Discord. The data is in RGB (red, green, and blue) format and the possible values range from 0 to 255.

  <!-- Terraria broadcast color in RGB -->
  <color red="255" green="215" blue="0" />

These options control whether or not Terraria game broadcasts, Terraria player chat, and Terraria world saves are displayed in the Discord text channel.

<!-- Toggle broadcasts, chat, and world saves displayed in Discord -->
<silence broadcasts="false" chat="false" saves="false" />

Setting this option to true will send a message to the Discord text channel when the relay reconnects to Discord after losing connection.

<!-- Notify Discord channel of relay availability after restoring the connection -->
<announce reconnect="true" />

This option determines how the notification message sent to Discord appears when the relay comes online. ** indicates the start and end of text that should be marked as bold in Discord. :white_check_mark: is the name of an emoji in Discord. Custom Discord server emojis may be used by specifying the following

<!-- Message sent to Discord text channel when the relay becomes available -->
<available text="**:white_check_mark: Relay online.**" />

This option determines how the notification message sent to Discord appears when the relay goes offline. ** indicates the start and end of text that should be marked as bold in Discord. :octagonal_sign: is the name of an emoji in Discord. Custom Discord server emojis may be used by specifying the following format: <:custom_name:813473461247362513>

<!-- Message sent to Discord text channel when the relay is shutting down -->
<unavailable text="**:octagonal_sign: Relay offline.**" />

This option determines how Terraria player join events appear in Discord. $player_name is a placeholder that gets expanded as the Terraria player who joined the game. ** indicates the start and end of text that should be marked as bold in Discord. :green_circle: is the name of an emoji in Discord. Custom Discord server emojis may be used by specifying the following format: <:custom_name:813473461247362513>

<!-- Message sent to Discord text channel when a player joins the game -->
<join text="**:green_circle: $player_name has joined the server.**" />

This option determines how Terraria player leave events appear in Discord. $player_name is a placeholder that gets expanded as the Terraria player who left the game. ** indicates the start and end of text that should be marked as bold in Discord. :red_circle: is the name of an emoji in Discord. Custom Discord server emojis may be used by specifying the following format: <:custom_name:813473461247362513>

<!-- Message sent to Discord text channel when a player leaves the game -->
<leave text="**:red_circle: $player_name has left the server.**" />

This option determines how Terraria broadcast messages appear to Discord users. $message is a placeholder that gets expanded as the broadcast message from Terraria. ** indicates the start and end of text that should be marked as bold in Discord. :mega: is the name of the megaphone emoji in Discord. Custom Discord server emojis may be used by specifying the following format: <:custom_name:813473461247362513>

<!-- Message sent to Discord text channel when a broadcast is sent from the game -->
<broadcast text="**:mega: Broadcast:** $message" />

This option determines how Terraria chat messages appear to Discord users. $player_name is a placeholder that gets expanded as the Terraria player who sent the message. $message is the chat message from Terraria. &lt; and &gt; are required here to escape the < (less than) and > (greater than) characters within XML. ** indicates the start and end of text that should be marked as bold in Discord.

<!-- Message sent to Discord text channel when a player chats in the game -->
<player text="**&lt;$player_name&gt;** $message" />

This option determines how Discord messages appear to Terraria players. $user_name is a placeholder that gets expanded as the Discord user who sent the message. $message is the message from Discord. &lt; and &gt; are required here to escape the < (less than) and > (greater than) characters within XML.

<!-- Message sent to game when a user chats in the Discord text channel -->
<chat text="&lt;$user_name@Discord&gt; $message" />

If this option is set to true, Discord messages are not displayed to Terraria players.

<!-- Toggle Discord chat displayed in game -->
<ignore chat="false" />

All chat messages from the Discord text channel and Terraria players are logged if this option is set to true.

<!-- Log all chat messages -->
<log chat="true" />

Setting a numeric value for this option causes messages from Discord to be truncated after the number of characters in the message exceeds this value. A value of 0 (zero) means that Terracord will not truncate messages.

<!-- Maximum length allowed in game for received Discord messages (0 = unlimited) -->
<message length="0" />

Enabling debug mode increases the quantity of log information.

<!-- Debug mode -->
<debug mode="false" />

This option sets the locale which pertains to regional date and number formatting. See the table of locales for supported values.

<!-- Locale -->
<locale string="en-US" />

This option sets the timestamp format used for logging. See here for a list of formatting specifiers.

<!-- Timestamp format -->
<timestamp format="MM/dd/yyyy HH:mm:ss zzz" />

This option determines whether (true) or not (false) TShock exits if an exception is encountered in Terracord.

<!-- Terminate TShock when an error is encountered -->
<exception abort="false" />

This closes the configuration element and marks the end of the file.

</configuration>
Clone this wiki locally