Exemplo n.º 1
0
 internal static RestMessage Create(RestDiscordClient client, MessageModel model)
 {
     return(model.Type switch
     {
         MessageType.Default => new RestUserMessage(client, model),
         _ => new RestSystemMessage(client, model),
     });
Exemplo n.º 2
0
 internal RestUserMessage(RestDiscordClient client, MessageModel model) : base(client, model)
 {
     IsTextToSpeech = model.Tts.Value;
     Nonce          = model.Nonce.GetValueOrDefault();
     WebhookId      = model.WebhookId.GetValueOrDefault();
     Update(model);
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 internal RestConnectedAccount(RestDiscordClient client, ConnectedAccountModel model) : base(client)
 {
     Id         = model.Id;
     Name       = model.Name;
     Type       = model.Type;
     IsVerified = model.Verified;
 }
Exemplo n.º 5
0
 public TypingRepeater(RestDiscordClient client, IMessageChannel channel) : base(
         cancellationToken => client.TriggerTypingAsync(channel.Id, new RestRequestOptionsBuilder()
                                                        .WithCancellationToken(cancellationToken)
                                                        .Build()),
         TimeSpan.FromSeconds(5.5))
 {
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
0
        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;
        }
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
 internal RestRequestEnumerator(RestDiscordClient client, int pageSize, int remaining, RestRequestOptions options)
 {
     Client    = client;
     PageSize  = pageSize;
     Remaining = remaining;
     _options  = options;
 }
Exemplo n.º 11
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);
 }
Exemplo n.º 12
0
 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);
 }
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 14
0
 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)));
 }
Exemplo n.º 15
0
 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;
 }
Exemplo n.º 16
0
 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,
     });
Exemplo n.º 17
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;
 }
 public RestMembersRequestEnumerator(RestDiscordClient client,
                                     Snowflake guildId, int limit, Snowflake?startFromId,
                                     RestRequestOptions options)
     : base(client, 1000, limit, options)
 {
     _guildId     = guildId;
     _startFromId = startFromId;
 }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
0
 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);
 }
Exemplo n.º 21
0
 public RestGuildsRequestEnumerator(RestDiscordClient client,
                                    int limit, RetrievalDirection direction, Snowflake?startFromId,
                                    RestRequestOptions options)
     : base(client, 100, limit, options)
 {
     _direction   = direction;
     _startFromId = startFromId;
 }
Exemplo n.º 22
0
 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);
 }
Exemplo n.º 23
0
 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;
 }
Exemplo n.º 24
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;
 }
Exemplo n.º 25
0
 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;
 }
Exemplo n.º 27
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);
 }
Exemplo n.º 28
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));
 }
        public RestBulkDeleteMessagesRequestEnumerator(RestDiscordClient client,
                                                       Snowflake channelId, Snowflake[] messageIds,
                                                       RestRequestOptions options)
            : base(client, 100, messageIds.Length, options)
        {
            _channelId  = channelId;
            _messageIds = messageIds;

            _offset = 0;
        }
Exemplo n.º 30
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);
        }