only print logged commands if it was a valid command

This commit is contained in:
TheUbMunster 2022-12-24 01:04:23 -07:00
parent 9e3a72dcbc
commit bb02fa6e90
1 changed files with 4 additions and 4 deletions

View File

@ -147,10 +147,6 @@ public class DiscordBot
if ((arg.Channel.Id.ToString() == localSettings.CommandChannel || arg.Channel.Id.ToString() == localSettings.LogChannel) && !arg.Author.IsBot) if ((arg.Channel.Id.ToString() == localSettings.CommandChannel || arg.Channel.Id.ToString() == localSettings.LogChannel) && !arg.Author.IsBot)
{ {
string message = (await arg.Channel.GetMessageAsync(arg.Id)).Content; string message = (await arg.Channel.GetMessageAsync(arg.Id)).Content;
if (localSettings.LogCommands)
{
logger.Info($"\"{arg.Author.Username}\" ran the command: \"{message}\" via discord");
}
//run command //run command
try try
{ {
@ -172,6 +168,10 @@ public class DiscordBot
} }
if (resp != null) if (resp != null)
{ {
if (localSettings.LogCommands)
{
logger.Info($"\"{arg.Author.Username}\" ran the command: \"{message}\" via discord");
}
foreach (string mesg in SplitMessage(resp)) foreach (string mesg in SplitMessage(resp))
await (arg as SocketUserMessage).ReplyAsync(mesg); await (arg as SocketUserMessage).ReplyAsync(mesg);
} }