internal static RestMessage Create(RestDiscordClient client, MessageModel model) { return(model.Type switch { MessageType.Default => new RestUserMessage(client, model), _ => new RestSystemMessage(client, model), });
internal RestUserMessage(RestDiscordClient client, MessageModel model) : base(client, model) { IsTextToSpeech = model.Tts.Value; Nonce = model.Nonce.GetValueOrDefault(); WebhookId = model.WebhookId.GetValueOrDefault(); Update(model); }
internal RestWebhook(RestDiscordClient client, WebhookModel model) : base(client, model.Id) { Token = model.Token; GuildId = model.GuildId; Guild = new RestDownloadable <RestGuild>(options => Client.GetGuildAsync(GuildId, options)); Channel = new RestDownloadable <RestTextChannel>(async options => await client.GetChannelAsync(ChannelId, options).ConfigureAwait(false) as RestTextChannel); }
internal RestConnectedAccount(RestDiscordClient client, ConnectedAccountModel model) : base(client) { Id = model.Id; Name = model.Name; Type = model.Type; IsVerified = model.Verified; }
public TypingRepeater(RestDiscordClient client, IMessageChannel channel) : base( cancellationToken => client.TriggerTypingAsync(channel.Id, new RestRequestOptionsBuilder() .WithCancellationToken(cancellationToken) .Build()), TimeSpan.FromSeconds(5.5)) { }
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) { Name = model.Name; IconHash = model.Icon; Description = model.Description; RpcOrigins = RpcOrigins != null ? model.RpcOrigins.ToImmutableArray() : ImmutableArray <string> .Empty; IsBotPublic = model.BotPublic; BotRequiresCodeGrant = model.BotRequireCodeGrant; if (model.Owner != null) { Owner = new RestUser(Client, model.Owner); } Summary = model.Summary; VerifyKey = model.VerifyKey; GuildId = model.GuildId; Guild = new RestDownloadable <RestGuild>(options => Client.GetGuildAsync(GuildId, options)); PrimarySkuId = model.PrimarySkuId; SlugUrl = model.Slug; CoverImageHash = model.CoverImage; }
internal RestBan(RestDiscordClient client, BanModel model, Snowflake guildId) : base(client) { GuildId = guildId; Guild = new RestDownloadable <RestGuild>(options => Client.GetGuildAsync(guildId, options)); User = new RestUser(client, model.User); Reason = model.Reason; }
internal RestMessage(RestDiscordClient client, MessageModel model) : base(client, model.Id) { ChannelId = model.ChannelId; GuildId = model.GuildId; Author = new RestUser(client, model.Author.Value); Timestamp = model.Timestamp.Value; }
internal RestRequestEnumerator(RestDiscordClient client, int pageSize, int remaining, RestRequestOptions options) { Client = client; PageSize = pageSize; Remaining = remaining; _options = options; }
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 RestTeam(RestDiscordClient client, TeamModel model) : base(client, model.Id) { Name = model.Name; IconHash = model.Icon; OwnerId = model.OwnerUserId; Members = model.Members.ToReadOnlyDictionary( (x, _) => new Snowflake(x.User.Id), (x, @this) => new RestTeamMember(@this, x), this); }
internal RestOverwrite(RestDiscordClient client, OverwriteModel model, Snowflake channelId) : base(client) { ChannelId = channelId; Channel = new RestDownloadable <RestGuildChannel>(options => Client.GetChannelAsync <RestGuildChannel>(channelId, options)); TargetId = model.Id; Permissions = (model.Allow, model.Deny); TargetType = model.Type; }
internal RestTeam(RestDiscordClient client, TeamModel model) : base(client, model.Id) { Name = model.Name; IconHash = model.Icon; OwnerId = model.OwnerUserId; Members = new ReadOnlyDictionary <Snowflake, RestTeamMember>( model.Members.ToDictionary(x => new Snowflake(x.Id), x => new RestTeamMember(client, x))); }
internal RestPartialGuild(RestDiscordClient client, GuildModel model) : base(client, model.Id) { Name = model.Name.Value; IconHash = model.Icon.Value; Features = model.Features.Value.ReadOnly(); IsOwner = model.Owner.Value; Permissions = model.Permissions.Value; }
internal new static RestPrivateChannel Create(RestDiscordClient client, ChannelModel model) { return(model.Type.Value switch { ChannelType.Dm => new RestDmChannel(client, model), ChannelType.Group => new RestGroupChannel(client, model), _ => null, });
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; }
public RestMembersRequestEnumerator(RestDiscordClient client, Snowflake guildId, int limit, Snowflake?startFromId, RestRequestOptions options) : base(client, 1000, limit, options) { _guildId = guildId; _startFromId = startFromId; }
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 RestInvite(RestDiscordClient client, InviteModel model) : base(client) { Code = model.Code; Guild = new RestGuild(client, model.Guild); model.Channel.GuildId = model.Guild.Id; Channel = RestChannel.Create(client, model.Channel); Update(model); }
public RestGuildsRequestEnumerator(RestDiscordClient client, int limit, RetrievalDirection direction, Snowflake?startFromId, RestRequestOptions options) : base(client, 100, limit, options) { _direction = direction; _startFromId = startFromId; }
internal RestMember(RestDiscordClient client, MemberModel model, Snowflake guildId) : base(client, model.User) { GuildId = guildId; Guild = new RestDownloadable <RestGuild>(options => Client.GetGuildAsync(GuildId, options)); JoinedAt = model.JoinedAt; IsMuted = model.Mute; IsDeafened = model.Deaf; Update(model); }
internal RestVoiceRegion(RestDiscordClient client, VoiceRegionModel model) : base(client) { Id = model.Id; Name = model.Name; IsVip = model.Vip; IsOptimal = model.Optimal; IsDeprecated = model.Deprecated; IsCustom = model.Custom; }
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 RestGuildEmoji(RestDiscordClient client, EmojiModel model, ulong guildId) : base(client, model.Id.Value) { GuildId = guildId; Guild = new RestDownloadable <RestGuild>(options => Client.GetGuildAsync(GuildId, options)); RequiresColons = model.RequireColons; IsManaged = model.Managed; IsAnimated = model.Animated; Update(model); }
public RestReactionsRequestEnumerator(RestDiscordClient client, Snowflake channelId, Snowflake messageId, IEmoji emoji, int limit, Snowflake?startFromId, RestRequestOptions options) : base(client, 100, limit, options) { _channelId = channelId; _messageId = messageId; _emoji = emoji; _startFromId = startFromId; }
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)); }
public RestBulkDeleteMessagesRequestEnumerator(RestDiscordClient client, Snowflake channelId, Snowflake[] messageIds, RestRequestOptions options) : base(client, 100, messageIds.Length, options) { _channelId = channelId; _messageIds = messageIds; _offset = 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); }