Guild Channels

This commit is contained in:
Kecskeméti László 2024-07-26 13:53:40 +02:00
parent e925e541fd
commit da80a3133d
2 changed files with 46 additions and 1 deletions

View File

@ -1,4 +1,5 @@
using Discord.API; using Discord.API;
using Serilog;
namespace Discord.Model; namespace Discord.Model;
@ -6,7 +7,23 @@ public class GuildTextChannel : GuildChannel
{ {
internal GuildTextChannel(GuildChannelData data) : base(data){ internal GuildTextChannel(GuildChannelData data) : base(data){
Update(data, false);
}
protected new void Update(GuildChannelData data, bool call_base_update){
if((ChannelType)data.Type is not ChannelType.GuildText or ChannelType.GuildAnnouncement){
Log.Warning("Channel type is not compatible with GuildTextChannel: {type}", (ChannelType)data.Type);
}
if(call_base_update) base.Update(data, call_base_update);
}
public override void Update(ChannelData data)
{
if(data is GuildChannelData guild_data){
Update(guild_data, true);
}else{
throw new ArgumentException("data must be GuildChannelData", nameof(data));
}
} }
} }

View File

@ -0,0 +1,28 @@
using System.Data;
using Discord.API;
namespace Discord.Model;
public class GuildVoiceChannel : GuildChannel
{
public int Bitrate {get; protected set;}
internal GuildVoiceChannel(GuildChannelData data) : base(data)
{
Update(data, false);
}
protected new void Update(GuildChannelData data, bool call_base_update){
Bitrate = data.Bitrate!.Value;
if(call_base_update) base.Update(data, call_base_update);
}
public override void Update(ChannelData data)
{
if(data is GuildChannelData guild_data){
Update(guild_data, true);
}else{
throw new ArgumentException("data must be GuildChannelData", nameof(data));
}
}
}