/// <summary> /// Handles the Reaction Added event. /// </summary> /// <param name="cachedMessage">Message that was reaction is on.</param> /// <param name="originChannel">Channel where the message is located.</param> /// <param name="reaction">Reaction made on the message.</param> /// <returns>Task Complete.</returns> private async Task <Task> HandleReactionAdded(Cacheable <IUserMessage, ulong> cachedMessage, ISocketMessageChannel originChannel, SocketReaction reaction) { IMessage message = await originChannel.GetMessageAsync(cachedMessage.Id); SocketGuildChannel chnl = message.Channel as SocketGuildChannel; ulong guild = chnl.Guild.Id; IUser user = reaction.User.Value; if (message != null && reaction.User.IsSpecified && !user.IsBot) { if (RaidCommandParent.IsRaidMessage(message.Id)) { await RaidCommandParent.RaidMessageReactionHandle(message, reaction); } else if (RaidCommandParent.IsRaidSubMessage(message.Id)) { await RaidCommandParent.RaidSubMessageReactionHandle(message, reaction); } else if (RaidCommandParent.IsRaidGuideMessage(message.Id)) { await RaidCommandParent.RaidGuideMessageReactionHandle(message, reaction); } else if (DexCommandParent.IsDexSelectMessage(message.Id)) { await DexCommandParent.DexSelectMessageReactionHandle(message, reaction, guild); } else if (DexCommandParent.IsDexMessage(message.Id)) { await DexCommandParent.DexMessageReactionHandle(message, reaction, guild); } else if (DexCommandParent.IsCatchMessage(message.Id)) { await DexCommandParent.CatchMessageReactionHandle(message, reaction); } else if (POICommands.IsPOISubMessage(message.Id)) { await POICommands.POIMessageReactionHandle(message, reaction, guild); } else if (HelpCommands.IsHelpMessage(message.Id)) { await HelpCommands.HelpMessageReactionHandle(message, reaction, guild); } else if (Connections.IsNotifyMessage(message.Id)) { await Connections.NotifyMessageReactionHandle(message, reaction, chnl.Guild); } } return(Task.CompletedTask); }
public ClasherDynBot() { rand = new Random(); discord = new DiscordClient(x => { x.LogLevel = LogSeverity.Info; x.LogHandler = Log; }); discord.UsingCommands(x => { x.PrefixChar = '!'; x.AllowMentionPrefix = true; }); commands = discord.GetService <CommandService>(); #region register command groups HelpCommands.RegisterHelpCommands(commands, discord); FunCommands.RegisterFunCommands(commands, discord); SettingCommands.RegisterWebsiteCommands(commands, discord); SearchCommands.RegisterSearchCommands(commands, discord); AttendanceCommands.RegisterAttendanceCommands(commands, discord); WarningCommands.RegisterWarningCommands(commands, discord); EnemyNoteCommands.RegisterEnemyNoteCommands(commands, discord); WarCommands.RegisterWarCommands(commands, discord); AdminCommands.RegisterAdminCommands(commands, discord); #endregion discord.ExecuteAndWait(async() => { string key = ConfigurationManager.AppSettings["Key"]; await discord.Connect(key, Discord.TokenType.Bot); //auto start notifications await StartNotifications(); }); }
public static void HandleAceCommandsFromServer(Session session, params string[] parameters) { HelpCommands.HandleAceCommands(session, CommandChannel.TheServerChannel, parameters); }
public HelpMessage(HelpCommands command, string message) { this.CommandNumber = command; this.Message = message; }
// In order to enable dotnet-counters you need to install dotnet-counters tool with the following command (use cmd) // dotnet tool install --global dotnet-counters // link: https://docs.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-counters#:~:text=dotnet-counters%20is%20a%20performance%20monitoring%20tool%20for%20ad-hoc,values%20that%20are%20published%20via%20the%20EventCounter%20API. static void Main(string[] args) { // You need to change to font to SimSun-ExtB in order to show unicode characters in console - IMPORTANT Console.OutputEncoding = System.Text.Encoding.UTF8; InitCommands(); OutputBanner(); LaunchConsoleMonitor(); // If console app is started without args: if (args.Length == 0) { while (!Commands.All(e => e.Value)) { var required = GetRequiredCommand(); if (required == "RUN") { ConsoleUtils.WriteLineColored(ConsoleColor.Cyan, $"\nSolver is running ..."); DispatchCommands.ProcessCommand("RUN", "ok"); var runAgain = true; while (runAgain) { Console.WriteLine("\nRun again to debug memory usage?"); Console.WriteLine("\tYes or No\n"); var runAgainAnswer = Console.ReadLine().Trim().ToLower(); if (runAgainAnswer.Equals("yes") || runAgainAnswer.Equals("y")) { Console.WriteLine(); DispatchCommands.ProcessCommand("RUN", "ok"); } else { runAgain = false; } } break; } ConsoleUtils.WriteLineColored(ConsoleColor.Cyan, $"Enter a {required} "); Console.WriteLine($"\t{AvailableCommands[required]}"); var userInput = Console.ReadLine().Trim().ToLower(); if (userInput.Equals("help") || userInput.Equals("-h")) { HelpCommands.ProcessHelpCommand(userInput); } else { var ok = DispatchCommands.ProcessCommand(required, userInput); if (ok) { Commands[required] = true; if (required.Trim().ToUpper() == "BOARDSIZE") { BoardSize = Convert.ToSByte(userInput); } } } } } // Console app is started with custom args: else { for (var i = 0; i < args.Length; i++) { (string key, string value) = ParseInput(args[i]); var ok = DispatchCommands.ProcessCommand(key, value); if (ok) { Commands[key.ToUpper()] = true; if (key.Equals("BOARDSIZE")) { BoardSize = Convert.ToSByte(value); } } } if (GetRequiredCommand() == "RUN") { ConsoleUtils.WriteLineColored(ConsoleColor.Cyan, "Solver is running:\n"); DispatchCommands.ProcessCommand("RUN", "ok"); } } }