Increase logging precision
This commit is contained in:
parent
76773074ad
commit
c660a0e970
@ -59,6 +59,11 @@ namespace ChaosBot.Discord.Services
|
||||
if (message.Source != MessageSource.User)
|
||||
return;
|
||||
|
||||
string messageToPrint = message.Content.Length > 50
|
||||
? $"{message.Content.Substring(0, 50)}..."
|
||||
: message.Content;
|
||||
LoggingFacade.Trace($"Message Received [{message.Author.Username}#{message.Author.Discriminator} -> {messageToPrint}]");
|
||||
|
||||
SocketCommandContext context = new SocketCommandContext(_client, message);
|
||||
|
||||
int argPos = 0;
|
||||
@ -67,17 +72,18 @@ namespace ChaosBot.Discord.Services
|
||||
if (!(message.HasMentionPrefix(_client.CurrentUser, ref argPos) ||
|
||||
message.HasStringPrefix(prefix, ref argPos)))
|
||||
{
|
||||
ExperienceHandler.AddXp(context);
|
||||
if(Convert.ToBoolean(ConfigurationRepository.GetValue("Experience:Commands", context.Guild.Id, "false")))
|
||||
ExperienceHandler.AddXp(context);
|
||||
return;
|
||||
}
|
||||
|
||||
if(Convert.ToBoolean(ConfigurationRepository.GetValue("Experience:Commands", context.Guild.Id, "false")))
|
||||
ExperienceHandler.AddXp(context);
|
||||
|
||||
bool customCommandExecuted = await CustomCommandHandler.CheckCommand(context, argPos);
|
||||
|
||||
|
||||
if (!customCommandExecuted)
|
||||
await _commands.ExecuteAsync(context, argPos, _services);
|
||||
{
|
||||
LoggingFacade.Info($"Executing command [{context.User.Username}#{context.User.Discriminator} -> {context.Message.Content.Substring(argPos)}]");
|
||||
await _commands.ExecuteAsync(context, argPos, _services);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -186,23 +192,23 @@ namespace ChaosBot.Discord.Services
|
||||
{
|
||||
if (!command.IsSpecified)
|
||||
{
|
||||
LoggingFacade.Error($"Command failed to execute for [{context.User.Username}] <-> [{result.ErrorReason}]!");
|
||||
LoggingFacade.Error($"Command execution failed [{context.User.Username}#{context.User.Discriminator} -> {command.Value.Name}]");
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
LoggingFacade.Info($"Command [{command.Value.Name}] executed for -> [{context.User.Username}]");
|
||||
LoggingFacade.Info($"Command executed [{context.User.Username}#{context.User.Discriminator} -> {command.Value.Name}]");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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.!");
|
||||
LoggingFacade.Warn($"Command access denied [{context.User.Username}#{context.User.Discriminator} -> {command.Value.Name} ({result})]");
|
||||
await context.Channel.SendMessageAsync($"Sorry, {context.User.Mention}, that command won't work for you!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggingFacade.Exception(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,8 @@ namespace ChaosBot.Discord.Services
|
||||
.FirstOrDefault(cc => command.StartsWith(cc.Command));
|
||||
|
||||
if (customCommand == null) return false;
|
||||
|
||||
LoggingFacade.Info($"Running custom command [{context.User.Username}#{context.User.Discriminator} -> {customCommand.Command}]");
|
||||
|
||||
if (customCommand.Type == CustomCommandType.Basic)
|
||||
{
|
||||
|
||||
@ -65,6 +65,8 @@ namespace ChaosBot.Discord.Services
|
||||
if (newLevel > oldLevel)
|
||||
{
|
||||
// The user has leveled up, we can send a message
|
||||
LoggingFacade.Info($"User leveled up [{context.User.Username}#{context.User.Discriminator} -> Level {newLevel}]");
|
||||
|
||||
string channelToSendIn =
|
||||
ConfigurationRepository.GetValue("LevelUp:Channel", context.Guild.Id, "false");
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user