Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 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);
 }
Esempio n. 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);
        }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 6
0
 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);
 }
Esempio n. 7
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));
 }
Esempio n. 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);
        }
Esempio n. 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));
            });
        }
Esempio n. 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;
        }
Esempio n. 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));
 }
Esempio n. 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));
 }