示例#1
0
文件: RestRole.cs 项目: Miimik/test
 internal RestRole(RestDiscordClient client, Snowflake guildId, RoleModel model) : base(client, model.Id)
 {
     GuildId = guildId;
     Guild   = RestFetchable.Create(this, (@this, options) =>
                                    @this.Client.GetGuildAsync(@this.GuildId, options));
     Update(model);
 }
示例#2
0
文件: RestWidget.cs 项目: Miimik/test
 internal RestWidget(RestDiscordClient client, WidgetModel model, Snowflake guildId) : base(client)
 {
     GuildId = guildId;
     Guild   = RestFetchable.Create(this, (@this, options) =>
                                    @this.Client.GetGuildAsync(@this.GuildId, options));
     Update(model);
 }
示例#3
0
        internal RestApplication(RestDiscordClient client, ApplicationModel model) : base(client, model.Id)
        {
            GuildId = model.GuildId;
            Guild   = RestFetchable.Create(this, (@this, options) =>
                                           @this.Client.GetGuildAsync(@this.GuildId, options));

            Update(model);
        }
示例#4
0
 internal RestBan(RestDiscordClient client, Snowflake guildId, BanModel model) : base(client)
 {
     GuildId = guildId;
     Guild   = RestFetchable.Create(this, (@this, options) =>
                                    @this.Client.GetGuildAsync(@this.GuildId, options));
     User   = new RestUser(client, model.User);
     Reason = model.Reason;
 }
示例#5
0
 internal RestOverwrite(RestDiscordClient client, Snowflake channelId, OverwriteModel model) : base(client)
 {
     ChannelId = channelId;
     Channel   = RestFetchable.Create(this, (@this, options) =>
                                      @this.Client.GetChannelAsync <RestGuildChannel>(@this.ChannelId, options));
     TargetId    = model.Id;
     Permissions = (model.Allow, model.Deny);
     TargetType  = model.Type;
 }
示例#6
0
 internal RestWebhook(RestDiscordClient client, WebhookModel model) : base(client, model.Id)
 {
     Type    = model.Type;
     Token   = model.Token;
     GuildId = model.GuildId;
     Guild   = RestFetchable.Create(this, (@this, options) =>
                                    @this.Client.GetGuildAsync(@this.GuildId, options));
     Channel = RestFetchable.Create(this, (@this, options) =>
                                    @this.Client.GetChannelAsync <RestTextChannel>(@this.ChannelId, options));
 }
示例#7
0
文件: RestMember.cs 项目: Miimik/test
 internal RestMember(RestDiscordClient client, Snowflake guildId, MemberModel model) : base(client, model.User)
 {
     GuildId = guildId;
     Guild   = RestFetchable.Create(this, (@this, options) =>
                                    @this.Client.GetGuildAsync(@this.GuildId, options));
     JoinedAt   = model.JoinedAt;
     IsMuted    = model.Mute;
     IsDeafened = model.Deaf;
     Update(model);
 }
示例#8
0
        internal RestGuildEmoji(RestDiscordClient client, Snowflake guildId, EmojiModel model) : base(client, model.Id.Value)
        {
            GuildId = guildId;
            Guild   = RestFetchable.Create(this, (@this, options) =>
                                           @this.Client.GetGuildAsync(@this.GuildId, options));
            RequiresColons = model.RequireColons;
            IsManaged      = model.Managed;
            IsAnimated     = model.Animated;

            Update(model);
        }
示例#9
0
        private RestDiscordClient(TokenType?optionalTokenType, string token, RestDiscordClientConfiguration configuration = null)
        {
            ApiClient   = new RestDiscordApiClient(optionalTokenType, token, configuration ?? new RestDiscordClientConfiguration());
            CurrentUser = RestFetchable.Create(this, async(@this, options) =>
            {
                var model = await @this.ApiClient.GetCurrentUserAsync(options).ConfigureAwait(false);
                return(new RestCurrentUser(@this, model));
            });
            CurrentApplication = RestFetchable.Create(this, async(@this, options) =>
            {
                //if (TokenType != TokenType.Bot)
                //    throw new InvalidOperationException("Cannot download the current application without a bot authorization token.");

                var model = await @this.ApiClient.GetCurrentApplicationInformationAsync(options).ConfigureAwait(false);
                return(new RestApplication(@this, model));
            });
        }
示例#10
0
        internal RestPreview(RestDiscordClient client, PreviewModel model) : base(client)
        {
            GuildId = model.Id;
            Guild   = RestFetchable.Create(this, (@this, options) =>
                                           @this.Client.GetGuildAsync(@this.GuildId, options));
            Name                = model.Name;
            Description         = model.Description;
            IconHash            = model.Icon;
            SplashHash          = model.Splash;
            DiscoverySplashHash = model.DiscoverySplash;
            Features            = model.Features.ReadOnly();

            // TODO: fetchable tying
            Emojis = model.Emojis.ToReadOnlyDictionary((x, _) => new Snowflake(x.Id.Value), (x, @this) => new RestGuildEmoji(@this.Client, @this.GuildId, x), this);

            ApproximateOnlineMemberCount = model.ApproximatePresenceCount;
            ApproximateMemberCount       = model.ApproximateMemberCount;
        }
示例#11
0
 internal RestGuildChannel(RestDiscordClient client, ChannelModel model) : base(client, model)
 {
     GuildId = model.GuildId.Value;
     Guild   = RestFetchable.Create(this, (@this, options) =>
                                    @this.Client.GetGuildAsync(@this.GuildId, options));
 }
示例#12
0
 internal RestGuildVoiceRegion(RestDiscordClient client, Snowflake guildId, VoiceRegionModel model) : base(client, model)
 {
     GuildId = guildId;
     Guild   = RestFetchable.Create(this, (@this, options) =>
                                    @this.Client.GetGuildAsync(@this.GuildId, options));
 }