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); }
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); }
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); }
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; }
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; }
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); }
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)); }
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); }
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)); }); }
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; }
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)); }
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)); }