From 08d1020770b9a6ca2df86ad07772735135768561 Mon Sep 17 00:00:00 2001 From: TheUbMunster <66451362+TheUbMunster@users.noreply.github.com> Date: Mon, 22 Aug 2022 16:01:58 -0600 Subject: [PATCH] You can no longer dm a bot for a command (has been tested) --- Server/DiscordBot.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Server/DiscordBot.cs b/Server/DiscordBot.cs index fc3bb55..f78fd1f 100644 --- a/Server/DiscordBot.cs +++ b/Server/DiscordBot.cs @@ -91,6 +91,17 @@ public class DiscordBot { string mentionPrefix = $"{DiscordClient.CurrentUser.Mention} "; DiscordClient.MessageCreated += async (_, args) => { if (args.Author.IsCurrent) return; + //prevent commands via dm + if (Config.LogChannel == null) { + Logger.Warn("The discord bot cannot process commands because the LogChannel in settings isn't set"); + return; + } + ulong chId = ulong.Parse(Config.LogChannel); + if (args.Channel.Id != chId) { + Logger.Warn("A command was sent to the bot in a channel other than the specified log channel (probably attempt to run command via dm)"); + return; + } + //run command try { DiscordMessage msg = args.Message; string? resp = null;