Using a fresh Pub 58, the only other thing added to the server is VitaNexCore. I am getting the following errors after the editing discord.cfg and recompiling:


C#:
Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: Authentication failed. Check your token and try again. ---> DSharpPlus.Exceptions.UnauthorizedException: Unauthorized: 401
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DSharpPlus.DiscordClient.<InternalUpdateGatewayAsync>d__308.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DSharpPlus.DiscordClient.<InternalConnectAsync>d__237.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at DSharpPlus.DiscordClient.<ConnectAsync>d__234.MoveNext()
   --- End of inner exception stack trace ---
   at DSharpPlus.DiscordClient.<ConnectAsync>d__234.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Server.Custom.Skyfly.UODisc.DClient.Initialize() in C:\SERVUO\SERVUO 58-WIP\Scripts\0-0-1a Customs\Skyfly\UODisc\DClient.cs:line 153
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Server.ScriptCompiler.Invoke(String method) in C:\SERVUO\SERVUO 58-WIP\Server\ScriptCompiler.cs:line 112
   at Server.Core.Setup(String[] args) in C:\SERVUO\SERVUO 58-WIP\Server\Main.cs:line 819
   at ServUO.ServUO.Main(String[] args) in C:\SERVUO\SERVUO 58-WIP\Application\ServUO.cs:line 9
</code>
 
Using a fresh Pub 58, the only other thing added to the server is VitaNexCore. I am getting the following errors after the editing discord.cfg and recompiling:


C#:
Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: Authentication failed. Check your token and try again. ---> DSharpPlus.Exceptions.UnauthorizedException: Unauthorized: 401
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DSharpPlus.DiscordClient.<InternalUpdateGatewayAsync>d__308.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DSharpPlus.DiscordClient.<InternalConnectAsync>d__237.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at DSharpPlus.DiscordClient.<ConnectAsync>d__234.MoveNext()
   --- End of inner exception stack trace ---
   at DSharpPlus.DiscordClient.<ConnectAsync>d__234.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Server.Custom.Skyfly.UODisc.DClient.Initialize() in C:\SERVUO\SERVUO 58-WIP\Scripts\0-0-1a Customs\Skyfly\UODisc\DClient.cs:line 153
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Server.ScriptCompiler.Invoke(String method) in C:\SERVUO\SERVUO 58-WIP\Server\ScriptCompiler.cs:line 112
   at Server.Core.Setup(String[] args) in C:\SERVUO\SERVUO 58-WIP\Server\Main.cs:line 819
   at ServUO.ServUO.Main(String[] args) in C:\SERVUO\SERVUO 58-WIP\Application\ServUO.cs:line 9
</code>

Hey, it looks like your bot token is incorrect
System.Exception: Authentication failed. Check your token and try again. ---> DSharpPlus.Exceptions.UnauthorizedException: Unauthorized: 401

Make sure to use the token you get from here:
1703797214864.png
 
Thank you, for some reason I was thinking there was a token for dsharp.

Ive gotten it loaded, however it is not transmitting the in game general chat channel communication to the discord server general section. Any ideas? Discord has the bot, it said welcome to the channel. I'm unsure what im missing.
 
Thank you, for some reason I was thinking there was a token for dsharp.

Ive gotten it loaded, however it is not transmitting the in game general chat channel communication to the discord server general section. Any ideas? Discord has the bot, it said welcome to the channel. I'm unsure what im missing.
In order to log/send messages to discord take a look here: Chat synchronization and logging to discord
You want to insert that into the method that handles newly sent messages in your general chat
 
In order to log/send messages to discord take a look here: Chat synchronization and logging to discord
You want to insert that into the method that handles newly sent messages in your general chat
Here? inside ChatActionHandlers.cs at /Services/Chat:
C#:
 public static void ChannelMessage(ChatUser from, Channel channel, string param)
        public static void ChannelMessage(ChatUser from, Channel channel, string param)
        {
            if (from.NextMessage < Core.TickCount)
            {
                channel.SendMessage(57, from, from.GetColorCharacter() + from.Username, string.Format("{{{0}}} {1}", channel.Name, param)); // %1: %2
                ChatLogging.LogMessage(channel.Name, from.Username, param);

                from.NextMessage = Core.TickCount + ChatSystem.ChatDelay;
            }
        }

        //BEGIN DISCUO EDITS
        public void Log(string msg, LogLevel level = LogLevel.Trace, bool usePrefix = true)
        {
            LoggerFactory.GetLogger(ChannelId).Log($"{player.Name}: {message}", LogLevel.Info, false);
        }
        //END DISCUO EDITS
 }

It's not working, but its not throwing errors either. I must not have the right file. I am out of ideas as Ive looked at logging and the Services\Chat folder.
 
