Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Update Webhook Channel ID if channel ID has changed. #1791

Merged
merged 1 commit into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public class RestWebhook : RestEntity<ulong>, IWebhook, IUpdateable
internal IGuild Guild { get; private set; }
internal ITextChannel Channel { get; private set; }

/// <inheritdoc />
public ulong ChannelId { get; }
/// <inheritdoc />
public string Token { get; }

/// <inheritdoc />
public ulong ChannelId { get; private set; }
/// <inheritdoc />
public string Name { get; private set; }
/// <inheritdoc />
Expand Down Expand Up @@ -56,6 +56,8 @@ internal static RestWebhook Create(BaseDiscordClient discord, ITextChannel chann

internal void Update(Model model)
{
if (ChannelId != model.ChannelId)
ChannelId = model.ChannelId;
if (model.Avatar.IsSpecified)
AvatarId = model.Avatar.Value;
if (model.Creator.IsSpecified)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Model = Discord.API.Webhook;
Expand All @@ -11,9 +11,9 @@ internal class RestInternalWebhook : IWebhook
private DiscordWebhookClient _client;

public ulong Id { get; }
public ulong ChannelId { get; }
public string Token { get; }

public ulong ChannelId { get; private set; }
public string Name { get; private set; }
public string AvatarId { get; private set; }
public ulong? GuildId { get; private set; }
Expand All @@ -36,6 +36,8 @@ internal static RestInternalWebhook Create(DiscordWebhookClient client, Model mo

internal void Update(Model model)
{
if (ChannelId != model.ChannelId)
ChannelId = model.ChannelId;
if (model.Avatar.IsSpecified)
AvatarId = model.Avatar.Value;
if (model.GuildId.IsSpecified)
Expand Down