Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

Commit

Permalink
Unify logging to Discord.NET
Browse files Browse the repository at this point in the history
  • Loading branch information
Headline committed Sep 7, 2018
1 parent b74fcbc commit b6911c0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 3 additions & 5 deletions IRC-Relay/Discord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public async Task SpawnBot()

public async Task OnDiscordConnected()
{
await session.Discord.Log(new LogMessage(LogSeverity.Critical, "DiscSpawn", "Discord bot initalized."));
await Discord.Log(new LogMessage(LogSeverity.Critical, "DiscSpawn", "Discord bot initalized."));
}

/* When we disconnect from discord (we got booted off), we'll remake */
Expand Down Expand Up @@ -197,7 +197,7 @@ await messageParam.Author.SendMessageAsync("To prevent you from having to re-typ
}
}

public Task Log(LogMessage msg)
public static Task Log(LogMessage msg)
{
return Task.Run(() => Console.WriteLine(msg.ToString()));
}
Expand All @@ -224,9 +224,7 @@ public static string UploadMarkDown(string input)
}

string key = (string)obj["key"];
string hasteUrl = "https://hastebin.com/" + key + ".cs";

return hasteUrl;
return "https://hastebin.com/" + key + ".cs";
}
}
public static string MentionToUsername(string input, SocketUserMessage message)
Expand Down
4 changes: 2 additions & 2 deletions IRC-Relay/IRC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ await Task.Run(() =>

private void OnConnected(object sender, EventArgs e)
{
session.Discord.Log(new LogMessage(LogSeverity.Critical, "IRCSpawn", "IRC bot initalized."));
Discord.Log(new LogMessage(LogSeverity.Critical, "IRCSpawn", "IRC bot initalized."));
}

private void OnError(object sender, ErrorEventArgs e)
Expand All @@ -96,7 +96,7 @@ private void OnError(object sender, ErrorEventArgs e)
* this Disconnect call */
new System.Threading.Thread(() => { session.Kill(); }).Start();

session.Discord.Log(new LogMessage(LogSeverity.Critical, "IRCOnError", e.ErrorMessage));
Discord.Log(new LogMessage(LogSeverity.Critical, "IRCOnError", e.ErrorMessage));
}

private void OnChannelMessage(object sender, IrcEventArgs e)
Expand Down
3 changes: 2 additions & 1 deletion IRC-Relay/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.IO;

using System.Threading.Tasks;
using Discord;
using JsonConfig;

namespace IRCRelay
Expand All @@ -39,7 +40,7 @@ private static async Task StartSessions(dynamic config)
do
{
await session.StartSession();
Console.WriteLine("Session failure... New session starting.");
await Discord.Log(new LogMessage(LogSeverity.Critical, "Main", "Session officially over. Starting new..."));
} while (!session.IsAlive);
}
}
Expand Down

0 comments on commit b6911c0

Please sign in to comment.