示例#1
0
        public async Task <IActionResult> GetGuild([FromRoute] ulong guildId)
        {
            var client = await HttpContext.GetBotClient();

            RestGuildUser currentUser = null;

            try
            {
                currentUser = await client.GetGuildUserAsync(guildId, HttpContext.GetUserId());
            }
            catch (HttpException)
            {
                return(StatusCode(412, "Bot not in guild"));
            }
            if (currentUser == null)
            {
                return(StatusCode(403, "Unauthorized"));
            }

            var res = await client.GetGuildAsync(guildId);

            var guild = new GuildView
            {
                ImageUrl = res.IconUrl,
                Id       = res.Id.ToString(),
                Name     = res.Name
            };

            return(Ok(guild));
        }
示例#2
0
        private void SelectGuild()
        {
            var guilds = _miunie.Impersonation.GetAvailableGuilds();
            var menu   = new ConsoleMenu <GuildView>(guilds, g => g.Name);

            menu.SetTitle(ConsoleStrings.SELECT_GUILD);
            _currentGuild = menu.Present();
        }