Пример #1
0
        /// <summary>
        /// Queries guilds in Server Discovery
        /// </summary>
        /// <param name="query">The name to search for</param>
        /// <param name="limit">Max amount of guilds to receive</param>
        /// <param name="offset">The offset in the list</param>
        public static IReadOnlyList <DiscoveryGuild> QueryGuilds(this DiscordClient client, GuildQueryOptions options = null)
        {
            if (options == null)
            {
                options = new GuildQueryOptions();
            }

            List <DiscoveryGuild> guilds = new List <DiscoveryGuild>();

            string query = $"?limit={options.Limit}&offset={options.Offset}";

            if (options.Query != null)
            {
                query += "&query=" + options.Query;
            }

            if (options.Category.HasValue)
            {
                query += "&categories=" + (int)options.Category;
            }


            foreach (var lol in client.HttpClient.Get($"/discoverable-guilds" + query).Deserialize <JObject>().Value <JArray>("guilds"))
            {
                guilds.Add(lol.ToObject <DiscoveryGuild>());
            }

            return(guilds.SetClientsInList(client));
        }
Пример #2
0
        /// <summary>
        /// Queries guilds in Server Discovery
        /// </summary>
        public static GuildQueryResult QueryGuilds(this DiscordClient client, GuildQueryOptions options = null)
        {
            if (options == null)
            {
                options = new GuildQueryOptions();
            }

            string query = $"?limit={options.Limit}&offset={options.Offset}";

            if (options.Query != null)
            {
                query += "&query=" + options.Query;
            }

            if (options.Category.HasValue)
            {
                query += "&categories=" + (int)options.Category;
            }

            return(client.HttpClient.Get($"/discoverable-guilds" + query).Deserialize <GuildQueryResult>().SetClient(client));
        }
Пример #3
0
 /// <summary>
 /// Queries guilds in Server Discovery
 /// </summary>
 public static GuildQueryResult QueryGuilds(this DiscordClient client, GuildQueryOptions options = null)
 {
     return(client.QueryGuildsAsync(options).GetAwaiter().GetResult());
 }