Ejemplo 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);
 }
Ejemplo n.º 2
0
 internal static RestMessage Create(RestDiscordClient client, MessageModel model)
 {
     return(model.Type switch
     {
         MessageType.Default => new RestUserMessage(client, model),
         _ => new RestSystemMessage(client, model),
     });
Ejemplo n.º 3
0
 public TypingRepeater(RestDiscordClient client, IMessageChannel channel) : base(
         cancellationToken => client.TriggerTypingAsync(channel.Id, new RestRequestOptionsBuilder()
                                                        .WithCancellationToken(cancellationToken)
                                                        .Build()),
         TimeSpan.FromSeconds(5.5))
 {
 }
Ejemplo n.º 4
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);
 }
Ejemplo n.º 5
0
 internal RestRequestEnumerator(RestDiscordClient client, int pageSize, int remaining, RestRequestOptions options)
 {
     Client    = client;
     PageSize  = pageSize;
     Remaining = remaining;
     _options  = options;
 }
Ejemplo n.º 6
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);
 }
Ejemplo n.º 7
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;
 }
Ejemplo n.º 8
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,
     });
Ejemplo n.º 9
0
 public RestMembersRequestEnumerator(RestDiscordClient client,
                                     Snowflake guildId, int limit, Snowflake?startFromId,
                                     RestRequestOptions options)
     : base(client, 1000, limit, options)
 {
     _guildId     = guildId;
     _startFromId = startFromId;
 }
Ejemplo n.º 10
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);
 }
Ejemplo n.º 11
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;
 }
Ejemplo n.º 12
0
 public RestGuildsRequestEnumerator(RestDiscordClient client,
                                    int limit, RetrievalDirection direction, Snowflake?startFromId,
                                    RestRequestOptions options)
     : base(client, 100, limit, options)
 {
     _direction   = direction;
     _startFromId = startFromId;
 }
Ejemplo n.º 13
0
        internal RestUserMessage(RestDiscordClient client, MessageModel model) : base(client, model)
        {
            IsTextToSpeech = model.Tts.Value;
            Nonce          = model.Nonce.GetValueOrDefault();
            WebhookId      = model.WebhookId.GetValueOrDefault();

            Update(model);
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
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;
 }
Ejemplo n.º 16
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;
 }
Ejemplo n.º 17
0
 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;
 }
Ejemplo n.º 18
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;
        }
Ejemplo n.º 20
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);
 }
Ejemplo n.º 21
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);
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
        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);
            }
        }
Ejemplo n.º 24
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;
        }
Ejemplo n.º 25
0
        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));
            }
        }
Ejemplo n.º 26
0
 internal RestUnknownGuildChannel(RestDiscordClient client, ChannelModel model) : base(client, model)
 {
     Type = (byte)model.Type.Value;
 }
Ejemplo n.º 27
0
 internal RestTextChannel(RestDiscordClient client, ChannelModel model) : base(client, model)
 {
     Update(model);
 }
Ejemplo n.º 28
0
 internal RestUser(RestDiscordClient client, UserModel model) : base(client, model.Id)
 {
     IsBot = model.Bot;
     Update(model);
 }
Ejemplo n.º 29
0
 internal RestPrivateChannel(RestDiscordClient client, ChannelModel model) : base(client, model)
 {
 }
Ejemplo n.º 30
0
 internal RestMessage(RestDiscordClient client, MessageModel model) : base(client, model.Id)
 {
     ChannelId = model.ChannelId;
     GuildId   = model.GuildId;
     Author    = new RestUser(client, model.Author.Value);
 }