Last edited:
Here? inside ChatActionHandlers.cs at /Services/Chat:
C#:
 public static void ChannelMessage(ChatUser from, Channel channel, string param)
        public static void ChannelMessage(ChatUser from, Channel channel, string param)
        {
            if (from.NextMessage < Core.TickCount)
            {
                channel.SendMessage(57, from, from.GetColorCharacter() + from.Username, string.Format("{{{0}}} {1}", channel.Name, param)); // %1: %2
                ChatLogging.LogMessage(channel.Name, from.Username, param);

                from.NextMessage = Core.TickCount + ChatSystem.ChatDelay;
            }
        }

        //BEGIN DISCUO EDITS
        public void Log(string msg, LogLevel level = LogLevel.Trace, bool usePrefix = true)
        {
            LoggerFactory.GetLogger(ChannelId).Log($"{player.Name}: {message}", LogLevel.Info, false);
        }
        //END DISCUO EDITS
 }

It's not working, but its not throwing errors either. I must not have the right file. I am out of ideas as Ive looked at logging and the Services\Chat folder.

You created a method called "Log" but i can't see where you are calling that method.
Think about what the code you sent does line by line.

First you have a static method called ChannelMessage that accepts a user, channel and param.
When this method gets called, it checks if you can send a new message (from.NextMessage).

Now look inside that if statement, what are you seeing there?
It's calling channel.SendMessage, it calls ChatLogging.LogMessage and sets the time when you can send your next message.

Next look at the 2. method in your post called "Log".
Inside this method you are calling the LoggerFactory.GetLogger(...).Log
Now look closely, you accept a "string msg" in your method but inside the string you send you use "message"?
Same for the player.Name, where is player coming from?
For the ChannelId i assume you have field/property (variable) in the class that contains the Id?

---

the only thing you need is this line
LoggerFactory.GetLogger(ChannelId).Log($"{player.Name}: {message}", LogLevel.Info, false);

Place that inside the if and change the things that don't make any sense, like having "player.Name" when it's actually "from.Username"
if (from.NextMessage < Core.TickCount)
{
channel.SendMessage(57, from, from.GetColorCharacter() + from.Username, string.Format("{{{0}}} {1}", channel.Name, param)); // %1: %2
ChatLogging.LogMessage(channel.Name, from.Username, param);

from.NextMessage = Core.TickCount + ChatSystem.ChatDelay;
}

You don't need this line at all
public void Log(string msg, LogLevel level = LogLevel.Trace, bool usePrefix = true)
This is simply the signature of the method you are calling here
Log($"{player.Name}: {message}", LogLevel.Info, false);

I saw your error yesterday but haven't had time to reply, you should get visual studio, those errors you had a simple reference errors due to missing "using" statements at the top of the file. With visual studio you can just click on those errors and let it fix automatically for you

Don't just copy & paste code especially if it's example code, look at what stuff is doing and try to understand it. I hope this helps understanding it all more. Should you still have trouble/questions feel free to contact me on discord directly where i can respond most likly faster (I'm the one called ?????? on the ServUO discord)
 
You created a method called "Log" but i can't see where you are calling that method.
Think about what the code you sent does line by line.

First you have a static method called ChannelMessage that accepts a user, channel and param.
When this method gets called, it checks if you can send a new message (from.NextMessage).

Now look inside that if statement, what are you seeing there?
It's calling channel.SendMessage, it calls ChatLogging.LogMessage and sets the time when you can send your next message.

Next look at the 2. method in your post called "Log".
Inside this method you are calling the LoggerFactory.GetLogger(...).Log
Now look closely, you accept a "string msg" in your method but inside the string you send you use "message"?
Same for the player.Name, where is player coming from?
For the ChannelId i assume you have field/property (variable) in the class that contains the Id?

---

the only thing you need is this line


Place that inside the if and change the things that don't make any sense, like having "player.Name" when it's actually "from.Username"


You don't need this line at all

This is simply the signature of the method you are calling here


I saw your error yesterday but haven't had time to reply, you should get visual studio, those errors you had a simple reference errors due to missing "using" statements at the top of the file. With visual studio you can just click on those errors and let it fix automatically for you

Don't just copy & paste code especially if it's example code, look at what stuff is doing and try to understand it. I hope this helps understanding it all more. Should you still have trouble/questions feel free to contact me on discord directly where i can respond most likly faster (I'm the one called ?????? on the ServUO discord)
Man I REALLY appreciate you taking the time to walk me through/guiding me as to what is happening instead of just saying, "try this"'
It really helps to learn what is going on, as I am very new to all this. I mostly made maps in the past.
 
hmmm... bro... im stuck at trying to make a URI redirect link... they made it impossible to add your own bot now

Found this site... discord.js Guide might figure it out now...
 
Last edited:
hmmm... bro... im stuck at trying to make a URI redirect link... they made it impossible to add your own bot now

Found this site... discord.js Guide might figure it out now...
you don't need a redirect uri to setup the bot.
follow the tutorial on here Installation

under point 8 you can read the following:
 
I'm trying to upgrade to .NET8 and UODisc is not throwing some errors. I've had to upgrade to the nuget DSharpPlus.
1722926204745.png
And this area. Each of these throws a slightly different error.
1722926324507.png

Any chance for an update to this?
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back