using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Model = Discord.API.Channel; namespace Discord.Rest { /// /// Represents a generic REST-based channel. /// public class RestChannel : RestEntity, IChannel, IUpdateable { /// public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); internal RestChannel(BaseDiscordClient discord, ulong id) : base(discord, id) { } /// Unexpected channel type. internal static RestChannel Create(BaseDiscordClient discord, Model model) { switch (model.Type) { case ChannelType.News: case ChannelType.Text: case ChannelType.Voice: return RestGuildChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model); case ChannelType.DM: case ChannelType.Group: return CreatePrivate(discord, model) as RestChannel; case ChannelType.Category: return RestCategoryChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model); default: return new RestChannel(discord, model.Id); } } /// Unexpected channel type. internal static IRestPrivateChannel CreatePrivate(BaseDiscordClient discord, Model model) { switch (model.Type) { case ChannelType.DM: return RestDMChannel.Create(discord, model); case ChannelType.Group: return RestGroupChannel.Create(discord, model); default: throw new InvalidOperationException($"Unexpected channel type: {model.Type}"); } } internal virtual void Update(Model model) { } /// public virtual Task UpdateAsync(RequestOptions options = null) => Task.Delay(0); //IChannel /// string IChannel.Name => null; /// Task IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) => Task.FromResult(null); //Overridden /// IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) => AsyncEnumerable.Empty>(); //Overridden } }