Exemplo n.º 1
0
        public async Task <SortedDictionary <string, List <string> > > GetEventNamesAsync(IDiscordMessage e)
        {
            SortedDictionary <string, List <string> > moduleEvents = new SortedDictionary <string, List <string> >
            {
                { "MISC", new List <string>() }
            };
            EventAccessibility userEventAccessibility = CommandHandler.GetUserAccessibility(e);

            foreach (ICommandEvent ev in CommandHandler.Commands.Values)
            {
                if (await ev.IsEnabled(e.Channel.Id) && userEventAccessibility >= ev.Accessibility)
                {
                    if (ev.Module != null)
                    {
                        if (!moduleEvents.ContainsKey(ev.Module.Name.ToUpper()))
                        {
                            moduleEvents.Add(ev.Module.Name.ToUpper(), new List <string>());
                        }

                        if (CommandHandler.GetUserAccessibility(e) >= ev.Accessibility)
                        {
                            moduleEvents[ev.Module.Name.ToUpper()].Add(ev.Name);
                        }
                    }
                    else
                    {
                        moduleEvents["MISC"].Add(ev.Name);
                    }
                }
            }

            if (moduleEvents["MISC"].Count == 0)
            {
                moduleEvents.Remove("MISC");
            }

            moduleEvents.OrderBy(i => { return(i.Key); });

            foreach (List <string> list in moduleEvents.Values)
            {
                list.Sort((x, y) => x.CompareTo(y));
            }

            return(moduleEvents);
        }
Exemplo n.º 2
0
        public async Task ShowModulesAsync(CommandContext e)
        {
            var cache = e.GetService <ICacheClient>();
            var db    = e.GetService <DbContext>();

            List <string>        modules                = new List <string>();
            SimpleCommandHandler commandHandler         = e.EventSystem.GetCommandHandler <SimpleCommandHandler>();
            EventAccessibility   userEventAccessibility = await commandHandler.GetUserAccessibility(e);

            foreach (CommandEvent ev in commandHandler.Commands)
            {
                if (userEventAccessibility >= ev.Accessibility)
                {
                    if (ev.Module != null && !modules.Contains(ev.Module.Name.ToUpper()))
                    {
                        modules.Add(ev.Module.Name.ToUpper());
                    }
                }
            }

            modules.Sort();

            string firstColumn = "", secondColumn = "";

            for (int i = 0; i < modules.Count(); i++)
            {
                string output = $"{(await e.EventSystem.GetCommandHandler<SimpleCommandHandler>().Modules[i].IsEnabled(cache, db, e.Channel.Id) ? "<:iconenabled:341251534522286080>" : "<:icondisabled:341251533754728458>")} {modules[i]}\n";
                if (i < modules.Count() / 2 + 1)
                {
                    firstColumn += output;
                }
                else
                {
                    secondColumn += output;
                }
            }

            await new EmbedBuilder()
            .SetTitle($"Module Status for '{e.Channel.Name}'")
            .AddInlineField("Column 1", firstColumn)
            .AddInlineField("Column 2", secondColumn)
            .ToEmbed().QueueToChannelAsync(e.Channel);
        }
Exemplo n.º 3
0
        public async Task ShowModulesAsync(EventContext e)
        {
            List <string>      modules                = new List <string>();
            ICommandHandler    commandHandler         = e.EventSystem.CommandHandler;
            EventAccessibility userEventAccessibility = commandHandler.GetUserAccessibility(e.message);

            foreach (ICommandEvent ev in commandHandler.Commands)
            {
                if (userEventAccessibility >= ev.Accessibility)
                {
                    if (ev.Module != null && !modules.Contains(ev.Module.Name.ToUpper()))
                    {
                        modules.Add(ev.Module.Name.ToUpper());
                    }
                }
            }

            modules.Sort();

            string firstColumn = "", secondColumn = "";

            for (int i = 0; i < modules.Count(); i++)
            {
                string output = $"{( await e.commandHandler.GetModule( modules[i] ).IsEnabled( e.Channel.Id ) ? "<:iconenabled:341251534522286080>" : "<:icondisabled:341251533754728458>" )} {modules[i]}\n";
                if (i < modules.Count() / 2 + 1)
                {
                    firstColumn += output;
                }
                else
                {
                    secondColumn += output;
                }
            }

            Utils.Embed.SetTitle($"Module Status for '{e.Channel.Name}'")
            .AddInlineField("Column 1", firstColumn)
            .AddInlineField("Column 2", secondColumn)
            .QueueToChannel(e.Channel);
        }
Exemplo n.º 4
0
 public IEvent SetAccessibility(EventAccessibility accessibility)
 {
     Accessibility = accessibility;
     return(this);
 }
Exemplo n.º 5
0
 public IEvent SetAccessibility(EventAccessibility accessibility)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 new public ICommandEvent SetAccessibility(EventAccessibility accessibility)
 {
     Accessibility = accessibility;
     return(this);
 }
Exemplo n.º 7
0
 ICommandEvent ICommandEvent.SetAccessibility(EventAccessibility accessibility)
 {
     throw new NotImplementedException();
 }