0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-22 03:05:16 +00:00

added log message that prints the channel the command came from and the channel commands are accepted from

This commit is contained in:
TheUbMunster 2022-08-22 16:43:00 -06:00 committed by Sanae
parent b6e634ada4
commit 82e94334c9

View file

@ -96,6 +96,7 @@ public class DiscordBot {
Reconnecting = false; Reconnecting = false;
string mentionPrefix = $"{DiscordClient.CurrentUser.Mention} "; string mentionPrefix = $"{DiscordClient.CurrentUser.Mention} ";
DiscordClient.MessageCreated += async (_, args) => { DiscordClient.MessageCreated += async (_, args) => {
Logger.Info($"Message recieved on channel \"{args.Channel.Id}\", accepting commands from channel \"{Config.LogChannel ?? "(Any Channel)"}\", do channels match: {args.Channel.Id.ToString() == Config.LogChannel}");
if (args.Author.IsCurrent) return; //dont respond to commands from ourselves (prevent "sql-injection" esq attacks) if (args.Author.IsCurrent) return; //dont respond to commands from ourselves (prevent "sql-injection" esq attacks)
//prevent commands via dm and non-public channels //prevent commands via dm and non-public channels
if (Config.LogChannel == null) { if (Config.LogChannel == null) {
@ -105,7 +106,7 @@ public class DiscordBot {
} }
if (args.Channel is DiscordDmChannel) { if (args.Channel is DiscordDmChannel) {
#if LOG_BAD_REQ #if LOG_BAD_REQ
Logger.Warn("A command was sent to the bot in a non-public channel. This will not be processed. (Send commands in the specified LogChannel in settings.json or only in public channels)"); Logger.Warn("A command was sent to the bot in a direct message channel. This will not be processed. (Send commands in the specified LogChannel in settings.json or only in public channels)");
#endif #endif
#if SEND_RESP_TO_BAD_REQ #if SEND_RESP_TO_BAD_REQ
await args.Message.RespondAsync("This channel is not valid for running commands. (Your command was not processed)."); await args.Message.RespondAsync("This channel is not valid for running commands. (Your command was not processed).");