internal static RestInternalWebhook Create(DiscordWebhookClient client, Model model)
        {
            RestInternalWebhook entity = new RestInternalWebhook(client, model);

            entity.Update(model);
            return(entity);
        }
 internal RestInternalWebhook(DiscordWebhookClient apiClient, Model model)
 {
     _client   = apiClient;
     Id        = model.Id;
     ChannelId = model.Id;
     Token     = model.Token;
 }
示例#3
0
        internal static RestWebhook Create(BaseDiscordClient discord, IGuild guild, Model model)
        {
            RestWebhook entity = new RestWebhook(discord, guild, model.Id, model.Token, model.ChannelId);

            entity.Update(model);
            return(entity);
        }
示例#4
0
        /// <exception cref="InvalidOperationException">Could not find a webhook with the supplied credentials.</exception>
        public static async Task <RestInternalWebhook> GetWebhookAsync(DiscordWebhookClient client, ulong webhookId)
        {
            WebhookModel model = await client.ApiClient.GetWebhookAsync(webhookId).ConfigureAwait(false);

            if (model == null)
            {
                throw new InvalidOperationException("Could not find a webhook with the supplied credentials.");
            }
            return(RestInternalWebhook.Create(client, model));
        }
示例#5
0
 internal void Update(Model model)
 {
     if (ChannelId != model.ChannelId)
     {
         ChannelId = model.ChannelId;
     }
     if (model.Avatar.IsSpecified)
     {
         AvatarId = model.Avatar.Value;
     }
     if (model.Creator.IsSpecified)
     {
         Creator = RestUser.Create(Discord, model.Creator.Value);
     }
     if (model.GuildId.IsSpecified)
     {
         GuildId = model.GuildId.Value;
     }
     if (model.Name.IsSpecified)
     {
         Name = model.Name.Value;
     }
     if (model.SourceGuild.IsSpecified)
     {
         SourceGuild = new WebhookFollowGuild
         {
             Id   = model.SourceGuild.Value.Id,
             Icon = model.SourceGuild.Value.Icon,
             Name = model.SourceGuild.Value.Name
         }
     }
     ;
     if (model.SourceChannel.IsSpecified)
     {
         SourceChannel = new WebhookFollowChannel
         {
             Id   = model.SourceChannel.Value.Id,
             Name = model.SourceChannel.Value.Name
         }
     }
     ;
 }
        public async Task ModifyAsync(Action <WebhookProperties> func, RequestOptions options = null)
        {
            Model model = await WebhookClientHelper.ModifyAsync(_client, func, options).ConfigureAwait(false);

            Update(model);
        }
示例#7
0
        /// <inheritdoc />
        public async Task UpdateAsync(RequestOptions options = null)
        {
            Model model = await Discord.ApiClient.GetWebhookAsync(Id, options).ConfigureAwait(false);

            Update(model);
        }