mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 20:33:40 +01:00
fix: catch some discord bot errors
This commit is contained in:
parent
f92a37fbf9
commit
64f07a8c02
3 changed files with 31 additions and 17 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue