Esempio n. 1
0
        public static async Task ReloadMeta(BotCommand command)
        {
            await command.ReplyAsync(new SimpleMessage("Reloading meta..."));

            Stopwatch sw = new Stopwatch();

            sw.Start();
            command.Bot.Meta.Reload();
            sw.Stop();
            string output = string.Empty;

            foreach (KeyValuePair <string, Type> pair in command.Bot.Meta.KnownMetaTypes)
            {
                output += $" ({pair.Key}: {command.Bot.Meta.AllOf(pair.Value).Count()})";
            }
            await command.ReplyAsync(new SimpleMessage($"Succesfully reloaded meta{output} in {sw.ElapsedMilliseconds / 1000} seconds"));
        }
Esempio n. 2
0
 public static async Task GeneralSearchAll(BotCommand command)
 {
     await command.Bot.HandleSearch <IDenizenMetaType>(command.Arguments.Stringify((x) => x, " "), command, true);
 }
Esempio n. 3
0
 public static async Task SearchLanguages(BotCommand command)
 {
     await command.Bot.HandleSearch <DenizenLanguage>(command.Arguments.Stringify((x) => x, " "), command);
 }
Esempio n. 4
0
 public static async Task SearchActions(BotCommand command)
 {
     await command.Bot.HandleSearch <DenizenAction>(command.Arguments.Stringify((x) => x, " "), command);
 }
Esempio n. 5
0
 public static async Task SearchMechanisms(BotCommand command)
 {
     await command.Bot.HandleSearch <DenizenMechanism>(command.Arguments[0], command);
 }
Esempio n. 6
0
 public static async Task SearchTags(BotCommand command)
 {
     await command.Bot.HandleSearch <DenizenTag>(command.Arguments[0], command);
 }
Esempio n. 7
0
        public static async Task PageCommand(BotCommand command)
        {
            DiscordUserMessage message = command.Message as DiscordUserMessage;

            if (message == null)
            {
                return;
            }
            if (message.Discord.LastPageError.Remove(message.DiscordMessage.Channel.Id, out RestUserMessage error))
            {
                await error.DeleteAsync();
            }
            if (command.Bot.DiscordConnection.LastPaginated.TryGetValue(message.DiscordMessage.Channel.Id, out DiscordPaginatedMessage paginated))
            {
                if (command.Arguments.Length > 0)
                {
                    string arg = command.Arguments[0].ToLower();
                    if (arg[0] == 'n') // next
                    {
                        if (paginated.CurrentPage < paginated.PageCount - 1)
                        {
                            paginated.CurrentPage++;
                            await paginated.MessageToEdit.ModifyAsync((x) => x.Embed = paginated.GetPage(paginated.CurrentPage));
                        }
                    }
                    else if (arg[0] == 'p') // previous
                    {
                        if (paginated.CurrentPage > 0)
                        {
                            paginated.CurrentPage--;
                            await paginated.MessageToEdit.ModifyAsync((x) => x.Embed = paginated.GetPage(paginated.CurrentPage));
                        }
                    }
                    else if (arg[0] == 'l') // last
                    {
                        if (paginated.CurrentPage < paginated.PageCount - 1)
                        {
                            paginated.CurrentPage = paginated.PageCount - 1;
                            await paginated.MessageToEdit.ModifyAsync((x) => x.Embed = paginated.GetPage(paginated.CurrentPage));
                        }
                    }
                    else if (int.TryParse(arg, out int num))
                    {
                        if (num > paginated.PageCount)
                        {
                            num = paginated.PageCount;
                        }
                        num--;
                        if (num < 0)
                        {
                            num = 0;
                        }
                        if (paginated.CurrentPage != num)
                        {
                            paginated.CurrentPage = num;
                            await paginated.MessageToEdit.ModifyAsync((x) => x.Embed = paginated.GetPage(paginated.CurrentPage));
                        }
                    }
                    else
                    {
                        message.Discord.LastPageError[message.DiscordMessage.Channel.Id] = await message.DiscordMessage.Channel
                                                                                           .SendMessageAsync($"Invalid command '!{command.Alias} {command.Arguments[0]}' Syntax: !{command.Alias} #/next/prev/last");
                    }
                }
                else
                {
                    message.Discord.LastPageError[message.DiscordMessage.Channel.Id] = await message.DiscordMessage.Channel
                                                                                       .SendMessageAsync($"Invalid command '!{command.Alias}' Syntax: !{command.Alias} #/next/prev/last");
                }
                await message.DiscordMessage.DeleteAsync();
            }
            else
            {
                message.Discord.LastPageError[message.DiscordMessage.Channel.Id] = await message.DiscordMessage.Channel.SendMessageAsync("No recent paginated commands have been executed.");
            }
        }