Beispiel #1
0
        public async Task <ActionResult> OnGetAsync(string id)
        {
            if (Request.Query.ContainsKey("page") && int.TryParse(Request.Query["page"].FirstOrDefault(), out var page))
            {
                PaginationPage = page;
            }
            if (Request.Query.ContainsKey("pageSize") && int.TryParse(Request.Query["pageSize"].FirstOrDefault(), out var pageSize))
            {
                PageSize = pageSize;
            }

            var result = await MakeResult(id);

            ViewData["ActivePage"] = PanelNavigation.Members(GuildManage);
            return(result);
        }
Beispiel #2
0
        public virtual async Task <ActionResult> MakeResult([FromQuery] string id)
        {
            BotContext = new BotContext();
            RestClient = await HttpContext.GetRestClient();

            BotClient = kuvuBot.Program.Client;

            if (ulong.TryParse(id, out var guildId))
            {
                Guild = BotContext.Guilds.FirstOrDefault(x => x.GuildId == guildId);
                if (Guild != null)
                {
                    DiscordGuild = await BotClient.GetGuildAsync(Guild.GuildId);

                    RestGuild = RestClient.Guilds.Values.FirstOrDefault(x => x.Id == Guild.GuildId);
                }
                if (Guild == null || DiscordGuild == null || RestGuild == null || !RestGuild.Permissions.HasValue || !RestGuild.Permissions.Value.HasPermission(Permissions.ManageGuild))
                {
                    return(Unauthorized());
                }
            }
            else if (id == "global")
            {
                GlobalUser = await RestClient.CurrentUser.GetGlobalUser(BotContext);

                if (GlobalUser.GlobalRank >= KuvuGlobalRank.Admin)
                {
                    Global = true;
                }
                else
                {
                    return(Unauthorized());
                }
            }

            GuildManage = PanelNavigation.GuildManage(id, DiscordGuild.Name);
            ViewData.AddToSidebar(new[]
            {
                new SidebarHeader("Guild management"),
                new SidebarItem("Information", "fas fa-info-circle", "/Panel/Guild/Information", GuildManage),
                new SidebarItem("Members", "fas fa-users", "/Panel/Guild/Members", page: PanelNavigation.Members(GuildManage)),
                new SidebarItem("Configuration", "fas fa-cogs", "/Panel/Guild/Configuration", page: PanelNavigation.Configuration(GuildManage)),
            });
            return(Page());
        }