public async Task AddImage(string path, string type, string creator, string source)
        {
            var runner = Database.GetUser(Context.User.Id);

            if (runner.BotPermissions < BotPermissionLevel.BotAdministrator)
            {
                await ReplyAsync(MessagingUtils.GetNoPermissionsString());

                return;
            }
            if (creator == "null")
            {
                creator = string.Empty;
            }
            if (source == "null")
            {
                source = string.Empty;
            }
            var imageType = type.ToLower() switch
            {
                "anime" => ImageType.Anime,
                "catgirls" => ImageType.Catgirls,
                "all" => ImageType.All,
                _ => ImageType.All,
            };

            Database.CreateImage(path, imageType, new CuteImage {
                Creator = creator, Path = path, ImageSource = source
            });
        }
        public async Task DatabaseEvaluateSql(string sql)
        {
            var runner = Database.GetUser(Context.User.Id);

            if (runner.BotPermissions < BotPermissionLevel.BotAdministrator)
            {
                await ReplyAsync(MessagingUtils.GetNoPermissionsString());

                return;
            }
            Database.ExecuteSql(sql);
        }
Beispiel #3
0
        public async Task ManageServer()
        {
            if (!PermissionsUtils.CheckForPermissions(Context, GuildPermission.Administrator))
            {
                await ReplyAsync(MessagingUtils.GetNoPermissionsString());

                return;
            }
            var server    = Database.GetServer(Context.Guild.Id);
            var navigator = ManagementService.CreateBotModerationNavigator(server, Context.Guild);

            await ReplyAsync(embed : navigator.GetHomePage(Context).Build());

            while (true)
            {
                var response = await NextMessageAsync(timeout : new TimeSpan(0, 0, 0, 0, -1)); // Infinite timeout

                string responseString = response.ToString().ToLower();
                if (responseString == "1")
                {
                    navigator.Navigate(ServerProperty.AllowsPotentialNSFW);
                }
                else if (responseString == "2")
                {
                    navigator.Navigate(ServerProperty.LoggingChannel);
                }
                else if (responseString == "3")
                {
                    navigator.Navigate(ServerProperty.SystemChannel);
                }
                else if (responseString == "quit")
                {
                    return;
                }
                else
                {
                    await ReplyAsync("That's not a valid property. If you need to exit, type 'quit'.");

                    continue;
                }
                var x = await ReplyAsync(embed : navigator.GetFormattedCurrentPage(Context.User).Build());

                while (true)
                {
                    var pageResponse = await NextMessageAsync(timeout : new TimeSpan(0, 0, 0, 0, -1)); // Infinite timeout

                    string pageResponseString = pageResponse.ToString().ToLower();
                    if (pageResponseString == "quit")
                    {
                        return;
                    }
                    if (pageResponseString == "back")
                    {
                        await ReplyAsync(embed : navigator.GetHomePage(Context).Build());

                        break;
                    }
                    if (navigator.Set(pageResponseString.TrimStart("set".ToCharArray()).TrimStart()))
                    {
                        Database.WriteServer(navigator.Server);
                        await ReplyAsync(embed : navigator.GetHomePage(Context).Build());

                        break;
                    }
                    else
                    {
                        await ReplyAsync("Your input wasn't valid.");

                        continue;
                    }
                }
            }
        }