コード例 #1
0
ファイル: SocketModal.cs プロジェクト: sabihoshi/Discord.Net
        internal new static SocketModal Create(DiscordSocketClient client, ModelBase model, ISocketMessageChannel channel, SocketUser user)
        {
            var entity = new SocketModal(client, model, channel, user);

            entity.Update(model);
            return(entity);
        }
コード例 #2
0
        internal new static SocketInteraction Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel)
        {
            var entity = new SocketCommandBase(client, model, channel);

            entity.Update(model);
            return(entity);
        }
コード例 #3
0
        internal override void Update(Model model)
        {
            base.Update(model);

            if (model.Message.IsSpecified)
            {
                if (Message == null)
                {
                    SocketUser author = null;
                    if (Channel is SocketGuildChannel channel)
                    {
                        if (model.Message.Value.WebhookId.IsSpecified)
                        {
                            author = SocketWebhookUser.Create(channel.Guild, Discord.State, model.Message.Value.Author.Value, model.Message.Value.WebhookId.Value);
                        }
                        else if (model.Message.Value.Author.IsSpecified)
                        {
                            author = channel.Guild.GetUser(model.Message.Value.Author.Value.Id);
                        }
                    }
                    else if (model.Message.Value.Author.IsSpecified)
                    {
                        author = (Channel as SocketChannel).GetUser(model.Message.Value.Author.Value.Id);
                    }

                    Message = SocketUserMessage.Create(Discord, Discord.State, author, Channel, model.Message.Value);
                }
                else
                {
                    Message.Update(Discord.State, model.Message.Value);
                }
            }
        }
コード例 #4
0
ファイル: RestModal.cs プロジェクト: sabihoshi/Discord.Net
        internal RestModal(DiscordRestClient client, ModelBase model)
            : base(client, model.Id)
        {
            var dataModel = model.Data.IsSpecified
                ? (DataModel)model.Data.Value
                : null;

            Data = new RestModalData(dataModel);
        }
コード例 #5
0
        internal SocketMessageComponent(DiscordSocketClient client, Model model, ISocketMessageChannel channel)
            : base(client, model.Id, channel)
        {
            var dataModel = model.Data.IsSpecified
                ? (DataModel)model.Data.Value
                : null;

            Data = new SocketMessageComponentData(dataModel);
        }
コード例 #6
0
        internal RestMessageComponent(BaseDiscordClient client, Model model)
            : base(client, model.Id)
        {
            var dataModel = model.Data.IsSpecified
                ? (DataModel)model.Data.Value
                : null;

            Data = new RestMessageComponentData(dataModel);
        }
コード例 #7
0
ファイル: SocketModal.cs プロジェクト: sabihoshi/Discord.Net
        internal SocketModal(DiscordSocketClient client, ModelBase model, ISocketMessageChannel channel, SocketUser user)
            : base(client, model.Id, channel, user)
        {
            var dataModel = model.Data.IsSpecified
                ? (DataModel)model.Data.Value
                : null;

            Data = new SocketModalData(dataModel);
        }
コード例 #8
0
        internal override async Task UpdateAsync(DiscordRestClient client, Model model)
        {
            await base.UpdateAsync(client, model).ConfigureAwait(false);

            var dataModel = model.Data.IsSpecified
                ? (DataModel)model.Data.Value
                : null;

            Data = await RestMessageCommandData.CreateAsync(client, dataModel, Guild, Channel).ConfigureAwait(false);
        }
コード例 #9
0
        internal override void Update(Model model)
        {
            var data = model.Data.IsSpecified
                ? (DataModel)model.Data.Value
                : null;

            Data.Update(data);

            base.Update(model);
        }
コード例 #10
0
        internal override async Task UpdateAsync(DiscordRestClient discord, Model model, bool doApiCall)
        {
            await base.UpdateAsync(discord, model, doApiCall).ConfigureAwait(false);

            if (model.Message.IsSpecified && model.ChannelId.IsSpecified)
            {
                if (Message == null)
                {
                    Message = RestUserMessage.Create(Discord, Channel, User, model.Message.Value);
                }
            }
        }
コード例 #11
0
        internal RestAutocompleteInteraction(DiscordRestClient client, Model model)
            : base(client, model.Id)
        {
            var dataModel = model.Data.IsSpecified
                ? (DataModel)model.Data.Value
                : null;

            if (dataModel != null)
            {
                Data = new RestAutocompleteInteractionData(dataModel);
            }
        }
コード例 #12
0
        internal SocketAutocompleteInteraction(DiscordSocketClient client, Model model, ISocketMessageChannel channel)
            : base(client, model.Id, channel)
        {
            var dataModel = model.Data.IsSpecified
                ? (DataModel)model.Data.Value
                : null;

            if (dataModel != null)
            {
                Data = new SocketAutocompleteInteractionData(dataModel);
            }
        }
