private Task CommandHandler(SocketMessage message) { if (!message.Content.StartsWith(BaseConfig.GetConfig().Prefix) || message.Author.IsBot) { return(Task.CompletedTask); } string firstWord = message.Content.Split()[0]; string command = firstWord.Substring(1, firstWord.Length - 1).ToLower(); if (BotChannel()) { // Dev if (Evaluate.Aliases.Contains(command) && HasPerm(Evaluate.AllowedRoles)) { Evaluate.DoCommand(); } if (Restart.Aliases.Contains(command) && HasPerm(Restart.AllowedRoles)) { Restart.DoCommand(); } if (Test.Aliases.Contains(command) && HasPerm(Test.AllowedRoles)) { Test.DoCommand(); } // Fun if (Minesweeper.Aliases.Contains(command)) { Minesweeper.DoCommand(); } // Main if (Leaderboard.Aliases.Contains(command)) { Leaderboard.DoCommand(); } if (Rank.Aliases.Contains(command)) { Rank.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); }