private Task MessageHandler(SocketMessage message) { string firstWord = message.Content.Split()[0]; bool pong = message.Author.Id == BaseConfig.GetConfig().BotID&& firstWord == "Pinging..."; if (pong || !message.Author.IsBot) { Recieved.Message = message; } else { return(Task.CompletedTask); } if (pong) { Ping.DoCommand(true); } if (!message.Content.StartsWith(BaseConfig.GetConfig().Prefix) || message.Author.IsBot) { return(Task.CompletedTask); } string command = firstWord.Substring(1, firstWord.Length - 1).ToLower(); // Commands if (Commands.Commands.Aliases.Contains(command) && BotChannel()) { Commands.Commands.DoCommand(); } if (Ping.Aliases.Contains(command) && BotChannel()) { Ping.DoCommand(false); } if (Restart.Aliases.Contains(command) && BotChannel() && IsAdmin(true)) { Restart.DoCommand(); } if (Test.Aliases.Contains(command) && BotChannel() && IsAdmin(true)) { Test.DoCommand(); } return(Task.CompletedTask); }
private Task MessageHandler(SocketMessage message) { string firstWord = message.Content.Split()[0]; bool pong = message.Author.Id == _client.CurrentUser.Id && firstWord == "Pinging..."; if (pong || (!message.Author.IsBot && !message.Author.IsWebhook)) { Recieved.Message = message; } else { return(Task.CompletedTask); } try { // Events BotMention.DoEvent().Wait(); Emojify.DoEvent().Wait(); Xp.DoEvent().Wait(); if (pong) { Ping.DoCommand(true).Wait(); } if (!message.Content.StartsWith(BaseConfig.GetConfig().Prefix) || message.Author.IsBot) { return(Task.CompletedTask); } string command = firstWord.Substring(1, firstWord.Length - 1).ToLower(); // Commands // Dev if (Evaluate.Aliases.Contains(command) && HasPerm(Evaluate.AllowedRoles)) { Evaluate.DoCommand().Wait(); } if (Ping.Aliases.Contains(command) && BotChannel()) { Ping.DoCommand(false).Wait(); } if (Restart.Aliases.Contains(command) && BotChannel() && HasPerm(Restart.AllowedRoles)) { Restart.DoCommand().Wait(); } if (Test.Aliases.Contains(command) && BotChannel() && HasPerm(Test.AllowedRoles)) { Test.DoCommand().Wait(); } // Fun if (Minesweeper.Aliases.Contains(command) && BotChannel()) { Minesweeper.DoCommand().Wait(); } if (MathEval.Aliases.Contains(command) && BotChannel()) { MathEval.DoCommand().Wait(); } // Info if (Commands.Commands.Aliases.Contains(command) && BotChannel()) { Commands.Commands.DoCommand().Wait(); } if (EmojiList.Aliases.Contains(command) && BotChannel()) { EmojiList.DoCommand().Wait(); } if (Leaderboard.Aliases.Contains(command) && BotChannel()) { Leaderboard.DoCommand().Wait(); } if (UserInfo.Aliases.Contains(command) && BotChannel()) { UserInfo.DoCommand().Wait(); } // Util if (AnswerRequest.Aliases.Contains(command)) { AnswerRequest.DoCommand().Wait(); } if (PingRequest.Aliases.Contains(command)) { PingRequest.DoCommand().Wait(); } if (Store.Aliases.Contains(command) && BotChannel()) { Store.DoCommand().Wait(); } } catch (Exception e) { foreach (var i in BaseConfig.GetConfig().Channels.BotTerminal) { ((IMessageChannel)_client.GetChannel(i)).SendMessageAsync($"```{e}```"); } } return(Task.CompletedTask); }