コード例 #13
0
        internal SocketMessageCommand(DiscordSocketClient client, Model model, ISocketMessageChannel channel, SocketUser user)
            : base(client, model, channel, user)
        {
            var dataModel = model.Data.IsSpecified
                ? (DataModel)model.Data.Value
                : null;

            ulong? guildId = null;
            if (Channel is SocketGuildChannel guildChannel)
                guildId = guildChannel.Guild.Id;

            Data = SocketMessageCommandData.Create(client, dataModel, model.Id, guildId);
        }
コード例 #14
0
        internal static SocketInteraction Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel)
        {
            if (model.Type == InteractionType.ApplicationCommand)
            {
                var dataModel = model.Data.IsSpecified
                    ? (DataModel)model.Data.Value
                    : null;

                if (dataModel == null)
                {
                    return(null);
                }

                return(dataModel.Type switch
                {
                    ApplicationCommandType.Slash => SocketSlashCommand.Create(client, model, channel),
                    ApplicationCommandType.Message => SocketMessageCommand.Create(client, model, channel),
                    ApplicationCommandType.User => SocketUserCommand.Create(client, model, channel),
                    _ => null
                });
コード例 #15
0
 internal RestMessageCommand(DiscordRestClient client, Model model)
     : base(client, model)
 {
 }
コード例 #16
0
        internal new static async Task <RestAutocompleteInteraction> CreateAsync(DiscordRestClient client, Model model)
        {
            var entity = new RestAutocompleteInteraction(client, model);
            await entity.UpdateAsync(client, model).ConfigureAwait(false);

            return(entity);
        }
コード例 #17
0
        internal static new async Task <RestPingInteraction> CreateAsync(DiscordRestClient client, Model model)
        {
            var entity = new RestPingInteraction(client, model.Id);
            await entity.UpdateAsync(client, model);

            return(entity);
        }
コード例 #18
0
 internal RestUserCommand(DiscordRestClient client, Model model)
     : base(client, model)
 {
 }
コード例 #19
0
 internal RestCommandBase(DiscordRestClient client, Model model)
     : base(client, model.Id)
 {
 }
コード例 #20
0
        internal new static SocketMessageComponent Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel)
        {
            var entity = new SocketMessageComponent(client, model, channel);

            entity.Update(model);
            return(entity);
        }
コード例 #21
0
 internal override async Task UpdateAsync(DiscordRestClient client, Model model)
 {
     await base.UpdateAsync(client, model).ConfigureAwait(false);
 }
コード例 #22
0
        internal static async Task <RestInteraction> CreateAsync(DiscordRestClient client, Model model)
        {
            if (model.Type == InteractionType.Ping)
            {
                return(await RestPingInteraction.CreateAsync(client, model));
            }

            if (model.Type == InteractionType.ApplicationCommand)
            {
                var dataModel = model.Data.IsSpecified
                    ? (DataModel)model.Data.Value
                    : null;

                if (dataModel == null)
                {
                    return(null);
                }

                return(dataModel.Type switch
                {
                    ApplicationCommandType.Slash => await RestSlashCommand.CreateAsync(client, model).ConfigureAwait(false),
                    ApplicationCommandType.Message => await RestMessageCommand.CreateAsync(client, model).ConfigureAwait(false),
                    ApplicationCommandType.User => await RestUserCommand.CreateAsync(client, model).ConfigureAwait(false),
                    _ => null
                });
コード例 #23
0
        internal new static async Task <RestMessageCommand> CreateAsync(DiscordRestClient client, Model model)
        {
            var entity = new RestMessageCommand(client, model);
            await entity.UpdateAsync(client, model).ConfigureAwait(false);

            return(entity);
        }
コード例 #24
0
 internal new static SocketInteraction Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel, SocketUser user)
 {
     var entity = new SocketMessageCommand(client, model, channel, user);
     entity.Update(model);
     return entity;
 }
コード例 #25
0
        internal new static SocketAutocompleteInteraction Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel, SocketUser user)
        {
            var entity = new SocketAutocompleteInteraction(client, model, channel, user);

            entity.Update(model);
            return(entity);
        }
コード例 #26
0
        internal new static async Task <RestCommandBase> CreateAsync(DiscordRestClient client, Model model, bool doApiCall)
        {
            var entity = new RestCommandBase(client, model);
            await entity.UpdateAsync(client, model, doApiCall).ConfigureAwait(false);

            return(entity);
        }
コード例 #27
0
ファイル: RestModal.cs プロジェクト: sabihoshi/Discord.Net
        internal new static async Task <RestModal> CreateAsync(DiscordRestClient client, ModelBase model, bool doApiCall)
        {
            var entity = new RestModal(client, model);
            await entity.UpdateAsync(client, model, doApiCall);

            return(entity);
        }