Exemple #1
0
        private void OnHelpMessage(Dictionary <string, object> parameters, SocketMessage e)
        {
            if (parameters.ContainsKey("<command>"))
            {
                string command = parameters["<command>"].ToString();

                if (m_discordEvents.ContainsKey(DiscordEventType.MessageRecieved))
                {
                    List <DiscordEvent>        rules        = m_discordEvents[DiscordEventType.MessageRecieved];
                    IEnumerable <DiscordEvent> commandRules = rules.Where(ev => ev.Rule is DiscordMessageRule ? ((DiscordMessageRule)ev.Rule).Command == command : false);
                    if (commandRules.Count() > 0)
                    {
                        string title = $"Commands For {command}";

                        commandRules.BuildCustomEmbed(evt =>
                        {
                            DiscordMessageRule cmd = (evt.Rule as DiscordMessageRule);
                            return($"{cmd.Pattern.Markdown(DiscordMarkdown.UnderlineBold)}\n{cmd.Help}\n");
                        }, title, e.Channel);
                    }
                }

                if (m_discordEvents.ContainsKey(DiscordEventType.PrivateMessageRecieved))
                {
                    List <DiscordEvent>        rules        = m_discordEvents[DiscordEventType.PrivateMessageRecieved];
                    IEnumerable <DiscordEvent> commandRules = rules.Where(ev => ev.Rule is DiscordMessageRule ? ((DiscordMessageRule)ev.Rule).Command == command : false);
                    if (commandRules.Count() > 0)
                    {
                        string title = $"Commands For {command}";

                        commandRules.BuildCustomEmbed(evt =>
                        {
                            DiscordMessageRule cmd = (evt.Rule as DiscordMessageRule);
                            return($"{cmd.Pattern.Markdown(DiscordMarkdown.UnderlineBold)}\n{cmd.Help}\n");
                        }, title, e.Channel);
                    }
                }
            }
            //else
            //{
            //    HashSet<string> commands = new HashSet<string>();
            //    foreach (var kvp in m_discordEvents)
            //    {
            //        foreach(var events in kvp.Value)
            //        {
            //            if(events.Rule is DiscordMessageRule)
            //            {
            //                DiscordMessageRule rule = (events.Rule as DiscordMessageRule);
            //                commands.Add(rule.Command);
            //            }
            //        }
            //    }

            //    string title = $"Commands List";
            //    commands.BuildCustomEmbed(cmd =>
            //    {
            //        return $"Command - {cmd}";
            //    }, title, e.Channel);
            //}
        }
Exemple #2
0
 public void RegisterAdminCommand(DiscordAdmin type, string command, string help, Action <Dictionary <string, object>, SocketMessage> eventMethod)
 {
     if ((type == DiscordAdmin.DM && m_guild == null) || type == DiscordAdmin.Global)
     {
         DiscordMessageRule rule         = new DiscordMessageRule(command, help);
         DiscordEvent       discordEvent = new DiscordEvent();
         discordEvent.Rule  = rule;
         discordEvent.Type  = type == DiscordAdmin.DM ? DiscordEventType.PrivateMessageRecieved : DiscordEventType.MessageRecieved;
         discordEvent.Event = eventMethod;
         AddDiscordEvent(discordEvent);
     }
 }
Exemple #3
0
 public void RegisterCommand(string command, string help, Action <Dictionary <string, object>, SocketMessage> eventMethod)
 {
     if (m_guild != null)
     {
         DiscordMessageRule rule         = new DiscordMessageRule(command, help);
         DiscordEvent       discordEvent = new DiscordEvent();
         discordEvent.Rule  = rule;
         discordEvent.Type  = DiscordEventType.MessageRecieved;
         discordEvent.Event = eventMethod;
         AddDiscordEvent(discordEvent);
     }
 }