diff --git a/Dalamud.Injector/Program.cs b/Dalamud.Injector/Program.cs index ef1bca2f2..4c9d791ca 100644 --- a/Dalamud.Injector/Program.cs +++ b/Dalamud.Injector/Program.cs @@ -75,7 +75,7 @@ namespace Dalamud.Injector { Thread.Sleep(1000); -#if DEBUG +#if NO // Inject exception handler NativeInject(process); #endif diff --git a/Dalamud/DiscordBot/DiscordBotManager.cs b/Dalamud/DiscordBot/DiscordBotManager.cs index ff2edef0d..d6164afcb 100644 --- a/Dalamud/DiscordBot/DiscordBotManager.cs +++ b/Dalamud/DiscordBot/DiscordBotManager.cs @@ -188,27 +188,35 @@ namespace Dalamud.DiscordBot { string senderName; string senderWorld; - if (playerLink == null) { - // chat messages from the local player do not include a player link, and are just the raw name - // but we should still track other instances to know if this is ever an issue otherwise - - // Special case 2 - When the local player talks in party/alliance, the name comes through as raw text, - // but prefixed by their position number in the party (which for local player may always be 1) - if (sender.TextValue.EndsWith(this.dalamud.ClientState.LocalPlayer.Name)) + if (this.dalamud.ClientState.LocalPlayer != null) { + if (playerLink == null) { - senderName = this.dalamud.ClientState.LocalPlayer.Name; + // chat messages from the local player do not include a player link, and are just the raw name + // but we should still track other instances to know if this is ever an issue otherwise + + // Special case 2 - When the local player talks in party/alliance, the name comes through as raw text, + // but prefixed by their position number in the party (which for local player may always be 1) + if (sender.TextValue.EndsWith(this.dalamud.ClientState.LocalPlayer.Name)) + { + senderName = this.dalamud.ClientState.LocalPlayer.Name; + } + else + { + Log.Error("playerLink was null. Sender: {0}", BitConverter.ToString(sender.Encode())); + + senderName = wasOutgoingTell ? this.dalamud.ClientState.LocalPlayer.Name : sender.TextValue; + } + + senderWorld = this.dalamud.ClientState.LocalPlayer.HomeWorld.GameData.Name; } else { - Log.Error("playerLink was null. Sender: {0}", BitConverter.ToString(sender.Encode())); - - senderName = wasOutgoingTell ? this.dalamud.ClientState.LocalPlayer.Name : sender.TextValue; + senderName = wasOutgoingTell ? this.dalamud.ClientState.LocalPlayer.Name : playerLink.PlayerName; + senderWorld = playerLink.World.Name; } - - senderWorld = this.dalamud.ClientState.LocalPlayer.HomeWorld.GameData.Name; } else { - senderName = wasOutgoingTell ? this.dalamud.ClientState.LocalPlayer.Name : playerLink.PlayerName; - senderWorld = playerLink.World.Name; + senderName = string.Empty; + senderWorld = string.Empty; } var rawMessage = message.TextValue; diff --git a/Dalamud/Game/ChatHandlers.cs b/Dalamud/Game/ChatHandlers.cs index d3145240b..d7ee31a9e 100644 --- a/Dalamud/Game/ChatHandlers.cs +++ b/Dalamud/Game/ChatHandlers.cs @@ -170,7 +170,13 @@ namespace Dalamud.Game { var messageCopy = message; var senderCopy = sender; - Task.Run(() => this.dalamud.BotManager.ProcessChatMessage(type, messageCopy, senderCopy)); + Task.Run(async () => { + try { + await this.dalamud.BotManager.ProcessChatMessage(type, messageCopy, senderCopy); + } catch (Exception ex) { + Log.Error(ex, "Could not process discord bot message."); + } + }); // Handle all of this with SeString some day /*