Ejemplo n.º 1
0
        internal static RestInternalWebhook Create(DiscordWebhookClient client, Model model)
        {
            RestInternalWebhook entity = new RestInternalWebhook(client, model);

            entity.Update(model);
            return(entity);
        }
Ejemplo n.º 2
0
 internal RestInternalWebhook(DiscordWebhookClient apiClient, Model model)
 {
     _client   = apiClient;
     Id        = model.Id;
     ChannelId = model.Id;
     Token     = model.Token;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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
         }
     }
     ;
 }
Ejemplo n.º 6
0
        public async Task ModifyAsync(Action <WebhookProperties> func, RequestOptions options = null)
        {
            Model model = await WebhookClientHelper.ModifyAsync(_client, func, options).ConfigureAwait(false);

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

            Update(model);
        }