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 static RestMessage Create(RestDiscordClient client, MessageModel model) { return(model.Type switch { MessageType.Default => new RestUserMessage(client, model), _ => new RestSystemMessage(client, model), });
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 RestRequestEnumerator(RestDiscordClient client, int pageSize, int remaining, RestRequestOptions options) { Client = client; PageSize = pageSize; Remaining = remaining; _options = options; }
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); }
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 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, });
public RestMembersRequestEnumerator(RestDiscordClient client, Snowflake guildId, int limit, Snowflake?startFromId, RestRequestOptions options) : base(client, 1000, limit, options) { _guildId = guildId; _startFromId = startFromId; }
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 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; }
public RestGuildsRequestEnumerator(RestDiscordClient client, int limit, RetrievalDirection direction, Snowflake?startFromId, RestRequestOptions options) : base(client, 100, limit, options) { _direction = direction; _startFromId = startFromId; }
internal RestUserMessage(RestDiscordClient client, MessageModel model) : base(client, model) { IsTextToSpeech = model.Tts.Value; Nonce = model.Nonce.GetValueOrDefault(); WebhookId = model.WebhookId.GetValueOrDefault(); 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 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 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; }
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 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 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 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); }
internal RestIntegration(RestDiscordClient client, IntegrationModel model) : base(client, model.Id) { Name = model.Name; Type = model.Type; IsEnabled = model.Enabled; IsSyncing = model.Syncing; RoleId = model.RoleId; User = new RestUser(client, model.User); Account = new IntegrationAccount(model.Account); SyncedAt = model.SyncedAt; Update(model); }
internal static RestChannel Create(RestDiscordClient client, ChannelModel model) { switch (model.Type.Value) { case ChannelType.Text: case ChannelType.Voice: case ChannelType.Category: case ChannelType.News: return(RestGuildChannel.Create(client, model)); case ChannelType.Dm: case ChannelType.Group: return(RestPrivateChannel.Create(client, model)); default: return(null); } }
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 static new RestGuildChannel Create(RestDiscordClient client, ChannelModel model) { switch (model.Type.Value) { case ChannelType.Text: case ChannelType.News: case ChannelType.Store: return(new RestTextChannel(client, model)); case ChannelType.Voice: return(new RestVoiceChannel(client, model)); case ChannelType.Category: return(new RestCategoryChannel(client, model)); default: return(new RestUnknownGuildChannel(client, model)); } }
internal RestUnknownGuildChannel(RestDiscordClient client, ChannelModel model) : base(client, model) { Type = (byte)model.Type.Value; }
internal RestTextChannel(RestDiscordClient client, ChannelModel model) : base(client, model) { Update(model); }
internal RestUser(RestDiscordClient client, UserModel model) : base(client, model.Id) { IsBot = model.Bot; Update(model); }
internal RestPrivateChannel(RestDiscordClient client, ChannelModel model) : base(client, model) { }
internal RestMessage(RestDiscordClient client, MessageModel model) : base(client, model.Id) { ChannelId = model.ChannelId; GuildId = model.GuildId; Author = new RestUser(client, model.Author.Value); }