Change Logging to LoggingFacade
This commit is contained in:
parent
f8b37391cb
commit
754f53c404
@ -1,5 +1,4 @@
|
|||||||
using NLog;
|
using System;
|
||||||
using System;
|
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
@ -8,13 +7,11 @@ using ChaosBot.Discord.Services;
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord
|
namespace ChaosBot.Discord
|
||||||
{
|
{
|
||||||
public class DiscordConnect
|
public class DiscordConnect
|
||||||
{
|
{
|
||||||
public static DiscordSocketClient _client = null;
|
public static DiscordSocketClient _client = null;
|
||||||
private static ILogger _logger = Program.Logger;
|
|
||||||
|
|
||||||
public static async Task StartUp()
|
public static async Task StartUp()
|
||||||
{
|
{
|
||||||
@ -45,13 +42,13 @@ namespace ChaosBot.Discord
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error($"DiscordConnect.StartUp: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Task ReadyAsync()
|
private static Task ReadyAsync()
|
||||||
{
|
{
|
||||||
_logger.Info($"Connected as -> [{_client.CurrentUser}] :)");
|
LoggingFacade.Info($"Connected as -> [{_client.CurrentUser}] :)");
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +66,7 @@ namespace ChaosBot.Discord
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error($"DiscordConnect.ConfigureServices: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return csInfo;
|
return csInfo;
|
||||||
@ -82,31 +79,31 @@ namespace ChaosBot.Discord
|
|||||||
switch (msg.Severity)
|
switch (msg.Severity)
|
||||||
{
|
{
|
||||||
case LogSeverity.Critical:
|
case LogSeverity.Critical:
|
||||||
_logger.Fatal(msg.Message);
|
LoggingFacade.Fatal(msg.Message);
|
||||||
break;
|
break;
|
||||||
case LogSeverity.Debug:
|
case LogSeverity.Debug:
|
||||||
_logger.Debug(msg.Message);
|
LoggingFacade.Debug(msg.Message);
|
||||||
break;
|
break;
|
||||||
case LogSeverity.Error:
|
case LogSeverity.Error:
|
||||||
_logger.Error(msg.Message);
|
LoggingFacade.Error(msg.Message);
|
||||||
break;
|
break;
|
||||||
case LogSeverity.Info:
|
case LogSeverity.Info:
|
||||||
_logger.Info(msg.Message);
|
LoggingFacade.Info(msg.Message);
|
||||||
break;
|
break;
|
||||||
case LogSeverity.Warning:
|
case LogSeverity.Warning:
|
||||||
_logger.Warn(msg.Message);
|
LoggingFacade.Warn(msg.Message);
|
||||||
break;
|
break;
|
||||||
case LogSeverity.Verbose:
|
case LogSeverity.Verbose:
|
||||||
_logger.Trace(msg.Message);
|
LoggingFacade.Trace(msg.Message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_logger.Trace(msg.Message);
|
LoggingFacade.Trace(msg.Message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error($"DiscordConnect.Log: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|||||||
@ -5,25 +5,22 @@ using System.Threading.Tasks;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using ChaosBot.Discord.PreConditions;
|
using ChaosBot.Discord.PreConditions;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.Modules.Admin
|
namespace ChaosBot.Discord.Modules.Admin
|
||||||
{
|
{
|
||||||
public class Clear : ModuleBase
|
public class Clear : ModuleBase
|
||||||
{
|
{
|
||||||
private static readonly ILogger _logger = Program.Logger;
|
|
||||||
|
|
||||||
[Command("clear")]
|
[Command("clear")]
|
||||||
[Alias("purge")]
|
[Alias("purge")]
|
||||||
[CheckCommandPerm("Admin")]
|
[CheckCommandPerm("Admin")]
|
||||||
public async Task ClearCommand(int msgtoDelete = 1)
|
public async Task ClearCommand(int msgToDelete = 1)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IEnumerable<IMessage> messages = await Context.Channel.GetMessagesAsync(msgtoDelete + 1).FlattenAsync();
|
IEnumerable<IMessage> messages = await Context.Channel.GetMessagesAsync(msgToDelete + 1).FlattenAsync();
|
||||||
await ((ITextChannel) Context.Channel).DeleteMessagesAsync(messages);
|
await ((ITextChannel) Context.Channel).DeleteMessagesAsync(messages);
|
||||||
const int delay = 3000;
|
const int delay = 3000;
|
||||||
IUserMessage m = await ReplyAsync($"{Context.User.Mention}, {msgtoDelete} messages deleted.");
|
IUserMessage m = await ReplyAsync($"{Context.User.Mention}, {msgToDelete} messages deleted.");
|
||||||
await Task.Delay(delay);
|
await Task.Delay(delay);
|
||||||
await m.DeleteAsync();
|
await m.DeleteAsync();
|
||||||
}
|
}
|
||||||
@ -31,7 +28,8 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
{
|
{
|
||||||
if(ex.Message.Contains("Messages must be younger than two weeks old."))
|
if(ex.Message.Contains("Messages must be younger than two weeks old."))
|
||||||
await ReplyAsync($"{Context.User.Mention}, You cannot delete messages older then 2 weeks old.");
|
await ReplyAsync($"{Context.User.Mention}, You cannot delete messages older then 2 weeks old.");
|
||||||
_logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
||||||
|
LoggingFacade.Debug($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.\n{ex.StackTrace}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using ChaosBot.Discord.PreConditions;
|
using ChaosBot.Discord.PreConditions;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
@ -11,14 +9,11 @@ using ChaosBot.Services;
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.Modules.Admin
|
namespace ChaosBot.Discord.Modules.Admin
|
||||||
{
|
{
|
||||||
public class Config : ModuleBase
|
public class Config : ModuleBase
|
||||||
{
|
{
|
||||||
private static readonly ILogger _logger = Program.Logger;
|
|
||||||
|
|
||||||
[Command("config")]
|
[Command("config")]
|
||||||
[CheckCommandPerm("Admin")]
|
[CheckCommandPerm("Admin")]
|
||||||
public async Task ConfigCommand(string cmd = "help", string key = null, string value = null)
|
public async Task ConfigCommand(string cmd = "help", string key = null, string value = null)
|
||||||
@ -38,8 +33,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,8 +69,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,8 +104,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,8 +144,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,8 +182,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,22 +6,16 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Antlr4.Runtime.Misc;
|
|
||||||
using ChaosBot.Discord.PreConditions;
|
using ChaosBot.Discord.PreConditions;
|
||||||
using ChaosBot.Lodestone;
|
using ChaosBot.Lodestone;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.Modules.Admin
|
namespace ChaosBot.Discord.Modules.Admin
|
||||||
{
|
{
|
||||||
public class RankCheck : ModuleBase
|
public class RankCheck : ModuleBase
|
||||||
{
|
{
|
||||||
private static readonly ILogger _logger = Program.Logger;
|
|
||||||
|
|
||||||
[Command("rankCheck")]
|
[Command("rankCheck")]
|
||||||
[Alias("rc")]
|
[Alias("rc")]
|
||||||
[CheckCommandPerm("Admin")]
|
[CheckCommandPerm("Admin")]
|
||||||
@ -127,7 +121,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,8 +143,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return JsonConvert.DeserializeObject<List<LodestoneRank>>(JsonConvert.SerializeObject(JsonConvert.DeserializeObject<LodestoneRankApi>(response).Data));
|
return JsonConvert.DeserializeObject<List<LodestoneRank>>(JsonConvert.SerializeObject(JsonConvert.DeserializeObject<LodestoneRankApi>(response).Data));
|
||||||
|
|||||||
@ -3,21 +3,17 @@ using Discord;
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using ChaosBot.Discord.PreConditions;
|
using ChaosBot.Discord.PreConditions;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using ChaosBot.Repositories;
|
using ChaosBot.Repositories;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.Modules.Admin
|
namespace ChaosBot.Discord.Modules.Admin
|
||||||
{
|
{
|
||||||
public class Role : ModuleBase
|
public class Role : ModuleBase
|
||||||
{
|
{
|
||||||
private static readonly ILogger Logger = Program.Logger;
|
|
||||||
|
|
||||||
[Command("role")]
|
[Command("role")]
|
||||||
[Alias("role help", "role info")]
|
[Alias("role help", "role info")]
|
||||||
[CheckCommandPerm("Admin")]
|
[CheckCommandPerm("Admin")]
|
||||||
@ -53,7 +49,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,8 +114,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await ReplyAsync($"Something went wrong trying to process {m.Value}: {ex.Message}");
|
await ReplyAsync($"Something went wrong trying to process {m.Value}: {ex.Message}");
|
||||||
Logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +123,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +146,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
|
|
||||||
foreach (Match m in Regex.Matches(input, pattern))
|
foreach (Match m in Regex.Matches(input, pattern))
|
||||||
{
|
{
|
||||||
Logger.Info(m.Value);
|
LoggingFacade.Info(m.Value);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IEmote emote;
|
IEmote emote;
|
||||||
@ -188,8 +183,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await ReplyAsync($"Something went wrong trying to process {m.Value}: {ex.Message}");
|
await ReplyAsync($"Something went wrong trying to process {m.Value}: {ex.Message}");
|
||||||
Logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +192,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ChaosBot.Discord.PreConditions;
|
using ChaosBot.Discord.PreConditions;
|
||||||
@ -7,14 +6,11 @@ using ChaosBot.Repositories;
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.Modules.User
|
namespace ChaosBot.Discord.Modules.User
|
||||||
{
|
{
|
||||||
public class Info : ModuleBase
|
public class Info : ModuleBase
|
||||||
{
|
{
|
||||||
private static readonly ILogger Logger = Program.Logger;
|
|
||||||
|
|
||||||
[Command("info")]
|
[Command("info")]
|
||||||
[Alias("version")]
|
[Alias("version")]
|
||||||
[CheckCommandPerm("User")]
|
[CheckCommandPerm("User")]
|
||||||
@ -41,8 +37,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,22 +1,16 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ChaosBot.Discord.PreConditions;
|
using ChaosBot.Discord.PreConditions;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using ChaosBot.Repositories;
|
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.Modules.User
|
namespace ChaosBot.Discord.Modules.User
|
||||||
{
|
{
|
||||||
public class Level : ModuleBase
|
public class Level : ModuleBase
|
||||||
{
|
{
|
||||||
private static readonly ILogger Logger = Program.Logger;
|
|
||||||
|
|
||||||
[Command("level")]
|
[Command("level")]
|
||||||
[Alias("xp", "exp", "experience", "lvl")]
|
[Alias("xp", "exp", "experience", "lvl")]
|
||||||
[CheckCommandPerm("User")]
|
[CheckCommandPerm("User")]
|
||||||
@ -71,8 +65,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,23 +5,17 @@ using Discord.Commands;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using ChaosBot.Discord.PreConditions;
|
using ChaosBot.Discord.PreConditions;
|
||||||
using ChaosBot.Lodestone;
|
using ChaosBot.Lodestone;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using ChaosBot.Repositories;
|
using ChaosBot.Repositories;
|
||||||
using ChaosBot.Services;
|
using ChaosBot.Services;
|
||||||
using Discord.Net;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.Modules.User
|
namespace ChaosBot.Discord.Modules.User
|
||||||
{
|
{
|
||||||
public class Lodestone : ModuleBase
|
public class Lodestone : ModuleBase
|
||||||
{
|
{
|
||||||
private static readonly ILogger _logger = Program.Logger;
|
|
||||||
|
|
||||||
[Command("lodestone")]
|
[Command("lodestone")]
|
||||||
[Alias("ls")]
|
[Alias("ls")]
|
||||||
[CheckCommandPerm("User")]
|
[CheckCommandPerm("User")]
|
||||||
@ -69,8 +63,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +108,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +135,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +232,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +259,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,27 +1,20 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ChaosBot.Discord.PreConditions;
|
using ChaosBot.Discord.PreConditions;
|
||||||
using ChaosBot.Migrations;
|
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NLog;
|
|
||||||
using ChaosBot.Repositories;
|
using ChaosBot.Repositories;
|
||||||
using ChaosBot.Services;
|
using ChaosBot.Services;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.Modules.User
|
namespace ChaosBot.Discord.Modules.User
|
||||||
{
|
{
|
||||||
public class Points : ModuleBase
|
public class Points : ModuleBase
|
||||||
{
|
{
|
||||||
private static ILogger _logger = Program.Logger;
|
|
||||||
|
|
||||||
[Command("points")]
|
[Command("points")]
|
||||||
[CheckCommandPerm("User")]
|
[CheckCommandPerm("User")]
|
||||||
public async Task PointsCommand(string cmd = "total", SocketUser user = null, ulong Amount = 0)
|
public async Task PointsCommand(string cmd = "total", SocketUser user = null, ulong Amount = 0)
|
||||||
@ -73,8 +66,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,8 +102,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,8 +123,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await ReplyAsync($"{Context.User.Mention}, you have {cur} points.", false);
|
await ReplyAsync($"{Context.User.Mention}, you have {cur} points.", false);
|
||||||
@ -175,8 +165,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await ReplyAsync(
|
await ReplyAsync(
|
||||||
@ -283,8 +272,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,8 +294,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await ReplyAsync(
|
await ReplyAsync(
|
||||||
|
|||||||
@ -1,13 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ChaosBot.Discord.PreConditions;
|
using ChaosBot.Discord.PreConditions;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NLog;
|
|
||||||
using ChaosBot.Repositories;
|
using ChaosBot.Repositories;
|
||||||
using ChaosBot.Services;
|
using ChaosBot.Services;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
@ -16,8 +14,6 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
{
|
{
|
||||||
public class RaffleCmd : ModuleBase
|
public class RaffleCmd : ModuleBase
|
||||||
{
|
{
|
||||||
private static ILogger _logger = Program.Logger;
|
|
||||||
|
|
||||||
[Command("raffle")]
|
[Command("raffle")]
|
||||||
[CheckCommandPerm("User")]
|
[CheckCommandPerm("User")]
|
||||||
public async Task RaffleCommand(string cmd = "total", SocketUser user = null, int Amount = 0)
|
public async Task RaffleCommand(string cmd = "total", SocketUser user = null, int Amount = 0)
|
||||||
@ -79,8 +75,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,8 +115,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +136,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await ReplyAsync($"{Context.User.Mention}, you have {cur} raffle tickets.", false);
|
await ReplyAsync($"{Context.User.Mention}, you have {cur} raffle tickets.", false);
|
||||||
@ -185,8 +178,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,8 +213,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await ReplyAsync(
|
await ReplyAsync(
|
||||||
@ -250,16 +241,15 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
await dbContext.SaveChangesAsync();
|
await dbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await ReplyAsync(
|
||||||
|
$"{Context.User.Mention} has removed all raffle tickets from {user.Mention}.",
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await ReplyAsync(
|
|
||||||
$"{Context.User.Mention} has removed all raffle tickets from {user.Mention}.",
|
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("raffle clear")]
|
[Command("raffle clear")]
|
||||||
@ -299,8 +289,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,8 +321,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ChaosBot.Discord.PreConditions;
|
using ChaosBot.Discord.PreConditions;
|
||||||
@ -8,14 +7,11 @@ using Dice;
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Microsoft.VisualBasic;
|
using Microsoft.VisualBasic;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.Modules.User
|
namespace ChaosBot.Discord.Modules.User
|
||||||
{
|
{
|
||||||
public class Roll : ModuleBase
|
public class Roll : ModuleBase
|
||||||
{
|
{
|
||||||
private static readonly ILogger _logger = Program.Logger;
|
|
||||||
|
|
||||||
[Command("roll")]
|
[Command("roll")]
|
||||||
[Alias("random", "dice")]
|
[Alias("random", "dice")]
|
||||||
[CheckCommandPerm("User")]
|
[CheckCommandPerm("User")]
|
||||||
@ -53,8 +49,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,26 +1,23 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using ChaosBot.Repositories;
|
using ChaosBot.Repositories;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.PreConditions
|
namespace ChaosBot.Discord.PreConditions
|
||||||
{
|
{
|
||||||
public class CheckCommandPerm : PreconditionAttribute
|
public class CheckCommandPerm : PreconditionAttribute
|
||||||
{
|
{
|
||||||
private static ILogger _logger = Program.Logger;
|
|
||||||
private readonly string _defaultRole;
|
private readonly string _defaultRole;
|
||||||
public CheckCommandPerm(string defaultRole) => _defaultRole = defaultRole;
|
public CheckCommandPerm(string defaultRole) => _defaultRole = defaultRole;
|
||||||
|
|
||||||
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
||||||
{
|
{
|
||||||
// Debug information
|
// Debug information
|
||||||
_logger.Trace($"CheckCommandPerm.CheckPermissionsAsync|Checking permissions for command: {command.Name}");
|
LoggingFacade.Trace($"CheckCommandPerm.CheckPermissionsAsync|Checking permissions for command: {command.Name}");
|
||||||
|
|
||||||
// If user is not SocketGuildUser, then return error
|
// If user is not SocketGuildUser, then return error
|
||||||
if (!(context.User is SocketGuildUser gUser)) return Task.FromResult(PreconditionResult.FromError("You must be in a guild to run this command."));
|
if (!(context.User is SocketGuildUser gUser)) return Task.FromResult(PreconditionResult.FromError("You must be in a guild to run this command."));
|
||||||
@ -79,7 +76,7 @@ namespace ChaosBot.Discord.PreConditions
|
|||||||
return Task.FromResult(PreconditionResult.FromSuccess());
|
return Task.FromResult(PreconditionResult.FromSuccess());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_logger.Info($"CheckCommandperm.CheckPermissionsAsync|commandPermissions: No Default");
|
LoggingFacade.Info($"CheckCommandperm.CheckPermissionsAsync|commandPermissions: No Default");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Permission denied
|
// Permission denied
|
||||||
|
|||||||
@ -1,25 +1,19 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ChaosBot.Models;
|
|
||||||
using ChaosBot.Repositories;
|
using ChaosBot.Repositories;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.PreConditions
|
namespace ChaosBot.Discord.PreConditions
|
||||||
{
|
{
|
||||||
public class CheckModuleEnabled : PreconditionAttribute
|
public class CheckModuleEnabled : PreconditionAttribute
|
||||||
{
|
{
|
||||||
private static ILogger _logger = Program.Logger;
|
|
||||||
private readonly string _moduleName;
|
private readonly string _moduleName;
|
||||||
public CheckModuleEnabled(string moduleName) => _moduleName = moduleName;
|
public CheckModuleEnabled(string moduleName) => _moduleName = moduleName;
|
||||||
|
|
||||||
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
||||||
{
|
{
|
||||||
// Debug information
|
// Debug information
|
||||||
_logger.Trace($"CheckModuleEnabled.CheckPermissionsAsync|Checking module enabled for module: {_moduleName}");
|
LoggingFacade.Trace($"CheckModuleEnabled.CheckPermissionsAsync|Checking module enabled for module: {_moduleName}");
|
||||||
|
|
||||||
if (context.Guild == null) return Task.FromResult(PreconditionResult.FromError("This must be run in a guild."));
|
if (context.Guild == null) return Task.FromResult(PreconditionResult.FromError("This must be run in a guild."));
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,6 @@ namespace ChaosBot.Discord.Services
|
|||||||
private readonly CommandService _commands;
|
private readonly CommandService _commands;
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
private readonly IServiceProvider _services;
|
private readonly IServiceProvider _services;
|
||||||
private readonly ILogger _logger = Program.Logger;
|
|
||||||
|
|
||||||
public CommandHandler(IServiceProvider services)
|
public CommandHandler(IServiceProvider services)
|
||||||
{
|
{
|
||||||
@ -43,7 +42,7 @@ namespace ChaosBot.Discord.Services
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error($"CommandHandler.CommandHandler: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +83,7 @@ namespace ChaosBot.Discord.Services
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error($"CommandHandler.MessageReceivedAsync: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,8 +118,7 @@ namespace ChaosBot.Discord.Services
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,8 +178,7 @@ namespace ChaosBot.Discord.Services
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,22 +188,22 @@ namespace ChaosBot.Discord.Services
|
|||||||
{
|
{
|
||||||
if (!command.IsSpecified)
|
if (!command.IsSpecified)
|
||||||
{
|
{
|
||||||
_logger.Error($"Command failed to execute for [{context.User.Username}] <-> [{result.ErrorReason}]!");
|
LoggingFacade.Error($"Command failed to execute for [{context.User.Username}] <-> [{result.ErrorReason}]!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
_logger.Info($"Command [{command.Value.Name}] executed for -> [{context.User.Username}]");
|
LoggingFacade.Info($"Command [{command.Value.Name}] executed for -> [{context.User.Username}]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Warn($"{context.User.Username} attempted to access {command.Value.Name} and was denied -> [{result}]");
|
LoggingFacade.Warn($"{context.User.Username} attempted to access {command.Value.Name} and was denied -> [{result}]");
|
||||||
await context.Channel.SendMessageAsync($"Sorry, {context.User.Username}, that command won't work for you.!");
|
await context.Channel.SendMessageAsync($"Sorry, {context.User.Username}, that command won't work for you.!");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error($"CommandHandler.CommandExecutedAsync: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.Services
|
namespace ChaosBot.Discord.Services
|
||||||
{
|
{
|
||||||
public static class CustomCommandHandler
|
public static class CustomCommandHandler
|
||||||
{
|
{
|
||||||
private static readonly ILogger Logger = Program.Logger;
|
|
||||||
|
|
||||||
public static async Task<bool> CheckCommand(SocketCommandContext context, int argPos)
|
public static async Task<bool> CheckCommand(SocketCommandContext context, int argPos)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -39,7 +35,7 @@ namespace ChaosBot.Discord.Services
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using ChaosBot.Discord.PreConditions;
|
using ChaosBot.Discord.PreConditions;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using ChaosBot.Repositories;
|
using ChaosBot.Repositories;
|
||||||
@ -8,14 +7,11 @@ using Discord;
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.Services
|
namespace ChaosBot.Discord.Services
|
||||||
{
|
{
|
||||||
public class ExperienceHandler
|
public class ExperienceHandler
|
||||||
{
|
{
|
||||||
private static readonly ILogger Logger = Program.Logger;
|
|
||||||
|
|
||||||
public static async void AddXp(SocketCommandContext context)
|
public static async void AddXp(SocketCommandContext context)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -100,8 +96,7 @@ namespace ChaosBot.Discord.Services
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error(
|
LoggingFacade.Exception(ex);
|
||||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,18 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Discord.Services
|
namespace ChaosBot.Discord.Services
|
||||||
{
|
{
|
||||||
public static class RoleReactionHandler
|
public static class RoleReactionHandler
|
||||||
{
|
{
|
||||||
private static readonly ILogger Logger = Program.Logger;
|
|
||||||
|
|
||||||
public static async void HandleReactionAdded(Cacheable<IUserMessage, ulong> cacheableMessage, ISocketMessageChannel socketMessageChannel, SocketReaction reaction)
|
public static async void HandleReactionAdded(Cacheable<IUserMessage, ulong> cacheableMessage, ISocketMessageChannel socketMessageChannel, SocketReaction reaction)
|
||||||
{
|
{
|
||||||
Optional<IUser> optionalUser = reaction.User;
|
Optional<IUser> optionalUser = reaction.User;
|
||||||
@ -38,7 +34,7 @@ namespace ChaosBot.Discord.Services
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,7 +64,7 @@ namespace ChaosBot.Discord.Services
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ namespace ChaosBot.Discord.Services
|
|||||||
{
|
{
|
||||||
public static class TimerHandler
|
public static class TimerHandler
|
||||||
{
|
{
|
||||||
private static readonly ILogger _logger = Program.Logger;
|
|
||||||
private static DiscordSocketClient _client;
|
private static DiscordSocketClient _client;
|
||||||
|
|
||||||
public static void Initialize(IServiceProvider services)
|
public static void Initialize(IServiceProvider services)
|
||||||
@ -31,7 +30,7 @@ namespace ChaosBot.Discord.Services
|
|||||||
SocketGuild guild = _client.GetGuild(Convert.ToUInt64(serverConfig.Key));
|
SocketGuild guild = _client.GetGuild(Convert.ToUInt64(serverConfig.Key));
|
||||||
if (guild == null)
|
if (guild == null)
|
||||||
{
|
{
|
||||||
_logger.Warn($"Guild {Convert.ToUInt64(serverConfig.Key)} not found");
|
LoggingFacade.Warn($"Guild {Convert.ToUInt64(serverConfig.Key)} not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +38,7 @@ namespace ChaosBot.Discord.Services
|
|||||||
guild.GetChannel(Convert.ToUInt64(lodestoneChannelSloganDescriptionId));
|
guild.GetChannel(Convert.ToUInt64(lodestoneChannelSloganDescriptionId));
|
||||||
if (socketChannel == null)
|
if (socketChannel == null)
|
||||||
{
|
{
|
||||||
_logger.Warn(
|
LoggingFacade.Warn(
|
||||||
$"Channel {Convert.ToUInt64(lodestoneChannelSloganDescriptionId)} not found in server {guild.Name}");
|
$"Channel {Convert.ToUInt64(lodestoneChannelSloganDescriptionId)} not found in server {guild.Name}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -47,7 +46,7 @@ namespace ChaosBot.Discord.Services
|
|||||||
ITextChannel channel = socketChannel as ITextChannel;
|
ITextChannel channel = socketChannel as ITextChannel;
|
||||||
if (channel == null)
|
if (channel == null)
|
||||||
{
|
{
|
||||||
_logger.Warn($"Could not cast channel {socketChannel.Id} to ITextChannel");
|
LoggingFacade.Warn($"Could not cast channel {socketChannel.Id} to ITextChannel");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +60,7 @@ namespace ChaosBot.Discord.Services
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error($"TimerHandler.UpdateChannelSloganDescription: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
|
|||||||
59
ChaosBot/LoggingFacade.cs
Normal file
59
ChaosBot/LoggingFacade.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
|
using NLog;
|
||||||
|
|
||||||
|
namespace ChaosBot
|
||||||
|
{
|
||||||
|
public static class LoggingFacade
|
||||||
|
{
|
||||||
|
private static ILogger GetLogger()
|
||||||
|
{
|
||||||
|
return Program.GetLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsTraceEnabled => GetLogger().IsTraceEnabled;
|
||||||
|
public static bool IsDebugEnabled => GetLogger().IsDebugEnabled;
|
||||||
|
public static bool IsInfoEnabled => GetLogger().IsInfoEnabled;
|
||||||
|
public static bool IsWarnEnabled => GetLogger().IsWarnEnabled;
|
||||||
|
public static bool IsErrorEnabled => GetLogger().IsErrorEnabled;
|
||||||
|
public static bool IsFatalEnabled => GetLogger().IsFatalEnabled;
|
||||||
|
|
||||||
|
public static void Trace(object value)
|
||||||
|
{
|
||||||
|
GetLogger().Trace(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Debug(object value)
|
||||||
|
{
|
||||||
|
GetLogger().Debug(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Info(object value)
|
||||||
|
{
|
||||||
|
GetLogger().Info(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Warn(object value)
|
||||||
|
{
|
||||||
|
GetLogger().Warn(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Error(object value)
|
||||||
|
{
|
||||||
|
GetLogger().Error(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Fatal(object value)
|
||||||
|
{
|
||||||
|
GetLogger().Fatal(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Exception(Exception ex)
|
||||||
|
{
|
||||||
|
MethodBase method = new StackFrame(1).GetMethod();
|
||||||
|
Error($"{method?.ReflectedType?.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
||||||
|
Debug($"{method?.ReflectedType?.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.\n{ex.StackTrace}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -10,7 +10,7 @@ namespace ChaosBot
|
|||||||
{
|
{
|
||||||
internal class Program
|
internal class Program
|
||||||
{
|
{
|
||||||
public static ILogger Logger;
|
private static ILogger _logger;
|
||||||
public static IConfiguration AppSettingsHandler;
|
public static IConfiguration AppSettingsHandler;
|
||||||
|
|
||||||
private static string _appsettingsPath;
|
private static string _appsettingsPath;
|
||||||
@ -21,6 +21,11 @@ namespace ChaosBot
|
|||||||
new Program().MainFunction().GetAwaiter().GetResult();
|
new Program().MainFunction().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ILogger GetLogger()
|
||||||
|
{
|
||||||
|
return _logger;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task MainFunction()
|
private async Task MainFunction()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -33,7 +38,7 @@ namespace ChaosBot
|
|||||||
/*
|
/*
|
||||||
* Initialize the _logger for logging purposes
|
* Initialize the _logger for logging purposes
|
||||||
*/
|
*/
|
||||||
Logger = Logging.GenLog(configurationHandler);
|
_logger = Logging.GenLog(configurationHandler);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set AppSettingsHandler on ConfigurationRepository
|
* Set AppSettingsHandler on ConfigurationRepository
|
||||||
@ -43,7 +48,7 @@ namespace ChaosBot
|
|||||||
/*
|
/*
|
||||||
* Initialize the Discord Client and Login
|
* Initialize the Discord Client and Login
|
||||||
*/
|
*/
|
||||||
Logger.Info($"Starting Up {AppSettingsHandler.GetValue<string>("Bot:Name")} v{AppSettingsHandler.GetValue<string>("Bot:Version")}");
|
_logger.Info($"Starting Up {AppSettingsHandler.GetValue<string>("Bot:Name")} v{AppSettingsHandler.GetValue<string>("Bot:Version")}");
|
||||||
|
|
||||||
|
|
||||||
var discordBot = LoadDiscord();
|
var discordBot = LoadDiscord();
|
||||||
@ -52,7 +57,7 @@ namespace ChaosBot
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error(ex, $"Program.MainFunction: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
_logger.Error(ex, $"Program.MainFunction: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,23 +1,19 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using ChaosBot.Repositories;
|
using ChaosBot.Repositories;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Services
|
namespace ChaosBot.Services
|
||||||
{
|
{
|
||||||
public class CheckPermissions
|
public class CheckPermissions
|
||||||
{
|
{
|
||||||
private static ILogger _logger = Program.Logger;
|
|
||||||
|
|
||||||
public static Boolean CheckPerms(ICommandContext context, string command, string defaultRole = "User")
|
public static Boolean CheckPerms(ICommandContext context, string command, string defaultRole = "User")
|
||||||
{
|
{
|
||||||
// Debug information
|
// Debug information
|
||||||
_logger.Trace($"CheckCommandPerm.CheckPermissionsAsync|Checking permissions for command: {command}");
|
LoggingFacade.Trace($"CheckCommandPerm.CheckPermissionsAsync|Checking permissions for command: {command}");
|
||||||
|
|
||||||
// If user is not SocketGuildUser, then return error
|
// If user is not SocketGuildUser, then return error
|
||||||
if (!(context.User is SocketGuildUser gUser)) return false;
|
if (!(context.User is SocketGuildUser gUser)) return false;
|
||||||
@ -76,7 +72,7 @@ namespace ChaosBot.Services
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_logger.Info($"CheckCommandperm.CheckPermissionsAsync|commandPermissions: No Default");
|
LoggingFacade.Info($"CheckCommandperm.CheckPermissionsAsync|commandPermissions: No Default");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Permission denied
|
// Permission denied
|
||||||
|
|||||||
@ -1,14 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ChaosBot.Lodestone;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NLog;
|
|
||||||
using NLog.Fluent;
|
|
||||||
|
|
||||||
namespace ChaosBot.Services
|
namespace ChaosBot.Services
|
||||||
{
|
{
|
||||||
@ -29,7 +25,6 @@ namespace ChaosBot.Services
|
|||||||
|
|
||||||
static class LodestoneHttpConnection
|
static class LodestoneHttpConnection
|
||||||
{
|
{
|
||||||
private static readonly ILogger _logger = Program.Logger;
|
|
||||||
static HttpClient client = new HttpClient();
|
static HttpClient client = new HttpClient();
|
||||||
private static bool _firstRun = true;
|
private static bool _firstRun = true;
|
||||||
|
|
||||||
@ -59,7 +54,7 @@ namespace ChaosBot.Services
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, $"HttpProxy.fetch<{typeof(T)}>: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
LoggingFacade.Exception(ex);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,19 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ChaosBot.Models;
|
|
||||||
using ChaosBot.Repositories;
|
|
||||||
using Discord.Commands;
|
|
||||||
using Discord.WebSocket;
|
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.Services
|
namespace ChaosBot.Services
|
||||||
{
|
{
|
||||||
public class RestrictedConfig
|
public class RestrictedConfig
|
||||||
{
|
{
|
||||||
private static ILogger _logger = Program.Logger;
|
|
||||||
|
|
||||||
public static Boolean IsAllowed(string key)
|
public static Boolean IsAllowed(string key)
|
||||||
{
|
{
|
||||||
// TODO: List populated from DB
|
// TODO: List populated from DB
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ChaosBot.Services
|
namespace ChaosBot.Services
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.WebServer.App
|
namespace ChaosBot.WebServer.App
|
||||||
{
|
{
|
||||||
@ -18,7 +15,6 @@ namespace ChaosBot.WebServer.App
|
|||||||
{
|
{
|
||||||
private static readonly AccessTokenCache Cache = WebServer.Cache;
|
private static readonly AccessTokenCache Cache = WebServer.Cache;
|
||||||
private static readonly HttpClient client = new HttpClient();
|
private static readonly HttpClient client = new HttpClient();
|
||||||
private static readonly ILogger Logger = Program.Logger;
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> Index(string code = null)
|
public async Task<IActionResult> Index(string code = null)
|
||||||
|
|||||||
@ -1,18 +1,14 @@
|
|||||||
using System.IO;
|
|
||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace ChaosBot.WebServer
|
namespace ChaosBot.WebServer
|
||||||
{
|
{
|
||||||
class Startup
|
class Startup
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger = Program.Logger;
|
|
||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
public IConfiguration Configuration { get; }
|
||||||
|
|
||||||
public Startup(IConfiguration configuration)
|
public Startup(IConfiguration configuration)
|
||||||
@ -38,7 +34,7 @@ namespace ChaosBot.WebServer
|
|||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
_logger.Info("Initializing Kestrel Startup and Configuration");
|
LoggingFacade.Info("Initializing Kestrel Startup and Configuration");
|
||||||
|
|
||||||
if (Program.AppSettingsHandler.GetValue<bool>("WebServer:Debug", false))
|
if (Program.AppSettingsHandler.GetValue<bool>("WebServer:Debug", false))
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user