Resource icon

Code RunUO 1.0 Discord Relay 1.0

Author
daroth
Downloads
0
Views
41
First release
Last update

Ratings

0.00 star(s) 0 ratings
No permission to download Join the discussion
Requirements
.NET 8 SDK
Hello all,

I'm the shard owner of Regisfall. We are still operating an old RunUO 1.0 codebase for the shard which sometimes requires a workaround or two for modern app integration. Today I built a "Discord Relay" app, which will read a .txt file and relay each line to a Discord Webhook. From there I made some basic code for RunUO to write to that .txt file for certain notifications like shard restarts/crashes/boots etc.

Here's how I went about building it:

Step 1 - Create new .net project
- Paste the following into cmd prompt to build your project:

C#:
Expand Collapse Copy
dotnet new console -n DiscordRelay
cd DiscordRelay

Step 2 - Set up project/webhook
- Replace Project.cs with the one attached to this thread
- Add your custom Webhook URL
- Set your .txt file location (default is C:\RunUO\DiscordQueue.txt)

Step 3 - Build .exe
- Open a cmd prompt in your project's folder and run this command to build the app:

Code:
Expand Collapse Copy
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true

We now have an app that will relay all lines of saved text in DiscordQueue.txt to your Discord webhook. The final step is to add the shard code to handle writing the text:

Step 4 - Add text writer to RunUO
The below chunk of code can be used for writing notifications to your text file

C#:
Expand Collapse Copy
using System;
using System.IO;

namespace Server
{
    public static class DiscordQueue
    {
        private static string QueueFile
        {
            get { return "DiscordQueue.txt"; }
        }

        public static void Write(string message)
        {
            try
            {
                using (StreamWriter sw = new StreamWriter(QueueFile, true))
                {
                    sw.WriteLine(DateTime.UtcNow.Ticks + "|" + message);
                }
            }
            catch
            {
            }
        }
    }
}


Example of how to use the Write function. This will send a notification every time the shard booted up:
C#:
Expand Collapse Copy
namespace Server.Misc
{
    public class DiscordStartup
    {
        public static void Initialize()
        {
            DiscordQueue.Write(":green_circle: Regisfall is back online.");
        }
    }
}

Donations

Total amount
$30.00
Goal
$500.00

Shards

Back