コード例 #1
0
        public static async Task <RestGuild> GetGuildAsync(BaseDiscordClient client,
                                                           ulong id, RequestOptions options)
        {
            var model = await client.ApiClient.GetGuildAsync(id, options).ConfigureAwait(false);

            if (model != null)
            {
                return(RestGuild.Create(client, model));
            }
            return(null);
        }
コード例 #2
0
        public static async Task <RestGuild> CreateGuildAsync(BaseDiscordClient client,
                                                              string name, IVoiceRegion region, Stream jpegIcon, RequestOptions options)
        {
            var args = new CreateGuildParams(name, region.Id);

            if (jpegIcon != null)
            {
                args.Icon = new API.Image(jpegIcon);
            }

            var model = await client.ApiClient.CreateGuildAsync(args, options).ConfigureAwait(false);

            return(RestGuild.Create(client, model));
        }
コード例 #3
0
        public static async Task <IReadOnlyCollection <RestGuild> > GetGuildsAsync(BaseDiscordClient client, bool withCounts, RequestOptions options)
        {
            IEnumerable <RestUserGuild> summaryModels = await GetGuildSummariesAsync(client, null, null, options).FlattenAsync().ConfigureAwait(false);

            ImmutableArray <RestGuild> .Builder guilds = ImmutableArray.CreateBuilder <RestGuild>();
            foreach (RestUserGuild summaryModel in summaryModels)
            {
                API.GuildJson guildModel = await client.ApiClient.GetGuildAsync(summaryModel.Id, withCounts).ConfigureAwait(false);

                if (guildModel != null)
                {
                    guilds.Add(RestGuild.Create(client, guildModel));
                }
            }
            return(guilds.ToImmutable());
        }
コード例 #4
0
ファイル: ClientHelper.cs プロジェクト: sdgr1997/Discord.Net
        public static async Task <IReadOnlyCollection <RestGuild> > GetGuildsAsync(BaseDiscordClient client, RequestOptions options)
        {
            var summaryModels = await GetGuildSummariesAsync(client, null, null, options).Flatten();

            var guilds = ImmutableArray.CreateBuilder <RestGuild>();

            foreach (var summaryModel in summaryModels)
            {
                var guildModel = await client.ApiClient.GetGuildAsync(summaryModel.Id).ConfigureAwait(false);

                if (guildModel != null)
                {
                    guilds.Add(RestGuild.Create(client, guildModel));
                }
            }
            return(guilds.ToImmutable());
        }