Fix: Don't rely on Guild for id (#2911)
This commit is contained in:
@@ -13,13 +13,13 @@ namespace Discord.Rest
|
|||||||
public class RestCategoryChannel : RestGuildChannel, ICategoryChannel
|
public class RestCategoryChannel : RestGuildChannel, ICategoryChannel
|
||||||
{
|
{
|
||||||
#region RestCategoryChannel
|
#region RestCategoryChannel
|
||||||
internal RestCategoryChannel(BaseDiscordClient discord, IGuild guild, ulong id)
|
internal RestCategoryChannel(BaseDiscordClient discord, IGuild guild, ulong id, ulong guildId)
|
||||||
: base(discord, guild, id)
|
: base(discord, guild, id, guildId)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal new static RestCategoryChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
internal new static RestCategoryChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
||||||
{
|
{
|
||||||
var entity = new RestCategoryChannel(discord, guild, model.Id);
|
var entity = new RestCategoryChannel(discord, guild, model.Id, guild?.Id ?? model.GuildId.Value);
|
||||||
entity.Update(model);
|
entity.Update(model);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,15 +47,15 @@ namespace Discord.Rest
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Mention => MentionUtils.MentionChannel(Id);
|
public string Mention => MentionUtils.MentionChannel(Id);
|
||||||
|
|
||||||
internal RestForumChannel(BaseDiscordClient client, IGuild guild, ulong id)
|
internal RestForumChannel(BaseDiscordClient client, IGuild guild, ulong id, ulong guildId)
|
||||||
: base(client, guild, id)
|
: base(client, guild, id, guildId)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal new static RestForumChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
internal new static RestForumChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
||||||
{
|
{
|
||||||
var entity = new RestForumChannel(discord, guild, model.Id);
|
var entity = new RestForumChannel(discord, guild, model.Id, guild?.Id ?? model.GuildId.Value);
|
||||||
entity.Update(model);
|
entity.Update(model);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,16 +23,18 @@ namespace Discord.Rest
|
|||||||
public string Name { get; private set; }
|
public string Name { get; private set; }
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public int Position { get; private set; }
|
public int Position { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public ulong GuildId => Guild.Id;
|
public ulong GuildId { get; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public ChannelFlags Flags { get; private set; }
|
public ChannelFlags Flags { get; private set; }
|
||||||
|
|
||||||
internal RestGuildChannel(BaseDiscordClient discord, IGuild guild, ulong id)
|
internal RestGuildChannel(BaseDiscordClient discord, IGuild guild, ulong id, ulong guildId)
|
||||||
: base(discord, id)
|
: base(discord, id)
|
||||||
{
|
{
|
||||||
Guild = guild;
|
Guild = guild;
|
||||||
|
GuildId = guildId;
|
||||||
}
|
}
|
||||||
internal static RestGuildChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
internal static RestGuildChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
||||||
{
|
{
|
||||||
@@ -46,7 +48,7 @@ namespace Discord.Rest
|
|||||||
ChannelType.Forum => RestForumChannel.Create(discord, guild, model),
|
ChannelType.Forum => RestForumChannel.Create(discord, guild, model),
|
||||||
ChannelType.Category => RestCategoryChannel.Create(discord, guild, model),
|
ChannelType.Category => RestCategoryChannel.Create(discord, guild, model),
|
||||||
ChannelType.PublicThread or ChannelType.PrivateThread or ChannelType.NewsThread => RestThreadChannel.Create(discord, guild, model),
|
ChannelType.PublicThread or ChannelType.PrivateThread or ChannelType.NewsThread => RestThreadChannel.Create(discord, guild, model),
|
||||||
_ => new RestGuildChannel(discord, guild, model.Id),
|
_ => new RestGuildChannel(discord, guild, model.Id, guild?.Id ?? model.GuildId.Value),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
internal override void Update(Model model)
|
internal override void Update(Model model)
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ namespace Discord.Rest;
|
|||||||
|
|
||||||
public class RestMediaChannel : RestForumChannel, IMediaChannel
|
public class RestMediaChannel : RestForumChannel, IMediaChannel
|
||||||
{
|
{
|
||||||
internal RestMediaChannel(BaseDiscordClient client, IGuild guild, ulong id)
|
internal RestMediaChannel(BaseDiscordClient client, IGuild guild, ulong id, ulong guildId)
|
||||||
: base(client, guild, id)
|
: base(client, guild, id, guildId)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal new static RestMediaChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
internal new static RestMediaChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
||||||
{
|
{
|
||||||
var entity = new RestMediaChannel(discord, guild, model.Id);
|
var entity = new RestMediaChannel(discord, guild, model.Id, guild?.Id ?? model.GuildId.Value);
|
||||||
entity.Update(model);
|
entity.Update(model);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ namespace Discord.Rest
|
|||||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class RestNewsChannel : RestTextChannel, INewsChannel
|
public class RestNewsChannel : RestTextChannel, INewsChannel
|
||||||
{
|
{
|
||||||
internal RestNewsChannel(BaseDiscordClient discord, IGuild guild, ulong id)
|
internal RestNewsChannel(BaseDiscordClient discord, IGuild guild, ulong id, ulong guildId)
|
||||||
: base(discord, guild, id)
|
: base(discord, guild, id, guildId)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal new static RestNewsChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
internal new static RestNewsChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
||||||
{
|
{
|
||||||
var entity = new RestNewsChannel(discord, guild, model.Id);
|
var entity = new RestNewsChannel(discord, guild, model.Id, guild?.Id ?? model.GuildId.Value);
|
||||||
entity.Update(model);
|
entity.Update(model);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ namespace Discord.Rest
|
|||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool IsLive { get; private set; }
|
public bool IsLive { get; private set; }
|
||||||
internal RestStageChannel(BaseDiscordClient discord, IGuild guild, ulong id)
|
internal RestStageChannel(BaseDiscordClient discord, IGuild guild, ulong id, ulong guildId)
|
||||||
: base(discord, guild, id) { }
|
: base(discord, guild, id, guildId) { }
|
||||||
|
|
||||||
internal new static RestStageChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
internal new static RestStageChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
||||||
{
|
{
|
||||||
var entity = new RestStageChannel(discord, guild, model.Id);
|
var entity = new RestStageChannel(discord, guild, model.Id, guild?.Id ?? model.GuildId.Value);
|
||||||
entity.Update(model);
|
entity.Update(model);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ namespace Discord.Rest
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public int DefaultSlowModeInterval { get; private set; }
|
public int DefaultSlowModeInterval { get; private set; }
|
||||||
|
|
||||||
internal RestTextChannel(BaseDiscordClient discord, IGuild guild, ulong id)
|
internal RestTextChannel(BaseDiscordClient discord, IGuild guild, ulong id, ulong guildId)
|
||||||
: base(discord, guild, id)
|
: base(discord, guild, id, guildId)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal new static RestTextChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
internal new static RestTextChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
||||||
{
|
{
|
||||||
var entity = new RestTextChannel(discord, guild, model.Id);
|
var entity = new RestTextChannel(discord, guild, model.Id, guild?.Id ?? model.GuildId.Value);
|
||||||
entity.Update(model);
|
entity.Update(model);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,15 +51,15 @@ namespace Discord.Rest
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ulong ParentChannelId { get; private set; }
|
public ulong ParentChannelId { get; private set; }
|
||||||
|
|
||||||
internal RestThreadChannel(BaseDiscordClient discord, IGuild guild, ulong id, DateTimeOffset? createdAt)
|
internal RestThreadChannel(BaseDiscordClient discord, IGuild guild, ulong id, ulong guildId, DateTimeOffset? createdAt)
|
||||||
: base(discord, guild, id)
|
: base(discord, guild, id, guildId)
|
||||||
{
|
{
|
||||||
CreatedAt = createdAt ?? new DateTimeOffset(2022, 1, 9, 0, 0, 0, TimeSpan.Zero);
|
CreatedAt = createdAt ?? new DateTimeOffset(2022, 1, 9, 0, 0, 0, TimeSpan.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal new static RestThreadChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
internal new static RestThreadChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
||||||
{
|
{
|
||||||
var entity = new RestThreadChannel(discord, guild, model.Id, model.ThreadMetadata.GetValueOrDefault()?.CreatedAt.GetValueOrDefault());
|
var entity = new RestThreadChannel(discord, guild, model.Id, guild?.Id ?? model.GuildId.Value, model.ThreadMetadata.GetValueOrDefault()?.CreatedAt.GetValueOrDefault());
|
||||||
entity.Update(model);
|
entity.Update(model);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,13 +31,13 @@ namespace Discord.Rest
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public VideoQualityMode VideoQualityMode { get; private set; }
|
public VideoQualityMode VideoQualityMode { get; private set; }
|
||||||
|
|
||||||
internal RestVoiceChannel(BaseDiscordClient discord, IGuild guild, ulong id)
|
internal RestVoiceChannel(BaseDiscordClient discord, IGuild guild, ulong id, ulong guildId)
|
||||||
: base(discord, guild, id)
|
: base(discord, guild, id, guildId)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal new static RestVoiceChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
internal new static RestVoiceChannel Create(BaseDiscordClient discord, IGuild guild, Model model)
|
||||||
{
|
{
|
||||||
var entity = new RestVoiceChannel(discord, guild, model.Id);
|
var entity = new RestVoiceChannel(discord, guild, model.Id, guild?.Id ?? model.GuildId.Value);
|
||||||
entity.Update(model);
|
entity.Update(model);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user