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

Commit

Permalink
Fixed crash caused by a channel not found
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioZumbi12 committed Nov 4, 2019
1 parent 14e510e commit bf944d3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions SEDiscordBridge/DiscordBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ public void SendChatMessage(string user, string msg)
{
msg = Plugin.Config.Format.Replace("{msg}", msg).Replace("{p}", user).Replace("{ts}", TimeZone.CurrentTimeZone.ToLocalTime(DateTime.Now).ToString());
}

botId = discord.SendMessageAsync(chann, msg.Replace("/n", "\n")).Result.Author.Id;
}
}
Expand All @@ -162,9 +161,9 @@ public void SendChatMessage(string user, string msg)
DiscordChannel chann = discord.GetChannelAsync(ulong.Parse(Plugin.Config.ChatChannelId)).Result;
botId = discord.SendMessageAsync(chann, e.ToString()).Result.Author.Id;
}
catch (Exception error)
catch (Exception ex)
{
SEDiscordBridgePlugin.Log.Warn(error.Message);
SEDiscordBridgePlugin.Log.Error($"SendChatMessage: {ex.Message}");
}
}
}
Expand All @@ -191,18 +190,18 @@ public void SendFacChatMessage(string user, string msg, string facName)
}
catch (Exception e)
{
SEDiscordBridgePlugin.Log.Warn(e.Message);
SEDiscordBridgePlugin.Log.Error($"SendFacChatMessage: {e.Message}");
}
}

public void SendStatusMessage(string user, string msg)
{
if (Ready && Plugin.Config.StatusChannelId.Length > 0)
{
DiscordChannel chann = discord.GetChannelAsync(ulong.Parse(Plugin.Config.StatusChannelId)).Result;

if (chann != null)
try
{
DiscordChannel chann = discord.GetChannelAsync(ulong.Parse(Plugin.Config.StatusChannelId)).Result;

if (user != null)
{
if (user.StartsWith("ID:"))
Expand All @@ -211,7 +210,10 @@ public void SendStatusMessage(string user, string msg)
msg = msg.Replace("{p}", user).Replace("{ts}", TimeZone.CurrentTimeZone.ToLocalTime(DateTime.Now).ToString());
}
botId = discord.SendMessageAsync(chann, msg.Replace("/n", "\n")).Result.Author.Id;
}
} catch(Exception e)
{
SEDiscordBridgePlugin.Log.Error($"SendStatusMessage: {e.Message}");
}
}
}

Expand Down

0 comments on commit bf944d3

Please sign in to comment.