initial commit (#2666)

This commit is contained in:
Misha133
2023-04-15 04:36:07 +03:00
committed by GitHub
parent dff6a57a92
commit d5ba7d25aa
3 changed files with 24 additions and 6 deletions

View File

@@ -23,6 +23,9 @@ namespace Discord.API
[JsonProperty("channel_id")]
public Optional<ulong> ChannelId { get; set; }
[JsonProperty("channel")]
public Optional<Channel> Channel { get; set; }
[JsonProperty("member")]
public Optional<GuildMember> Member { get; set; }

View File

@@ -135,8 +135,8 @@ namespace Discord.Rest
internal virtual async Task UpdateAsync(DiscordRestClient discord, Model model, bool doApiCall)
{
ChannelId = model.ChannelId.IsSpecified
? model.ChannelId.Value
ChannelId = model.Channel.IsSpecified
? model.Channel.Value.Id
: null;
GuildId = model.GuildId.IsSpecified
@@ -186,8 +186,23 @@ namespace Discord.Rest
Channel = (IRestMessageChannel)await discord.GetChannelAsync(ChannelId.Value);
else
{
Channel = null;
if (model.Channel.IsSpecified)
{
Channel = model.Channel.Value.Type switch
{
ChannelType.News or
ChannelType.Text or
ChannelType.Voice or
ChannelType.Stage or
ChannelType.NewsThread or
ChannelType.PrivateThread or
ChannelType.PublicThread
=> RestGuildChannel.Create(discord, Guild, model.Channel.Value) as IRestMessageChannel,
ChannelType.DM => RestDMChannel.Create(discord, model.Channel.Value),
ChannelType.Group => RestGroupChannel.Create(discord, model.Channel.Value),
_ => null
};
}
_getChannel = async (opt, ul) =>
{
if (Guild is null)

View File

@@ -116,8 +116,8 @@ namespace Discord.WebSocket
internal virtual void Update(Model model)
{
ChannelId = model.ChannelId.IsSpecified
? model.ChannelId.Value
ChannelId = model.Channel.IsSpecified
? model.Channel.Value.Id
: null;
GuildId = model.GuildId.IsSpecified