| @@ -13,7 +13,7 @@ using System.Runtime.InteropServices; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| public class DiscordClient : IDiscordClient | |||||
| public class DiscordRestClient : IDiscordClient | |||||
| { | { | ||||
| private readonly object _eventLock = new object(); | private readonly object _eventLock = new object(); | ||||
| @@ -37,9 +37,9 @@ namespace Discord | |||||
| public LoginState LoginState { get; private set; } | public LoginState LoginState { get; private set; } | ||||
| /// <summary> Creates a new REST-only discord client. </summary> | /// <summary> Creates a new REST-only discord client. </summary> | ||||
| public DiscordClient() : this(new DiscordConfig()) { } | |||||
| public DiscordRestClient() : this(new DiscordConfig()) { } | |||||
| /// <summary> Creates a new REST-only discord client. </summary> | /// <summary> Creates a new REST-only discord client. </summary> | ||||
| public DiscordClient(DiscordConfig config) | |||||
| public DiscordRestClient(DiscordConfig config) | |||||
| { | { | ||||
| LogManager = new LogManager(config.LogLevel); | LogManager = new LogManager(config.LogLevel); | ||||
| LogManager.Message += async msg => await _logEvent.InvokeAsync(msg).ConfigureAwait(false); | LogManager.Message += async msg => await _logEvent.InvokeAsync(msg).ConfigureAwait(false); | ||||
| @@ -16,7 +16,7 @@ using System.Threading.Tasks; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| public partial class DiscordSocketClient : DiscordClient, IDiscordClient | |||||
| public partial class DiscordSocketClient : DiscordRestClient, IDiscordClient | |||||
| { | { | ||||
| private readonly ConcurrentQueue<ulong> _largeGuilds; | private readonly ConcurrentQueue<ulong> _largeGuilds; | ||||
| private readonly ILogger _gatewayLogger; | private readonly ILogger _gatewayLogger; | ||||
| @@ -13,12 +13,12 @@ namespace Discord | |||||
| public string[] RPCOrigins { get; private set; } | public string[] RPCOrigins { get; private set; } | ||||
| public ulong Flags { get; private set; } | public ulong Flags { get; private set; } | ||||
| public override DiscordClient Discord { get; } | |||||
| public override DiscordRestClient Discord { get; } | |||||
| public IUser Owner { get; private set; } | public IUser Owner { get; private set; } | ||||
| public string IconUrl => API.CDN.GetApplicationIconUrl(Id, _iconId); | public string IconUrl => API.CDN.GetApplicationIconUrl(Id, _iconId); | ||||
| public Application(DiscordClient discord, Model model) | |||||
| public Application(DiscordRestClient discord, Model model) | |||||
| : base(model.Id) | : base(model.Id) | ||||
| { | { | ||||
| Discord = discord; | Discord = discord; | ||||
| @@ -13,13 +13,13 @@ namespace Discord | |||||
| [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
| internal class DMChannel : SnowflakeEntity, IDMChannel | internal class DMChannel : SnowflakeEntity, IDMChannel | ||||
| { | { | ||||
| public override DiscordClient Discord { get; } | |||||
| public override DiscordRestClient Discord { get; } | |||||
| public IUser Recipient { get; private set; } | public IUser Recipient { get; private set; } | ||||
| public virtual IReadOnlyCollection<IMessage> CachedMessages => ImmutableArray.Create<IMessage>(); | public virtual IReadOnlyCollection<IMessage> CachedMessages => ImmutableArray.Create<IMessage>(); | ||||
| IReadOnlyCollection<IUser> IPrivateChannel.Recipients => ImmutableArray.Create(Recipient); | IReadOnlyCollection<IUser> IPrivateChannel.Recipients => ImmutableArray.Create(Recipient); | ||||
| public DMChannel(DiscordClient discord, IUser recipient, Model model) | |||||
| public DMChannel(DiscordRestClient discord, IUser recipient, Model model) | |||||
| : base(model.Id) | : base(model.Id) | ||||
| { | { | ||||
| Discord = discord; | Discord = discord; | ||||
| @@ -18,14 +18,14 @@ namespace Discord | |||||
| protected ConcurrentDictionary<ulong, GroupUser> _users; | protected ConcurrentDictionary<ulong, GroupUser> _users; | ||||
| private string _iconId; | private string _iconId; | ||||
| public override DiscordClient Discord { get; } | |||||
| public override DiscordRestClient Discord { get; } | |||||
| public string Name { get; private set; } | public string Name { get; private set; } | ||||
| public IReadOnlyCollection<IUser> Recipients => _users.ToReadOnlyCollection(); | public IReadOnlyCollection<IUser> Recipients => _users.ToReadOnlyCollection(); | ||||
| public virtual IReadOnlyCollection<IMessage> CachedMessages => ImmutableArray.Create<IMessage>(); | public virtual IReadOnlyCollection<IMessage> CachedMessages => ImmutableArray.Create<IMessage>(); | ||||
| public string IconUrl => API.CDN.GetChannelIconUrl(Id, _iconId); | public string IconUrl => API.CDN.GetChannelIconUrl(Id, _iconId); | ||||
| public GroupChannel(DiscordClient discord, Model model) | |||||
| public GroupChannel(DiscordRestClient discord, Model model) | |||||
| : base(model.Id) | : base(model.Id) | ||||
| { | { | ||||
| Discord = discord; | Discord = discord; | ||||
| @@ -19,7 +19,7 @@ namespace Discord | |||||
| public Guild Guild { get; private set; } | public Guild Guild { get; private set; } | ||||
| public override DiscordClient Discord => Guild.Discord; | |||||
| public override DiscordRestClient Discord => Guild.Discord; | |||||
| public GuildChannel(Guild guild, Model model) | public GuildChannel(Guild guild, Model model) | ||||
| : base(model.Id) | : base(model.Id) | ||||
| @@ -4,7 +4,7 @@ | |||||
| { | { | ||||
| public T Id { get; } | public T Id { get; } | ||||
| public abstract DiscordClient Discord { get; } | |||||
| public abstract DiscordRestClient Discord { get; } | |||||
| internal virtual bool IsAttached => false; | internal virtual bool IsAttached => false; | ||||
| bool IEntity<T>.IsAttached => IsAttached; | bool IEntity<T>.IsAttached => IsAttached; | ||||
| @@ -27,7 +27,7 @@ namespace Discord | |||||
| public MfaLevel MfaLevel { get; private set; } | public MfaLevel MfaLevel { get; private set; } | ||||
| public DefaultMessageNotifications DefaultMessageNotifications { get; private set; } | public DefaultMessageNotifications DefaultMessageNotifications { get; private set; } | ||||
| public override DiscordClient Discord { get; } | |||||
| public override DiscordRestClient Discord { get; } | |||||
| public ulong? AFKChannelId { get; private set; } | public ulong? AFKChannelId { get; private set; } | ||||
| public ulong? EmbedChannelId { get; private set; } | public ulong? EmbedChannelId { get; private set; } | ||||
| public ulong OwnerId { get; private set; } | public ulong OwnerId { get; private set; } | ||||
| @@ -42,7 +42,7 @@ namespace Discord | |||||
| public Role EveryoneRole => GetRole(Id); | public Role EveryoneRole => GetRole(Id); | ||||
| public IReadOnlyCollection<IRole> Roles => _roles.ToReadOnlyCollection(); | public IReadOnlyCollection<IRole> Roles => _roles.ToReadOnlyCollection(); | ||||
| public Guild(DiscordClient discord, Model model) | |||||
| public Guild(DiscordRestClient discord, Model model) | |||||
| : base(model.Id) | : base(model.Id) | ||||
| { | { | ||||
| Discord = discord; | Discord = discord; | ||||
| @@ -23,7 +23,7 @@ namespace Discord | |||||
| public User User { get; private set; } | public User User { get; private set; } | ||||
| public IntegrationAccount Account { get; private set; } | public IntegrationAccount Account { get; private set; } | ||||
| public override DiscordClient Discord => Guild.Discord; | |||||
| public override DiscordRestClient Discord => Guild.Discord; | |||||
| public DateTimeOffset SyncedAt => DateTimeUtils.FromTicks(_syncedAtTicks); | public DateTimeOffset SyncedAt => DateTimeUtils.FromTicks(_syncedAtTicks); | ||||
| public GuildIntegration(Guild guild, Model model) | public GuildIntegration(Guild guild, Model model) | ||||
| @@ -13,11 +13,11 @@ namespace Discord | |||||
| public bool IsOwner { get; private set; } | public bool IsOwner { get; private set; } | ||||
| public GuildPermissions Permissions { get; private set; } | public GuildPermissions Permissions { get; private set; } | ||||
| public override DiscordClient Discord { get; } | |||||
| public override DiscordRestClient Discord { get; } | |||||
| public string IconUrl => API.CDN.GetGuildIconUrl(Id, _iconId); | public string IconUrl => API.CDN.GetGuildIconUrl(Id, _iconId); | ||||
| public UserGuild(DiscordClient discord, Model model) | |||||
| public UserGuild(DiscordRestClient discord, Model model) | |||||
| : base(model.Id) | : base(model.Id) | ||||
| { | { | ||||
| Discord = discord; | Discord = discord; | ||||
| @@ -13,13 +13,13 @@ namespace Discord | |||||
| public ulong ChannelId { get; private set; } | public ulong ChannelId { get; private set; } | ||||
| public ulong GuildId { get; private set; } | public ulong GuildId { get; private set; } | ||||
| public override DiscordClient Discord { get; } | |||||
| public override DiscordRestClient Discord { get; } | |||||
| public string Code => Id; | public string Code => Id; | ||||
| public string Url => $"{DiscordConfig.InviteUrl}/{XkcdCode ?? Code}"; | public string Url => $"{DiscordConfig.InviteUrl}/{XkcdCode ?? Code}"; | ||||
| public string XkcdUrl => XkcdCode != null ? $"{DiscordConfig.InviteUrl}/{XkcdCode}" : null; | public string XkcdUrl => XkcdCode != null ? $"{DiscordConfig.InviteUrl}/{XkcdCode}" : null; | ||||
| public Invite(DiscordClient discord, Model model) | |||||
| public Invite(DiscordRestClient discord, Model model) | |||||
| : base(model.Code) | : base(model.Code) | ||||
| { | { | ||||
| Discord = discord; | Discord = discord; | ||||
| @@ -16,7 +16,7 @@ namespace Discord | |||||
| public DateTimeOffset CreatedAt => DateTimeUtils.FromTicks(_createdAtTicks); | public DateTimeOffset CreatedAt => DateTimeUtils.FromTicks(_createdAtTicks); | ||||
| public InviteMetadata(DiscordClient client, Model model) | |||||
| public InviteMetadata(DiscordRestClient client, Model model) | |||||
| : base(client, model) | : base(client, model) | ||||
| { | { | ||||
| Update(model, UpdateSource.Creation); | Update(model, UpdateSource.Creation); | ||||
| @@ -29,7 +29,7 @@ namespace Discord | |||||
| public IReadOnlyCollection<IRole> MentionedRoles { get; private set; } | public IReadOnlyCollection<IRole> MentionedRoles { get; private set; } | ||||
| public IReadOnlyCollection<IUser> MentionedUsers { get; private set; } | public IReadOnlyCollection<IUser> MentionedUsers { get; private set; } | ||||
| public override DiscordClient Discord => (Channel as Entity<ulong>).Discord; | |||||
| public override DiscordRestClient Discord => (Channel as Entity<ulong>).Discord; | |||||
| public DateTimeOffset? EditedTimestamp => DateTimeUtils.FromTicks(_editedTimestampTicks); | public DateTimeOffset? EditedTimestamp => DateTimeUtils.FromTicks(_editedTimestampTicks); | ||||
| public DateTimeOffset Timestamp => DateTimeUtils.FromTicks(_timestampTicks); | public DateTimeOffset Timestamp => DateTimeUtils.FromTicks(_timestampTicks); | ||||
| @@ -23,7 +23,7 @@ namespace Discord | |||||
| public bool IsEveryone => Id == Guild.Id; | public bool IsEveryone => Id == Guild.Id; | ||||
| public string Mention => MentionUtils.Mention(this); | public string Mention => MentionUtils.Mention(this); | ||||
| public override DiscordClient Discord => Guild.Discord; | |||||
| public override DiscordRestClient Discord => Guild.Discord; | |||||
| public Role(Guild guild, Model model) | public Role(Guild guild, Model model) | ||||
| : base(model.Id) | : base(model.Id) | ||||
| @@ -37,7 +37,7 @@ namespace Discord | |||||
| public virtual UserStatus Status => UserStatus.Unknown; | public virtual UserStatus Status => UserStatus.Unknown; | ||||
| public virtual Game Game => null; | public virtual Game Game => null; | ||||
| public DiscordClient Discord => Guild.Discord; | |||||
| public DiscordRestClient Discord => Guild.Discord; | |||||
| public DateTimeOffset? JoinedAt => DateTimeUtils.FromTicks(_joinedAtTicks); | public DateTimeOffset? JoinedAt => DateTimeUtils.FromTicks(_joinedAtTicks); | ||||
| public GuildUser(Guild guild, User user) | public GuildUser(Guild guild, User user) | ||||
| @@ -18,9 +18,9 @@ namespace Discord | |||||
| public override UserStatus Status => _status; | public override UserStatus Status => _status; | ||||
| public override Game Game => _game; | public override Game Game => _game; | ||||
| public override DiscordClient Discord { get; } | |||||
| public override DiscordRestClient Discord { get; } | |||||
| public SelfUser(DiscordClient discord, Model model) | |||||
| public SelfUser(DiscordRestClient discord, Model model) | |||||
| : base(model) | : base(model) | ||||
| { | { | ||||
| Discord = discord; | Discord = discord; | ||||
| @@ -13,7 +13,7 @@ namespace Discord | |||||
| public string Username { get; private set; } | public string Username { get; private set; } | ||||
| public ushort DiscriminatorValue { get; private set; } | public ushort DiscriminatorValue { get; private set; } | ||||
| public override DiscordClient Discord { get { throw new NotSupportedException(); } } | |||||
| public override DiscordRestClient Discord { get { throw new NotSupportedException(); } } | |||||
| public string AvatarUrl => API.CDN.GetUserAvatarUrl(Id, _avatarId); | public string AvatarUrl => API.CDN.GetUserAvatarUrl(Id, _avatarId); | ||||
| public string Discriminator => DiscriminatorValue.ToString("D4"); | public string Discriminator => DiscriminatorValue.ToString("D4"); | ||||
| @@ -5,7 +5,7 @@ namespace Discord.Extensions | |||||
| { | { | ||||
| public static class DiscordClientExtensions | public static class DiscordClientExtensions | ||||
| { | { | ||||
| public static async Task<IVoiceRegion> GetOptimalVoiceRegionAsync(this DiscordClient discord) | |||||
| public static async Task<IVoiceRegion> GetOptimalVoiceRegionAsync(this DiscordRestClient discord) | |||||
| { | { | ||||
| var regions = await discord.GetVoiceRegionsAsync().ConfigureAwait(false); | var regions = await discord.GetVoiceRegionsAsync().ConfigureAwait(false); | ||||
| return regions.FirstOrDefault(x => x.IsOptimal); | return regions.FirstOrDefault(x => x.IsOptimal); | ||||