| @@ -53,7 +53,7 @@ namespace Discord.Audio | |||||
| public ulong ChannelId { get; internal set; } | public ulong ChannelId { get; internal set; } | ||||
| internal byte[] SecretKey { get; private set; } | internal byte[] SecretKey { get; private set; } | ||||
| private DiscordSocketClient Discord => Guild.Discord; | |||||
| private DiscordSocketClient Discord => Guild.Client; | |||||
| public ConnectionState ConnectionState => _connection.State; | public ConnectionState ConnectionState => _connection.State; | ||||
| /// <summary> Creates a new REST/WebSocket discord client. </summary> | /// <summary> Creates a new REST/WebSocket discord client. </summary> | ||||
| @@ -37,7 +37,7 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| internal new static SocketCategoryChannel Create(SocketGuild guild, ClientState state, Model model) | internal new static SocketCategoryChannel Create(SocketGuild guild, ClientState state, Model model) | ||||
| { | { | ||||
| var entity = new SocketCategoryChannel(guild.Discord, model.Id, guild); | |||||
| var entity = new SocketCategoryChannel(guild.Client, model.Id, guild); | |||||
| entity.Update(state, model); | entity.Update(state, model); | ||||
| return entity; | return entity; | ||||
| } | } | ||||
| @@ -29,15 +29,15 @@ namespace Discord.WebSocket | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection that is the current logged-in user and the recipient. | /// Gets a collection that is the current logged-in user and the recipient. | ||||
| /// </summary> | /// </summary> | ||||
| public new IReadOnlyCollection<SocketUser> Users => ImmutableArray.Create(Discord.CurrentUser, Recipient); | |||||
| public new IReadOnlyCollection<SocketUser> Users => ImmutableArray.Create(Client.CurrentUser, Recipient); | |||||
| internal SocketDMChannel(DiscordSocketClient discord, ulong id, SocketGlobalUser recipient) | internal SocketDMChannel(DiscordSocketClient discord, ulong id, SocketGlobalUser recipient) | ||||
| : base(discord, id) | : base(discord, id) | ||||
| { | { | ||||
| Recipient = recipient; | Recipient = recipient; | ||||
| recipient.GlobalUser.AddRef(); | recipient.GlobalUser.AddRef(); | ||||
| if (Discord.MessageCacheSize > 0) | |||||
| _messages = new MessageCache(Discord); | |||||
| if (Client.MessageCacheSize > 0) | |||||
| _messages = new MessageCache(Client); | |||||
| } | } | ||||
| internal static SocketDMChannel Create(DiscordSocketClient discord, ClientState state, Model model) | internal static SocketDMChannel Create(DiscordSocketClient discord, ClientState state, Model model) | ||||
| { | { | ||||
| @@ -52,7 +52,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task CloseAsync(RequestOptions options = null) | public Task CloseAsync(RequestOptions options = null) | ||||
| => ChannelHelper.DeleteAsync(this, Discord, options); | |||||
| => ChannelHelper.DeleteAsync(this, Client, options); | |||||
| //Messages | //Messages | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| @@ -70,7 +70,7 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| IMessage msg = _messages?.Get(id); | IMessage msg = _messages?.Get(id); | ||||
| if (msg == null) | if (msg == null) | ||||
| msg = await ChannelHelper.GetMessageAsync(this, Discord, id, options).ConfigureAwait(false); | |||||
| msg = await ChannelHelper.GetMessageAsync(this, Client, id, options).ConfigureAwait(false); | |||||
| return msg; | return msg; | ||||
| } | } | ||||
| @@ -87,7 +87,7 @@ namespace Discord.WebSocket | |||||
| /// Paged collection of messages. | /// Paged collection of messages. | ||||
| /// </returns> | /// </returns> | ||||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, null, Direction.Before, limit, CacheMode.AllowDownload, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, null, Direction.Before, limit, CacheMode.AllowDownload, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of messages in this channel. | /// Gets a collection of messages in this channel. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -103,7 +103,7 @@ namespace Discord.WebSocket | |||||
| /// Paged collection of messages. | /// Paged collection of messages. | ||||
| /// </returns> | /// </returns> | ||||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessageId, dir, limit, CacheMode.AllowDownload, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, fromMessageId, dir, limit, CacheMode.AllowDownload, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of messages in this channel. | /// Gets a collection of messages in this channel. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -119,45 +119,45 @@ namespace Discord.WebSocket | |||||
| /// Paged collection of messages. | /// Paged collection of messages. | ||||
| /// </returns> | /// </returns> | ||||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, CacheMode.AllowDownload, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, fromMessage.Id, dir, limit, CacheMode.AllowDownload, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IReadOnlyCollection<SocketMessage> GetCachedMessages(int limit = DiscordConfig.MaxMessagesPerBatch) | public IReadOnlyCollection<SocketMessage> GetCachedMessages(int limit = DiscordConfig.MaxMessagesPerBatch) | ||||
| => SocketChannelHelper.GetCachedMessages(this, Discord, _messages, null, Direction.Before, limit); | |||||
| => SocketChannelHelper.GetCachedMessages(this, Client, _messages, null, Direction.Before, limit); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IReadOnlyCollection<SocketMessage> GetCachedMessages(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) | public IReadOnlyCollection<SocketMessage> GetCachedMessages(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) | ||||
| => SocketChannelHelper.GetCachedMessages(this, Discord, _messages, fromMessageId, dir, limit); | |||||
| => SocketChannelHelper.GetCachedMessages(this, Client, _messages, fromMessageId, dir, limit); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IReadOnlyCollection<SocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) | public IReadOnlyCollection<SocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) | ||||
| => SocketChannelHelper.GetCachedMessages(this, Discord, _messages, fromMessage.Id, dir, limit); | |||||
| => SocketChannelHelper.GetCachedMessages(this, Client, _messages, fromMessage.Id, dir, limit); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | ||||
| => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); | |||||
| => ChannelHelper.GetPinnedMessagesAsync(this, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | /// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | ||||
| public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null) | public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null) | ||||
| => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); | |||||
| => ChannelHelper.SendMessageAsync(this, Client, text, isTTS, embed, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | ||||
| => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, options); | |||||
| => ChannelHelper.SendFileAsync(this, Client, filePath, text, isTTS, embed, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | /// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | ||||
| public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | ||||
| => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, options); | |||||
| => ChannelHelper.SendFileAsync(this, Client, stream, filename, text, isTTS, embed, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) | public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) | ||||
| => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options); | |||||
| => ChannelHelper.DeleteMessageAsync(this, messageId, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) | public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) | ||||
| => ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options); | |||||
| => ChannelHelper.DeleteMessageAsync(this, message.Id, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task TriggerTypingAsync(RequestOptions options = null) | public Task TriggerTypingAsync(RequestOptions options = null) | ||||
| => ChannelHelper.TriggerTypingAsync(this, Discord, options); | |||||
| => ChannelHelper.TriggerTypingAsync(this, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IDisposable EnterTypingState(RequestOptions options = null) | public IDisposable EnterTypingState(RequestOptions options = null) | ||||
| => ChannelHelper.EnterTypingState(this, Discord, options); | |||||
| => ChannelHelper.EnterTypingState(this, Client, options); | |||||
| internal void AddMessage(SocketMessage msg) | internal void AddMessage(SocketMessage msg) | ||||
| => _messages?.Add(msg); | => _messages?.Add(msg); | ||||
| @@ -176,8 +176,8 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| if (id == Recipient.Id) | if (id == Recipient.Id) | ||||
| return Recipient; | return Recipient; | ||||
| else if (id == Discord.CurrentUser.Id) | |||||
| return Discord.CurrentUser; | |||||
| else if (id == Client.CurrentUser.Id) | |||||
| return Client.CurrentUser; | |||||
| else | else | ||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -218,13 +218,13 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, null, Direction.Before, limit, mode, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, null, Direction.Before, limit, mode, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessageId, dir, limit, mode, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, fromMessageId, dir, limit, mode, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, fromMessage.Id, dir, limit, mode, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | ||||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | ||||
| @@ -33,13 +33,13 @@ namespace Discord.WebSocket | |||||
| public IReadOnlyCollection<SocketMessage> CachedMessages => _messages?.Messages ?? ImmutableArray.Create<SocketMessage>(); | public IReadOnlyCollection<SocketMessage> CachedMessages => _messages?.Messages ?? ImmutableArray.Create<SocketMessage>(); | ||||
| public new IReadOnlyCollection<SocketGroupUser> Users => _users.ToReadOnlyCollection(); | public new IReadOnlyCollection<SocketGroupUser> Users => _users.ToReadOnlyCollection(); | ||||
| public IReadOnlyCollection<SocketGroupUser> Recipients | public IReadOnlyCollection<SocketGroupUser> Recipients | ||||
| => _users.Select(x => x.Value).Where(x => x.Id != Discord.CurrentUser.Id).ToReadOnlyCollection(() => _users.Count - 1); | |||||
| => _users.Select(x => x.Value).Where(x => x.Id != Client.CurrentUser.Id).ToReadOnlyCollection(() => _users.Count - 1); | |||||
| internal SocketGroupChannel(DiscordSocketClient discord, ulong id) | internal SocketGroupChannel(DiscordSocketClient discord, ulong id) | ||||
| : base(discord, id) | : base(discord, id) | ||||
| { | { | ||||
| if (Discord.MessageCacheSize > 0) | |||||
| _messages = new MessageCache(Discord); | |||||
| if (Client.MessageCacheSize > 0) | |||||
| _messages = new MessageCache(Client); | |||||
| _voiceStates = new ConcurrentDictionary<ulong, SocketVoiceState>(ConcurrentHashSet.DefaultConcurrencyLevel, 5); | _voiceStates = new ConcurrentDictionary<ulong, SocketVoiceState>(ConcurrentHashSet.DefaultConcurrencyLevel, 5); | ||||
| _users = new ConcurrentDictionary<ulong, SocketGroupUser>(ConcurrentHashSet.DefaultConcurrencyLevel, 5); | _users = new ConcurrentDictionary<ulong, SocketGroupUser>(ConcurrentHashSet.DefaultConcurrencyLevel, 5); | ||||
| } | } | ||||
| @@ -69,7 +69,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task LeaveAsync(RequestOptions options = null) | public Task LeaveAsync(RequestOptions options = null) | ||||
| => ChannelHelper.DeleteAsync(this, Discord, options); | |||||
| => ChannelHelper.DeleteAsync(this, Client, options); | |||||
| /// <exception cref="NotSupportedException">Voice is not yet supported for group channels.</exception> | /// <exception cref="NotSupportedException">Voice is not yet supported for group channels.</exception> | ||||
| public Task<IAudioClient> ConnectAsync() | public Task<IAudioClient> ConnectAsync() | ||||
| @@ -98,7 +98,7 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| IMessage msg = _messages?.Get(id); | IMessage msg = _messages?.Get(id); | ||||
| if (msg == null) | if (msg == null) | ||||
| msg = await ChannelHelper.GetMessageAsync(this, Discord, id, options).ConfigureAwait(false); | |||||
| msg = await ChannelHelper.GetMessageAsync(this, Client, id, options).ConfigureAwait(false); | |||||
| return msg; | return msg; | ||||
| } | } | ||||
| @@ -115,7 +115,7 @@ namespace Discord.WebSocket | |||||
| /// Paged collection of messages. | /// Paged collection of messages. | ||||
| /// </returns> | /// </returns> | ||||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, null, Direction.Before, limit, CacheMode.AllowDownload, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, null, Direction.Before, limit, CacheMode.AllowDownload, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of messages in this channel. | /// Gets a collection of messages in this channel. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -131,7 +131,7 @@ namespace Discord.WebSocket | |||||
| /// Paged collection of messages. | /// Paged collection of messages. | ||||
| /// </returns> | /// </returns> | ||||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessageId, dir, limit, CacheMode.AllowDownload, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, fromMessageId, dir, limit, CacheMode.AllowDownload, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of messages in this channel. | /// Gets a collection of messages in this channel. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -147,45 +147,45 @@ namespace Discord.WebSocket | |||||
| /// Paged collection of messages. | /// Paged collection of messages. | ||||
| /// </returns> | /// </returns> | ||||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, CacheMode.AllowDownload, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, fromMessage.Id, dir, limit, CacheMode.AllowDownload, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IReadOnlyCollection<SocketMessage> GetCachedMessages(int limit = DiscordConfig.MaxMessagesPerBatch) | public IReadOnlyCollection<SocketMessage> GetCachedMessages(int limit = DiscordConfig.MaxMessagesPerBatch) | ||||
| => SocketChannelHelper.GetCachedMessages(this, Discord, _messages, null, Direction.Before, limit); | |||||
| => SocketChannelHelper.GetCachedMessages(this, Client, _messages, null, Direction.Before, limit); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IReadOnlyCollection<SocketMessage> GetCachedMessages(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) | public IReadOnlyCollection<SocketMessage> GetCachedMessages(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) | ||||
| => SocketChannelHelper.GetCachedMessages(this, Discord, _messages, fromMessageId, dir, limit); | |||||
| => SocketChannelHelper.GetCachedMessages(this, Client, _messages, fromMessageId, dir, limit); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IReadOnlyCollection<SocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) | public IReadOnlyCollection<SocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) | ||||
| => SocketChannelHelper.GetCachedMessages(this, Discord, _messages, fromMessage.Id, dir, limit); | |||||
| => SocketChannelHelper.GetCachedMessages(this, Client, _messages, fromMessage.Id, dir, limit); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | ||||
| => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); | |||||
| => ChannelHelper.GetPinnedMessagesAsync(this, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | /// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | ||||
| public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null) | public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null) | ||||
| => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); | |||||
| => ChannelHelper.SendMessageAsync(this, Client, text, isTTS, embed, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | ||||
| => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, options); | |||||
| => ChannelHelper.SendFileAsync(this, Client, filePath, text, isTTS, embed, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | ||||
| => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, options); | |||||
| => ChannelHelper.SendFileAsync(this, Client, stream, filename, text, isTTS, embed, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) | public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) | ||||
| => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options); | |||||
| => ChannelHelper.DeleteMessageAsync(this, messageId, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) | public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) | ||||
| => ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options); | |||||
| => ChannelHelper.DeleteMessageAsync(this, message.Id, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task TriggerTypingAsync(RequestOptions options = null) | public Task TriggerTypingAsync(RequestOptions options = null) | ||||
| => ChannelHelper.TriggerTypingAsync(this, Discord, options); | |||||
| => ChannelHelper.TriggerTypingAsync(this, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IDisposable EnterTypingState(RequestOptions options = null) | public IDisposable EnterTypingState(RequestOptions options = null) | ||||
| => ChannelHelper.EnterTypingState(this, Discord, options); | |||||
| => ChannelHelper.EnterTypingState(this, Client, options); | |||||
| internal void AddMessage(SocketMessage msg) | internal void AddMessage(SocketMessage msg) | ||||
| => _messages?.Add(msg); | => _messages?.Add(msg); | ||||
| @@ -212,7 +212,7 @@ namespace Discord.WebSocket | |||||
| return user; | return user; | ||||
| else | else | ||||
| { | { | ||||
| var privateUser = SocketGroupUser.Create(this, Discord.State, model); | |||||
| var privateUser = SocketGroupUser.Create(this, Client.State, model); | |||||
| privateUser.GlobalUser.AddRef(); | privateUser.GlobalUser.AddRef(); | ||||
| _users[privateUser.Id] = privateUser; | _users[privateUser.Id] = privateUser; | ||||
| return privateUser; | return privateUser; | ||||
| @@ -222,7 +222,7 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| if (_users.TryRemove(id, out SocketGroupUser user)) | if (_users.TryRemove(id, out SocketGroupUser user)) | ||||
| { | { | ||||
| user.GlobalUser.RemoveRef(Discord); | |||||
| user.GlobalUser.RemoveRef(Client); | |||||
| return user; | return user; | ||||
| } | } | ||||
| return null; | return null; | ||||
| @@ -281,13 +281,13 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, null, Direction.Before, limit, mode, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, null, Direction.Before, limit, mode, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessageId, dir, limit, mode, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, fromMessageId, dir, limit, mode, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, fromMessage.Id, dir, limit, mode, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | ||||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | ||||
| @@ -56,7 +56,7 @@ namespace Discord.WebSocket | |||||
| return SocketCategoryChannel.Create(guild, state, model); | return SocketCategoryChannel.Create(guild, state, model); | ||||
| default: | default: | ||||
| // TODO: Proper implementation for channel categories | // TODO: Proper implementation for channel categories | ||||
| return new SocketGuildChannel(guild.Discord, model.Id, guild); | |||||
| return new SocketGuildChannel(guild.Client, model.Id, guild); | |||||
| } | } | ||||
| } | } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| @@ -74,10 +74,10 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task ModifyAsync(Action<GuildChannelProperties> func, RequestOptions options = null) | public Task ModifyAsync(Action<GuildChannelProperties> func, RequestOptions options = null) | ||||
| => ChannelHelper.ModifyAsync(this, Discord, func, options); | |||||
| => ChannelHelper.ModifyAsync(this, Client, func, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteAsync(RequestOptions options = null) | public Task DeleteAsync(RequestOptions options = null) | ||||
| => ChannelHelper.DeleteAsync(this, Discord, options); | |||||
| => ChannelHelper.DeleteAsync(this, Client, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the permission overwrite for a specific user. | /// Gets the permission overwrite for a specific user. | ||||
| @@ -123,7 +123,7 @@ namespace Discord.WebSocket | |||||
| /// </returns> | /// </returns> | ||||
| public async Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options = null) | public async Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options = null) | ||||
| { | { | ||||
| await ChannelHelper.AddPermissionOverwriteAsync(this, Discord, user, permissions, options).ConfigureAwait(false); | |||||
| await ChannelHelper.AddPermissionOverwriteAsync(this, Client, user, permissions, options).ConfigureAwait(false); | |||||
| _overwrites = _overwrites.Add(new Overwrite(user.Id, PermissionTarget.User, new OverwritePermissions(permissions.AllowValue, permissions.DenyValue))); | _overwrites = _overwrites.Add(new Overwrite(user.Id, PermissionTarget.User, new OverwritePermissions(permissions.AllowValue, permissions.DenyValue))); | ||||
| } | } | ||||
| @@ -138,7 +138,7 @@ namespace Discord.WebSocket | |||||
| /// </returns> | /// </returns> | ||||
| public async Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null) | public async Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null) | ||||
| { | { | ||||
| await ChannelHelper.AddPermissionOverwriteAsync(this, Discord, role, permissions, options).ConfigureAwait(false); | |||||
| await ChannelHelper.AddPermissionOverwriteAsync(this, Client, role, permissions, options).ConfigureAwait(false); | |||||
| _overwrites = _overwrites.Add(new Overwrite(role.Id, PermissionTarget.Role, new OverwritePermissions(permissions.AllowValue, permissions.DenyValue))); | _overwrites = _overwrites.Add(new Overwrite(role.Id, PermissionTarget.Role, new OverwritePermissions(permissions.AllowValue, permissions.DenyValue))); | ||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -151,7 +151,7 @@ namespace Discord.WebSocket | |||||
| /// </returns> | /// </returns> | ||||
| public async Task RemovePermissionOverwriteAsync(IUser user, RequestOptions options = null) | public async Task RemovePermissionOverwriteAsync(IUser user, RequestOptions options = null) | ||||
| { | { | ||||
| await ChannelHelper.RemovePermissionOverwriteAsync(this, Discord, user, options).ConfigureAwait(false); | |||||
| await ChannelHelper.RemovePermissionOverwriteAsync(this, Client, user, options).ConfigureAwait(false); | |||||
| for (int i = 0; i < _overwrites.Length; i++) | for (int i = 0; i < _overwrites.Length; i++) | ||||
| { | { | ||||
| @@ -172,7 +172,7 @@ namespace Discord.WebSocket | |||||
| /// </returns> | /// </returns> | ||||
| public async Task RemovePermissionOverwriteAsync(IRole role, RequestOptions options = null) | public async Task RemovePermissionOverwriteAsync(IRole role, RequestOptions options = null) | ||||
| { | { | ||||
| await ChannelHelper.RemovePermissionOverwriteAsync(this, Discord, role, options).ConfigureAwait(false); | |||||
| await ChannelHelper.RemovePermissionOverwriteAsync(this, Client, role, options).ConfigureAwait(false); | |||||
| for (int i = 0; i < _overwrites.Length; i++) | for (int i = 0; i < _overwrites.Length; i++) | ||||
| { | { | ||||
| @@ -34,7 +34,7 @@ namespace Discord.WebSocket | |||||
| => CategoryId.HasValue ? Guild.GetChannel(CategoryId.Value) as ICategoryChannel : null; | => CategoryId.HasValue ? Guild.GetChannel(CategoryId.Value) as ICategoryChannel : null; | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task SyncPermissionsAsync(RequestOptions options = null) | public Task SyncPermissionsAsync(RequestOptions options = null) | ||||
| => ChannelHelper.SyncPermissionsAsync(this, Discord, options); | |||||
| => ChannelHelper.SyncPermissionsAsync(this, Client, options); | |||||
| private bool _nsfw; | private bool _nsfw; | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| @@ -53,12 +53,12 @@ namespace Discord.WebSocket | |||||
| internal SocketTextChannel(DiscordSocketClient discord, ulong id, SocketGuild guild) | internal SocketTextChannel(DiscordSocketClient discord, ulong id, SocketGuild guild) | ||||
| : base(discord, id, guild) | : base(discord, id, guild) | ||||
| { | { | ||||
| if (Discord.MessageCacheSize > 0) | |||||
| _messages = new MessageCache(Discord); | |||||
| if (Client.MessageCacheSize > 0) | |||||
| _messages = new MessageCache(Client); | |||||
| } | } | ||||
| internal new static SocketTextChannel Create(SocketGuild guild, ClientState state, Model model) | internal new static SocketTextChannel Create(SocketGuild guild, ClientState state, Model model) | ||||
| { | { | ||||
| var entity = new SocketTextChannel(guild.Discord, model.Id, guild); | |||||
| var entity = new SocketTextChannel(guild.Client, model.Id, guild); | |||||
| entity.Update(state, model); | entity.Update(state, model); | ||||
| return entity; | return entity; | ||||
| } | } | ||||
| @@ -73,7 +73,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null) | public Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null) | ||||
| => ChannelHelper.ModifyAsync(this, Discord, func, options); | |||||
| => ChannelHelper.ModifyAsync(this, Client, func, options); | |||||
| //Messages | //Messages | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| @@ -96,7 +96,7 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| IMessage msg = _messages?.Get(id); | IMessage msg = _messages?.Get(id); | ||||
| if (msg == null) | if (msg == null) | ||||
| msg = await ChannelHelper.GetMessageAsync(this, Discord, id, options).ConfigureAwait(false); | |||||
| msg = await ChannelHelper.GetMessageAsync(this, Client, id, options).ConfigureAwait(false); | |||||
| return msg; | return msg; | ||||
| } | } | ||||
| @@ -113,7 +113,7 @@ namespace Discord.WebSocket | |||||
| /// Paged collection of messages. | /// Paged collection of messages. | ||||
| /// </returns> | /// </returns> | ||||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, null, Direction.Before, limit, CacheMode.AllowDownload, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, null, Direction.Before, limit, CacheMode.AllowDownload, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of messages in this channel. | /// Gets a collection of messages in this channel. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -129,7 +129,7 @@ namespace Discord.WebSocket | |||||
| /// Paged collection of messages. | /// Paged collection of messages. | ||||
| /// </returns> | /// </returns> | ||||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessageId, dir, limit, CacheMode.AllowDownload, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, fromMessageId, dir, limit, CacheMode.AllowDownload, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of messages in this channel. | /// Gets a collection of messages in this channel. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -145,54 +145,54 @@ namespace Discord.WebSocket | |||||
| /// Paged collection of messages. | /// Paged collection of messages. | ||||
| /// </returns> | /// </returns> | ||||
| public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, CacheMode.AllowDownload, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, fromMessage.Id, dir, limit, CacheMode.AllowDownload, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IReadOnlyCollection<SocketMessage> GetCachedMessages(int limit = DiscordConfig.MaxMessagesPerBatch) | public IReadOnlyCollection<SocketMessage> GetCachedMessages(int limit = DiscordConfig.MaxMessagesPerBatch) | ||||
| => SocketChannelHelper.GetCachedMessages(this, Discord, _messages, null, Direction.Before, limit); | |||||
| => SocketChannelHelper.GetCachedMessages(this, Client, _messages, null, Direction.Before, limit); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IReadOnlyCollection<SocketMessage> GetCachedMessages(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) | public IReadOnlyCollection<SocketMessage> GetCachedMessages(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) | ||||
| => SocketChannelHelper.GetCachedMessages(this, Discord, _messages, fromMessageId, dir, limit); | |||||
| => SocketChannelHelper.GetCachedMessages(this, Client, _messages, fromMessageId, dir, limit); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IReadOnlyCollection<SocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) | public IReadOnlyCollection<SocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) | ||||
| => SocketChannelHelper.GetCachedMessages(this, Discord, _messages, fromMessage.Id, dir, limit); | |||||
| => SocketChannelHelper.GetCachedMessages(this, Client, _messages, fromMessage.Id, dir, limit); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null) | ||||
| => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options); | |||||
| => ChannelHelper.GetPinnedMessagesAsync(this, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | /// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | ||||
| public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null) | public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null) | ||||
| => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); | |||||
| => ChannelHelper.SendMessageAsync(this, Client, text, isTTS, embed, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | ||||
| => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, options); | |||||
| => ChannelHelper.SendFileAsync(this, Client, filePath, text, isTTS, embed, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | /// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | ||||
| public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) | ||||
| => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, options); | |||||
| => ChannelHelper.SendFileAsync(this, Client, stream, filename, text, isTTS, embed, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null) | public Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null) | ||||
| => ChannelHelper.DeleteMessagesAsync(this, Discord, messages.Select(x => x.Id), options); | |||||
| => ChannelHelper.DeleteMessagesAsync(this, Client, messages.Select(x => x.Id), options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteMessagesAsync(IEnumerable<ulong> messageIds, RequestOptions options = null) | public Task DeleteMessagesAsync(IEnumerable<ulong> messageIds, RequestOptions options = null) | ||||
| => ChannelHelper.DeleteMessagesAsync(this, Discord, messageIds, options); | |||||
| => ChannelHelper.DeleteMessagesAsync(this, Client, messageIds, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) | public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) | ||||
| => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options); | |||||
| => ChannelHelper.DeleteMessageAsync(this, messageId, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) | public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) | ||||
| => ChannelHelper.DeleteMessageAsync(this, message.Id, Discord, options); | |||||
| => ChannelHelper.DeleteMessageAsync(this, message.Id, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task TriggerTypingAsync(RequestOptions options = null) | public Task TriggerTypingAsync(RequestOptions options = null) | ||||
| => ChannelHelper.TriggerTypingAsync(this, Discord, options); | |||||
| => ChannelHelper.TriggerTypingAsync(this, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IDisposable EnterTypingState(RequestOptions options = null) | public IDisposable EnterTypingState(RequestOptions options = null) | ||||
| => ChannelHelper.EnterTypingState(this, Discord, options); | |||||
| => ChannelHelper.EnterTypingState(this, Client, options); | |||||
| internal void AddMessage(SocketMessage msg) | internal void AddMessage(SocketMessage msg) | ||||
| => _messages?.Add(msg); | => _messages?.Add(msg); | ||||
| @@ -226,7 +226,7 @@ namespace Discord.WebSocket | |||||
| /// webhook. | /// webhook. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<RestWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null) | public Task<RestWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null) | ||||
| => ChannelHelper.CreateWebhookAsync(this, Discord, name, avatar, options); | |||||
| => ChannelHelper.CreateWebhookAsync(this, Client, name, avatar, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a webhook available in this text channel. | /// Gets a webhook available in this text channel. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -237,7 +237,7 @@ namespace Discord.WebSocket | |||||
| /// with the identifier; <c>null</c> if the webhook is not found. | /// with the identifier; <c>null</c> if the webhook is not found. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) | public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) | ||||
| => ChannelHelper.GetWebhookAsync(this, Discord, id, options); | |||||
| => ChannelHelper.GetWebhookAsync(this, Client, id, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the webhooks available in this text channel. | /// Gets the webhooks available in this text channel. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -247,15 +247,15 @@ namespace Discord.WebSocket | |||||
| /// of webhooks that is available in this channel. | /// of webhooks that is available in this channel. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<IReadOnlyCollection<RestWebhook>> GetWebhooksAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestWebhook>> GetWebhooksAsync(RequestOptions options = null) | ||||
| => ChannelHelper.GetWebhooksAsync(this, Discord, options); | |||||
| => ChannelHelper.GetWebhooksAsync(this, Client, options); | |||||
| //Invites | //Invites | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public async Task<IInviteMetadata> CreateInviteAsync(int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) | public async Task<IInviteMetadata> CreateInviteAsync(int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) | ||||
| => await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, isUnique, options).ConfigureAwait(false); | |||||
| => await ChannelHelper.CreateInviteAsync(this, Client, maxAge, maxUses, isTemporary, isUnique, options).ConfigureAwait(false); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public async Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null) | public async Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null) | ||||
| => await ChannelHelper.GetInvitesAsync(this, Discord, options).ConfigureAwait(false); | |||||
| => await ChannelHelper.GetInvitesAsync(this, Client, options).ConfigureAwait(false); | |||||
| private string DebuggerDisplay => $"{Name} ({Id}, Text)"; | private string DebuggerDisplay => $"{Name} ({Id}, Text)"; | ||||
| internal new SocketTextChannel Clone() => MemberwiseClone() as SocketTextChannel; | internal new SocketTextChannel Clone() => MemberwiseClone() as SocketTextChannel; | ||||
| @@ -290,13 +290,13 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, null, Direction.Before, limit, mode, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, null, Direction.Before, limit, mode, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessageId, dir, limit, mode, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, fromMessageId, dir, limit, mode, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options) | ||||
| => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options); | |||||
| => SocketChannelHelper.GetMessagesAsync(this, Client, _messages, fromMessage.Id, dir, limit, mode, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | ||||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | ||||
| @@ -32,7 +32,7 @@ namespace Discord.WebSocket | |||||
| => CategoryId.HasValue ? Guild.GetChannel(CategoryId.Value) as ICategoryChannel : null; | => CategoryId.HasValue ? Guild.GetChannel(CategoryId.Value) as ICategoryChannel : null; | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task SyncPermissionsAsync(RequestOptions options = null) | public Task SyncPermissionsAsync(RequestOptions options = null) | ||||
| => ChannelHelper.SyncPermissionsAsync(this, Discord, options); | |||||
| => ChannelHelper.SyncPermissionsAsync(this, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public override IReadOnlyCollection<SocketGuildUser> Users | public override IReadOnlyCollection<SocketGuildUser> Users | ||||
| @@ -44,7 +44,7 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| internal new static SocketVoiceChannel Create(SocketGuild guild, ClientState state, Model model) | internal new static SocketVoiceChannel Create(SocketGuild guild, ClientState state, Model model) | ||||
| { | { | ||||
| var entity = new SocketVoiceChannel(guild.Discord, model.Id, guild); | |||||
| var entity = new SocketVoiceChannel(guild.Client, model.Id, guild); | |||||
| entity.Update(state, model); | entity.Update(state, model); | ||||
| return entity; | return entity; | ||||
| } | } | ||||
| @@ -59,7 +59,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task ModifyAsync(Action<VoiceChannelProperties> func, RequestOptions options = null) | public Task ModifyAsync(Action<VoiceChannelProperties> func, RequestOptions options = null) | ||||
| => ChannelHelper.ModifyAsync(this, Discord, func, options); | |||||
| => ChannelHelper.ModifyAsync(this, Client, func, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public async Task<IAudioClient> ConnectAsync(bool selfDeaf = false, bool selfMute = false, bool external = false) | public async Task<IAudioClient> ConnectAsync(bool selfDeaf = false, bool selfMute = false, bool external = false) | ||||
| @@ -83,10 +83,10 @@ namespace Discord.WebSocket | |||||
| //Invites | //Invites | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public async Task<IInviteMetadata> CreateInviteAsync(int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) | public async Task<IInviteMetadata> CreateInviteAsync(int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) | ||||
| => await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, isUnique, options).ConfigureAwait(false); | |||||
| => await ChannelHelper.CreateInviteAsync(this, Client, maxAge, maxUses, isTemporary, isUnique, options).ConfigureAwait(false); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public async Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null) | public async Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null) | ||||
| => await ChannelHelper.GetInvitesAsync(this, Discord, options).ConfigureAwait(false); | |||||
| => await ChannelHelper.GetInvitesAsync(this, Client, options).ConfigureAwait(false); | |||||
| private string DebuggerDisplay => $"{Name} ({Id}, Voice)"; | private string DebuggerDisplay => $"{Name} ({Id}, Voice)"; | ||||
| internal new SocketVoiceChannel Clone() => MemberwiseClone() as SocketVoiceChannel; | internal new SocketVoiceChannel Clone() => MemberwiseClone() as SocketVoiceChannel; | ||||
| @@ -197,7 +197,7 @@ namespace Discord.WebSocket | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the current logged-in user. | /// Gets the current logged-in user. | ||||
| /// </summary> | /// </summary> | ||||
| public SocketGuildUser CurrentUser => _members.TryGetValue(Discord.CurrentUser.Id, out SocketGuildUser member) ? member : null; | |||||
| public SocketGuildUser CurrentUser => _members.TryGetValue(Client.CurrentUser.Id, out SocketGuildUser member) ? member : null; | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the built-in role containing all users in this guild. | /// Gets the built-in role containing all users in this guild. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -216,7 +216,7 @@ namespace Discord.WebSocket | |||||
| get | get | ||||
| { | { | ||||
| var channels = _channels; | var channels = _channels; | ||||
| var state = Discord.State; | |||||
| var state = Client.State; | |||||
| return channels.Select(x => state.GetChannel(x) as SocketGuildChannel).Where(x => x != null).ToReadOnlyCollection(channels); | return channels.Select(x => state.GetChannel(x) as SocketGuildChannel).Where(x => x != null).ToReadOnlyCollection(channels); | ||||
| } | } | ||||
| } | } | ||||
| @@ -416,27 +416,27 @@ namespace Discord.WebSocket | |||||
| //General | //General | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteAsync(RequestOptions options = null) | public Task DeleteAsync(RequestOptions options = null) | ||||
| => GuildHelper.DeleteAsync(this, Discord, options); | |||||
| => GuildHelper.DeleteAsync(this, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | ||||
| public Task ModifyAsync(Action<GuildProperties> func, RequestOptions options = null) | public Task ModifyAsync(Action<GuildProperties> func, RequestOptions options = null) | ||||
| => GuildHelper.ModifyAsync(this, Discord, func, options); | |||||
| => GuildHelper.ModifyAsync(this, Client, func, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | ||||
| public Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null) | public Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null) | ||||
| => GuildHelper.ModifyEmbedAsync(this, Discord, func, options); | |||||
| => GuildHelper.ModifyEmbedAsync(this, Client, func, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task ReorderChannelsAsync(IEnumerable<ReorderChannelProperties> args, RequestOptions options = null) | public Task ReorderChannelsAsync(IEnumerable<ReorderChannelProperties> args, RequestOptions options = null) | ||||
| => GuildHelper.ReorderChannelsAsync(this, Discord, args, options); | |||||
| => GuildHelper.ReorderChannelsAsync(this, Client, args, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task ReorderRolesAsync(IEnumerable<ReorderRoleProperties> args, RequestOptions options = null) | public Task ReorderRolesAsync(IEnumerable<ReorderRoleProperties> args, RequestOptions options = null) | ||||
| => GuildHelper.ReorderRolesAsync(this, Discord, args, options); | |||||
| => GuildHelper.ReorderRolesAsync(this, Client, args, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task LeaveAsync(RequestOptions options = null) | public Task LeaveAsync(RequestOptions options = null) | ||||
| => GuildHelper.LeaveAsync(this, Discord, options); | |||||
| => GuildHelper.LeaveAsync(this, Client, options); | |||||
| //Bans | //Bans | ||||
| /// <summary> | /// <summary> | ||||
| @@ -449,7 +449,7 @@ namespace Discord.WebSocket | |||||
| /// behind the ban. | /// behind the ban. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<IReadOnlyCollection<RestBan>> GetBansAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestBan>> GetBansAsync(RequestOptions options = null) | ||||
| => GuildHelper.GetBansAsync(this, Discord, options); | |||||
| => GuildHelper.GetBansAsync(this, Client, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a ban object for a banned user. | /// Gets a ban object for a banned user. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -460,7 +460,7 @@ namespace Discord.WebSocket | |||||
| /// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | /// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<RestBan> GetBanAsync(IUser user, RequestOptions options = null) | public Task<RestBan> GetBanAsync(IUser user, RequestOptions options = null) | ||||
| => GuildHelper.GetBanAsync(this, Discord, user.Id, options); | |||||
| => GuildHelper.GetBanAsync(this, Client, user.Id, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a ban object for a banned user. | /// Gets a ban object for a banned user. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -471,21 +471,21 @@ namespace Discord.WebSocket | |||||
| /// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | /// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<RestBan> GetBanAsync(ulong userId, RequestOptions options = null) | public Task<RestBan> GetBanAsync(ulong userId, RequestOptions options = null) | ||||
| => GuildHelper.GetBanAsync(this, Discord, userId, options); | |||||
| => GuildHelper.GetBanAsync(this, Client, userId, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task AddBanAsync(IUser user, int pruneDays = 0, string reason = null, RequestOptions options = null) | public Task AddBanAsync(IUser user, int pruneDays = 0, string reason = null, RequestOptions options = null) | ||||
| => GuildHelper.AddBanAsync(this, Discord, user.Id, pruneDays, reason, options); | |||||
| => GuildHelper.AddBanAsync(this, Client, user.Id, pruneDays, reason, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task AddBanAsync(ulong userId, int pruneDays = 0, string reason = null, RequestOptions options = null) | public Task AddBanAsync(ulong userId, int pruneDays = 0, string reason = null, RequestOptions options = null) | ||||
| => GuildHelper.AddBanAsync(this, Discord, userId, pruneDays, reason, options); | |||||
| => GuildHelper.AddBanAsync(this, Client, userId, pruneDays, reason, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task RemoveBanAsync(IUser user, RequestOptions options = null) | public Task RemoveBanAsync(IUser user, RequestOptions options = null) | ||||
| => GuildHelper.RemoveBanAsync(this, Discord, user.Id, options); | |||||
| => GuildHelper.RemoveBanAsync(this, Client, user.Id, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task RemoveBanAsync(ulong userId, RequestOptions options = null) | public Task RemoveBanAsync(ulong userId, RequestOptions options = null) | ||||
| => GuildHelper.RemoveBanAsync(this, Discord, userId, options); | |||||
| => GuildHelper.RemoveBanAsync(this, Client, userId, options); | |||||
| //Channels | //Channels | ||||
| /// <summary> | /// <summary> | ||||
| @@ -497,7 +497,7 @@ namespace Discord.WebSocket | |||||
| /// </returns> | /// </returns> | ||||
| public SocketGuildChannel GetChannel(ulong id) | public SocketGuildChannel GetChannel(ulong id) | ||||
| { | { | ||||
| var channel = Discord.State.GetChannel(id) as SocketGuildChannel; | |||||
| var channel = Client.State.GetChannel(id) as SocketGuildChannel; | |||||
| if (channel?.Guild.Id == Id) | if (channel?.Guild.Id == Id) | ||||
| return channel; | return channel; | ||||
| return null; | return null; | ||||
| @@ -545,7 +545,7 @@ namespace Discord.WebSocket | |||||
| /// text channel. | /// text channel. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<RestTextChannel> CreateTextChannelAsync(string name, Action<TextChannelProperties> func = null, RequestOptions options = null) | public Task<RestTextChannel> CreateTextChannelAsync(string name, Action<TextChannelProperties> func = null, RequestOptions options = null) | ||||
| => GuildHelper.CreateTextChannelAsync(this, Discord, name, options, func); | |||||
| => GuildHelper.CreateTextChannelAsync(this, Client, name, options, func); | |||||
| /// <summary> | /// <summary> | ||||
| /// Creates a new voice channel in this guild. | /// Creates a new voice channel in this guild. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -558,7 +558,7 @@ namespace Discord.WebSocket | |||||
| /// voice channel. | /// voice channel. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<RestVoiceChannel> CreateVoiceChannelAsync(string name, Action<VoiceChannelProperties> func = null, RequestOptions options = null) | public Task<RestVoiceChannel> CreateVoiceChannelAsync(string name, Action<VoiceChannelProperties> func = null, RequestOptions options = null) | ||||
| => GuildHelper.CreateVoiceChannelAsync(this, Discord, name, options, func); | |||||
| => GuildHelper.CreateVoiceChannelAsync(this, Client, name, options, func); | |||||
| /// <summary> | /// <summary> | ||||
| /// Creates a new channel category in this guild. | /// Creates a new channel category in this guild. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -571,7 +571,7 @@ namespace Discord.WebSocket | |||||
| /// category channel. | /// category channel. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<RestCategoryChannel> CreateCategoryChannelAsync(string name, Action<GuildChannelProperties> func = null, RequestOptions options = null) | public Task<RestCategoryChannel> CreateCategoryChannelAsync(string name, Action<GuildChannelProperties> func = null, RequestOptions options = null) | ||||
| => GuildHelper.CreateCategoryChannelAsync(this, Discord, name, options, func); | |||||
| => GuildHelper.CreateCategoryChannelAsync(this, Client, name, options, func); | |||||
| internal SocketGuildChannel AddChannel(ClientState state, ChannelModel model) | internal SocketGuildChannel AddChannel(ClientState state, ChannelModel model) | ||||
| { | { | ||||
| @@ -597,13 +597,13 @@ namespace Discord.WebSocket | |||||
| /// voice regions the guild can access. | /// voice regions the guild can access. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestVoiceRegion>> GetVoiceRegionsAsync(RequestOptions options = null) | ||||
| => GuildHelper.GetVoiceRegionsAsync(this, Discord, options); | |||||
| => GuildHelper.GetVoiceRegionsAsync(this, Client, options); | |||||
| //Integrations | //Integrations | ||||
| public Task<IReadOnlyCollection<RestGuildIntegration>> GetIntegrationsAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestGuildIntegration>> GetIntegrationsAsync(RequestOptions options = null) | ||||
| => GuildHelper.GetIntegrationsAsync(this, Discord, options); | |||||
| => GuildHelper.GetIntegrationsAsync(this, Client, options); | |||||
| public Task<RestGuildIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null) | public Task<RestGuildIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null) | ||||
| => GuildHelper.CreateIntegrationAsync(this, Discord, id, type, options); | |||||
| => GuildHelper.CreateIntegrationAsync(this, Client, id, type, options); | |||||
| //Invites | //Invites | ||||
| /// <summary> | /// <summary> | ||||
| @@ -615,7 +615,7 @@ namespace Discord.WebSocket | |||||
| /// invite metadata, each representing information for an invite found within this guild. | /// invite metadata, each representing information for an invite found within this guild. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null) | ||||
| => GuildHelper.GetInvitesAsync(this, Discord, options); | |||||
| => GuildHelper.GetInvitesAsync(this, Client, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the vanity invite URL of this guild. | /// Gets the vanity invite URL of this guild. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -625,7 +625,7 @@ namespace Discord.WebSocket | |||||
| /// the vanity invite found within this guild; <c>null</c> if none is found. | /// the vanity invite found within this guild; <c>null</c> if none is found. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<RestInviteMetadata> GetVanityInviteAsync(RequestOptions options = null) | public Task<RestInviteMetadata> GetVanityInviteAsync(RequestOptions options = null) | ||||
| => GuildHelper.GetVanityInviteAsync(this, Discord, options); | |||||
| => GuildHelper.GetVanityInviteAsync(this, Client, options); | |||||
| //Roles | //Roles | ||||
| /// <summary> | /// <summary> | ||||
| @@ -657,10 +657,10 @@ namespace Discord.WebSocket | |||||
| /// </returns> | /// </returns> | ||||
| public Task<RestRole> CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?), | public Task<RestRole> CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?), | ||||
| bool isHoisted = false, RequestOptions options = null) | bool isHoisted = false, RequestOptions options = null) | ||||
| => GuildHelper.CreateRoleAsync(this, Discord, name, permissions, color, isHoisted, options); | |||||
| => GuildHelper.CreateRoleAsync(this, Client, name, permissions, color, isHoisted, options); | |||||
| internal SocketRole AddRole(RoleModel model) | internal SocketRole AddRole(RoleModel model) | ||||
| { | { | ||||
| var role = SocketRole.Create(this, Discord.State, model); | |||||
| var role = SocketRole.Create(this, Client.State, model); | |||||
| _roles[model.Id] = role; | _roles[model.Id] = role; | ||||
| return role; | return role; | ||||
| } | } | ||||
| @@ -674,7 +674,7 @@ namespace Discord.WebSocket | |||||
| //Users | //Users | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task<RestGuildUser> AddGuildUserAsync(ulong id, string accessToken, Action<AddGuildUserProperties> func = null, RequestOptions options = null) | public Task<RestGuildUser> AddGuildUserAsync(ulong id, string accessToken, Action<AddGuildUserProperties> func = null, RequestOptions options = null) | ||||
| => GuildHelper.AddGuildUserAsync(this, Discord, id, accessToken, func, options); | |||||
| => GuildHelper.AddGuildUserAsync(this, Client, id, accessToken, func, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a user from this guild. | /// Gets a user from this guild. | ||||
| @@ -698,15 +698,15 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task<int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null) | public Task<int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null) | ||||
| => GuildHelper.PruneUsersAsync(this, Discord, days, simulate, options); | |||||
| => GuildHelper.PruneUsersAsync(this, Client, days, simulate, options); | |||||
| internal SocketGuildUser AddOrUpdateUser(UserModel model) | internal SocketGuildUser AddOrUpdateUser(UserModel model) | ||||
| { | { | ||||
| if (_members.TryGetValue(model.Id, out SocketGuildUser member)) | if (_members.TryGetValue(model.Id, out SocketGuildUser member)) | ||||
| member.GlobalUser?.Update(Discord.State, model); | |||||
| member.GlobalUser?.Update(Client.State, model); | |||||
| else | else | ||||
| { | { | ||||
| member = SocketGuildUser.Create(this, Discord.State, model); | |||||
| member = SocketGuildUser.Create(this, Client.State, model); | |||||
| member.GlobalUser.AddRef(); | member.GlobalUser.AddRef(); | ||||
| _members[member.Id] = member; | _members[member.Id] = member; | ||||
| DownloadedMemberCount++; | DownloadedMemberCount++; | ||||
| @@ -716,10 +716,10 @@ namespace Discord.WebSocket | |||||
| internal SocketGuildUser AddOrUpdateUser(MemberModel model) | internal SocketGuildUser AddOrUpdateUser(MemberModel model) | ||||
| { | { | ||||
| if (_members.TryGetValue(model.User.Id, out SocketGuildUser member)) | if (_members.TryGetValue(model.User.Id, out SocketGuildUser member)) | ||||
| member.Update(Discord.State, model); | |||||
| member.Update(Client.State, model); | |||||
| else | else | ||||
| { | { | ||||
| member = SocketGuildUser.Create(this, Discord.State, model); | |||||
| member = SocketGuildUser.Create(this, Client.State, model); | |||||
| member.GlobalUser.AddRef(); | member.GlobalUser.AddRef(); | ||||
| _members[member.Id] = member; | _members[member.Id] = member; | ||||
| DownloadedMemberCount++; | DownloadedMemberCount++; | ||||
| @@ -729,10 +729,10 @@ namespace Discord.WebSocket | |||||
| internal SocketGuildUser AddOrUpdateUser(PresenceModel model) | internal SocketGuildUser AddOrUpdateUser(PresenceModel model) | ||||
| { | { | ||||
| if (_members.TryGetValue(model.User.Id, out SocketGuildUser member)) | if (_members.TryGetValue(model.User.Id, out SocketGuildUser member)) | ||||
| member.Update(Discord.State, model, false); | |||||
| member.Update(Client.State, model, false); | |||||
| else | else | ||||
| { | { | ||||
| member = SocketGuildUser.Create(this, Discord.State, model); | |||||
| member = SocketGuildUser.Create(this, Client.State, model); | |||||
| member.GlobalUser.AddRef(); | member.GlobalUser.AddRef(); | ||||
| _members[member.Id] = member; | _members[member.Id] = member; | ||||
| DownloadedMemberCount++; | DownloadedMemberCount++; | ||||
| @@ -744,7 +744,7 @@ namespace Discord.WebSocket | |||||
| if (_members.TryRemove(id, out SocketGuildUser member)) | if (_members.TryRemove(id, out SocketGuildUser member)) | ||||
| { | { | ||||
| DownloadedMemberCount--; | DownloadedMemberCount--; | ||||
| member.GlobalUser.RemoveRef(Discord); | |||||
| member.GlobalUser.RemoveRef(Client); | |||||
| return member; | return member; | ||||
| } | } | ||||
| return null; | return null; | ||||
| @@ -753,7 +753,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public async Task DownloadUsersAsync() | public async Task DownloadUsersAsync() | ||||
| { | { | ||||
| await Discord.DownloadUsersAsync(new[] { this }).ConfigureAwait(false); | |||||
| await Client.DownloadUsersAsync(new[] { this }).ConfigureAwait(false); | |||||
| } | } | ||||
| internal void CompleteDownloadUsers() | internal void CompleteDownloadUsers() | ||||
| { | { | ||||
| @@ -771,7 +771,7 @@ namespace Discord.WebSocket | |||||
| /// of the requested audit log entries. | /// of the requested audit log entries. | ||||
| /// </returns> | /// </returns> | ||||
| public IAsyncEnumerable<IReadOnlyCollection<RestAuditLogEntry>> GetAuditLogsAsync(int limit, RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<RestAuditLogEntry>> GetAuditLogsAsync(int limit, RequestOptions options = null) | ||||
| => GuildHelper.GetAuditLogsAsync(this, Discord, null, limit, options); | |||||
| => GuildHelper.GetAuditLogsAsync(this, Client, null, limit, options); | |||||
| //Webhooks | //Webhooks | ||||
| /// <summary> | /// <summary> | ||||
| @@ -784,7 +784,7 @@ namespace Discord.WebSocket | |||||
| /// specified <paramref name="id"/>; <c>null</c> if none is found. | /// specified <paramref name="id"/>; <c>null</c> if none is found. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) | public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) | ||||
| => GuildHelper.GetWebhookAsync(this, Discord, id, options); | |||||
| => GuildHelper.GetWebhookAsync(this, Client, id, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of all webhook from this guild. | /// Gets a collection of all webhook from this guild. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -794,22 +794,22 @@ namespace Discord.WebSocket | |||||
| /// of webhooks found within the guild. | /// of webhooks found within the guild. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<IReadOnlyCollection<RestWebhook>> GetWebhooksAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestWebhook>> GetWebhooksAsync(RequestOptions options = null) | ||||
| => GuildHelper.GetWebhooksAsync(this, Discord, options); | |||||
| => GuildHelper.GetWebhooksAsync(this, Client, options); | |||||
| //Emotes | //Emotes | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task<GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null) | public Task<GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null) | ||||
| => GuildHelper.GetEmoteAsync(this, Discord, id, options); | |||||
| => GuildHelper.GetEmoteAsync(this, Client, id, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null) | public Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null) | ||||
| => GuildHelper.CreateEmoteAsync(this, Discord, name, image, roles, options); | |||||
| => GuildHelper.CreateEmoteAsync(this, Client, name, image, roles, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | ||||
| public Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null) | public Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null) | ||||
| => GuildHelper.ModifyEmoteAsync(this, Discord, emote.Id, func, options); | |||||
| => GuildHelper.ModifyEmoteAsync(this, Client, emote.Id, func, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null) | public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null) | ||||
| => GuildHelper.DeleteEmoteAsync(this, Discord, emote.Id, options); | |||||
| => GuildHelper.DeleteEmoteAsync(this, Client, emote.Id, options); | |||||
| //Voice States | //Voice States | ||||
| internal async Task<SocketVoiceState> AddOrUpdateVoiceStateAsync(ClientState state, VoiceStateModel model) | internal async Task<SocketVoiceState> AddOrUpdateVoiceStateAsync(ClientState state, VoiceStateModel model) | ||||
| @@ -876,14 +876,14 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| #pragma warning disable IDISP001 | #pragma warning disable IDISP001 | ||||
| var _ = promise.TrySetResultAsync(null); | var _ = promise.TrySetResultAsync(null); | ||||
| await Discord.ApiClient.SendVoiceStateUpdateAsync(Id, channelId, selfDeaf, selfMute).ConfigureAwait(false); | |||||
| await Client.ApiClient.SendVoiceStateUpdateAsync(Id, channelId, selfDeaf, selfMute).ConfigureAwait(false); | |||||
| return null; | return null; | ||||
| #pragma warning restore IDISP001 | #pragma warning restore IDISP001 | ||||
| } | } | ||||
| if (_audioClient == null) | if (_audioClient == null) | ||||
| { | { | ||||
| var audioClient = new AudioClient(this, Discord.GetAudioId(), channelId); | |||||
| var audioClient = new AudioClient(this, Client.GetAudioId(), channelId); | |||||
| audioClient.Disconnected += async ex => | audioClient.Disconnected += async ex => | ||||
| { | { | ||||
| if (!promise.Task.IsCompleted) | if (!promise.Task.IsCompleted) | ||||
| @@ -911,7 +911,7 @@ namespace Discord.WebSocket | |||||
| #pragma warning restore IDISP003 | #pragma warning restore IDISP003 | ||||
| } | } | ||||
| await Discord.ApiClient.SendVoiceStateUpdateAsync(Id, channelId, selfDeaf, selfMute).ConfigureAwait(false); | |||||
| await Client.ApiClient.SendVoiceStateUpdateAsync(Id, channelId, selfDeaf, selfMute).ConfigureAwait(false); | |||||
| } | } | ||||
| catch | catch | ||||
| { | { | ||||
| @@ -955,14 +955,14 @@ namespace Discord.WebSocket | |||||
| _audioConnectPromise = null; | _audioConnectPromise = null; | ||||
| if (_audioClient != null) | if (_audioClient != null) | ||||
| await _audioClient.StopAsync().ConfigureAwait(false); | await _audioClient.StopAsync().ConfigureAwait(false); | ||||
| await Discord.ApiClient.SendVoiceStateUpdateAsync(Id, null, false, false).ConfigureAwait(false); | |||||
| await Client.ApiClient.SendVoiceStateUpdateAsync(Id, null, false, false).ConfigureAwait(false); | |||||
| _audioClient?.Dispose(); | _audioClient?.Dispose(); | ||||
| _audioClient = null; | _audioClient = null; | ||||
| } | } | ||||
| internal async Task FinishConnectAudio(string url, string token) | internal async Task FinishConnectAudio(string url, string token) | ||||
| { | { | ||||
| //TODO: Mem Leak: Disconnected/Connected handlers arent cleaned up | //TODO: Mem Leak: Disconnected/Connected handlers arent cleaned up | ||||
| var voiceState = GetVoiceState(Discord.CurrentUser.Id).Value; | |||||
| var voiceState = GetVoiceState(Client.CurrentUser.Id).Value; | |||||
| await _audioLock.WaitAsync().ConfigureAwait(false); | await _audioLock.WaitAsync().ConfigureAwait(false); | ||||
| try | try | ||||
| @@ -970,7 +970,7 @@ namespace Discord.WebSocket | |||||
| if (_audioClient != null) | if (_audioClient != null) | ||||
| { | { | ||||
| await RepopulateAudioStreamsAsync().ConfigureAwait(false); | await RepopulateAudioStreamsAsync().ConfigureAwait(false); | ||||
| await _audioClient.StartAsync(url, Discord.CurrentUser.Id, voiceState.VoiceSessionId, token).ConfigureAwait(false); | |||||
| await _audioClient.StartAsync(url, Client.CurrentUser.Id, voiceState.VoiceSessionId, token).ConfigureAwait(false); | |||||
| } | } | ||||
| } | } | ||||
| catch (OperationCanceledException) | catch (OperationCanceledException) | ||||
| @@ -139,7 +139,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteAsync(RequestOptions options = null) | public Task DeleteAsync(RequestOptions options = null) | ||||
| => MessageHelper.DeleteAsync(this, Discord, options); | |||||
| => MessageHelper.DeleteAsync(this, Client, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the content of the message. | /// Gets the content of the message. | ||||
| @@ -41,7 +41,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public override IReadOnlyCollection<SocketUser> MentionedUsers => MessageHelper.FilterTagsByValue<SocketUser>(TagType.UserMention, _tags); | public override IReadOnlyCollection<SocketUser> MentionedUsers => MessageHelper.FilterTagsByValue<SocketUser>(TagType.UserMention, _tags); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IReadOnlyDictionary<IEmote, ReactionMetadata> Reactions => _reactions.GroupBy(r => r.Emote).ToDictionary(x => x.Key, x => new ReactionMetadata { ReactionCount = x.Count(), IsMe = x.Any(y => y.UserId == Discord.CurrentUser.Id) }); | |||||
| public IReadOnlyDictionary<IEmote, ReactionMetadata> Reactions => _reactions.GroupBy(r => r.Emote).ToDictionary(x => x.Key, x => new ReactionMetadata { ReactionCount = x.Count(), IsMe = x.Any(y => y.UserId == Client.CurrentUser.Id) }); | |||||
| internal SocketUserMessage(DiscordSocketClient discord, ulong id, ISocketMessageChannel channel, SocketUser author, MessageSource source) | internal SocketUserMessage(DiscordSocketClient discord, ulong id, ISocketMessageChannel channel, SocketUser author, MessageSource source) | ||||
| : base(discord, id, channel, author, source) | : base(discord, id, channel, author, source) | ||||
| @@ -106,7 +106,7 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| var val = value[i]; | var val = value[i]; | ||||
| if (val.Object != null) | if (val.Object != null) | ||||
| newMentions.Add(SocketUnknownUser.Create(Discord, state, val.Object)); | |||||
| newMentions.Add(SocketUnknownUser.Create(Client, state, val.Object)); | |||||
| } | } | ||||
| mentions = newMentions.ToImmutable(); | mentions = newMentions.ToImmutable(); | ||||
| } | } | ||||
| @@ -138,27 +138,27 @@ namespace Discord.WebSocket | |||||
| /// <exception cref="InvalidOperationException">Only the author of a message may modify the message.</exception> | /// <exception cref="InvalidOperationException">Only the author of a message may modify the message.</exception> | ||||
| /// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | /// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> | ||||
| public Task ModifyAsync(Action<MessageProperties> func, RequestOptions options = null) | public Task ModifyAsync(Action<MessageProperties> func, RequestOptions options = null) | ||||
| => MessageHelper.ModifyAsync(this, Discord, func, options); | |||||
| => MessageHelper.ModifyAsync(this, Client, func, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task AddReactionAsync(IEmote emote, RequestOptions options = null) | public Task AddReactionAsync(IEmote emote, RequestOptions options = null) | ||||
| => MessageHelper.AddReactionAsync(this, emote, Discord, options); | |||||
| => MessageHelper.AddReactionAsync(this, emote, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task RemoveReactionAsync(IEmote emote, IUser user, RequestOptions options = null) | public Task RemoveReactionAsync(IEmote emote, IUser user, RequestOptions options = null) | ||||
| => MessageHelper.RemoveReactionAsync(this, user, emote, Discord, options); | |||||
| => MessageHelper.RemoveReactionAsync(this, user, emote, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task RemoveAllReactionsAsync(RequestOptions options = null) | public Task RemoveAllReactionsAsync(RequestOptions options = null) | ||||
| => MessageHelper.RemoveAllReactionsAsync(this, Discord, options); | |||||
| => MessageHelper.RemoveAllReactionsAsync(this, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public IAsyncEnumerable<IReadOnlyCollection<IUser>> GetReactionUsersAsync(IEmote emote, int limit, RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<IUser>> GetReactionUsersAsync(IEmote emote, int limit, RequestOptions options = null) | ||||
| => MessageHelper.GetReactionUsersAsync(this, emote, limit, Discord, options); | |||||
| => MessageHelper.GetReactionUsersAsync(this, emote, limit, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task PinAsync(RequestOptions options = null) | public Task PinAsync(RequestOptions options = null) | ||||
| => MessageHelper.PinAsync(this, Discord, options); | |||||
| => MessageHelper.PinAsync(this, Client, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task UnpinAsync(RequestOptions options = null) | public Task UnpinAsync(RequestOptions options = null) | ||||
| => MessageHelper.UnpinAsync(this, Discord, options); | |||||
| => MessageHelper.UnpinAsync(this, Client, options); | |||||
| public string Resolve(int startIndex, TagHandling userHandling = TagHandling.Name, TagHandling channelHandling = TagHandling.Name, | public string Resolve(int startIndex, TagHandling userHandling = TagHandling.Name, TagHandling channelHandling = TagHandling.Name, | ||||
| TagHandling roleHandling = TagHandling.Name, TagHandling everyoneHandling = TagHandling.Ignore, TagHandling emojiHandling = TagHandling.Name) | TagHandling roleHandling = TagHandling.Name, TagHandling everyoneHandling = TagHandling.Ignore, TagHandling emojiHandling = TagHandling.Name) | ||||
| @@ -52,7 +52,7 @@ namespace Discord.WebSocket | |||||
| => Guild.Users.Where(x => x.Roles.Any(r => r.Id == Id)); | => Guild.Users.Where(x => x.Roles.Any(r => r.Id == Id)); | ||||
| internal SocketRole(SocketGuild guild, ulong id) | internal SocketRole(SocketGuild guild, ulong id) | ||||
| : base(guild.Discord, id) | |||||
| : base(guild.Client, id) | |||||
| { | { | ||||
| Guild = guild; | Guild = guild; | ||||
| } | } | ||||
| @@ -75,10 +75,10 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task ModifyAsync(Action<RoleProperties> func, RequestOptions options = null) | public Task ModifyAsync(Action<RoleProperties> func, RequestOptions options = null) | ||||
| => RoleHelper.ModifyAsync(this, Discord, func, options); | |||||
| => RoleHelper.ModifyAsync(this, Client, func, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task DeleteAsync(RequestOptions options = null) | public Task DeleteAsync(RequestOptions options = null) | ||||
| => RoleHelper.DeleteAsync(this, Discord, options); | |||||
| => RoleHelper.DeleteAsync(this, Client, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the name of the role. | /// Gets the name of the role. | ||||
| @@ -5,13 +5,13 @@ namespace Discord.WebSocket | |||||
| public abstract class SocketEntity<T> : IEntity<T> | public abstract class SocketEntity<T> : IEntity<T> | ||||
| where T : IEquatable<T> | where T : IEquatable<T> | ||||
| { | { | ||||
| internal DiscordSocketClient Discord { get; } | |||||
| public DiscordSocketClient Client { get; } | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public T Id { get; } | public T Id { get; } | ||||
| internal SocketEntity(DiscordSocketClient discord, T id) | internal SocketEntity(DiscordSocketClient discord, T id) | ||||
| { | { | ||||
| Discord = discord; | |||||
| Client = discord; | |||||
| Id = id; | Id = id; | ||||
| } | } | ||||
| } | } | ||||
| @@ -31,14 +31,14 @@ namespace Discord.WebSocket | |||||
| public override bool IsWebhook => false; | public override bool IsWebhook => false; | ||||
| internal SocketGroupUser(SocketGroupChannel channel, SocketGlobalUser globalUser) | internal SocketGroupUser(SocketGroupChannel channel, SocketGlobalUser globalUser) | ||||
| : base(channel.Discord, globalUser.Id) | |||||
| : base(channel.Client, globalUser.Id) | |||||
| { | { | ||||
| Channel = channel; | Channel = channel; | ||||
| GlobalUser = globalUser; | GlobalUser = globalUser; | ||||
| } | } | ||||
| internal static SocketGroupUser Create(SocketGroupChannel channel, ClientState state, Model model) | internal static SocketGroupUser Create(SocketGroupChannel channel, ClientState state, Model model) | ||||
| { | { | ||||
| var entity = new SocketGroupUser(channel, channel.Discord.GetOrCreateUser(state, model)); | |||||
| var entity = new SocketGroupUser(channel, channel.Client.GetOrCreateUser(state, model)); | |||||
| entity.Update(state, model); | entity.Update(state, model); | ||||
| return entity; | return entity; | ||||
| } | } | ||||
| @@ -102,27 +102,27 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| internal SocketGuildUser(SocketGuild guild, SocketGlobalUser globalUser) | internal SocketGuildUser(SocketGuild guild, SocketGlobalUser globalUser) | ||||
| : base(guild.Discord, globalUser.Id) | |||||
| : base(guild.Client, globalUser.Id) | |||||
| { | { | ||||
| Guild = guild; | Guild = guild; | ||||
| GlobalUser = globalUser; | GlobalUser = globalUser; | ||||
| } | } | ||||
| internal static SocketGuildUser Create(SocketGuild guild, ClientState state, UserModel model) | internal static SocketGuildUser Create(SocketGuild guild, ClientState state, UserModel model) | ||||
| { | { | ||||
| var entity = new SocketGuildUser(guild, guild.Discord.GetOrCreateUser(state, model)); | |||||
| var entity = new SocketGuildUser(guild, guild.Client.GetOrCreateUser(state, model)); | |||||
| entity.Update(state, model); | entity.Update(state, model); | ||||
| entity.UpdateRoles(new ulong[0]); | entity.UpdateRoles(new ulong[0]); | ||||
| return entity; | return entity; | ||||
| } | } | ||||
| internal static SocketGuildUser Create(SocketGuild guild, ClientState state, MemberModel model) | internal static SocketGuildUser Create(SocketGuild guild, ClientState state, MemberModel model) | ||||
| { | { | ||||
| var entity = new SocketGuildUser(guild, guild.Discord.GetOrCreateUser(state, model.User)); | |||||
| var entity = new SocketGuildUser(guild, guild.Client.GetOrCreateUser(state, model.User)); | |||||
| entity.Update(state, model); | entity.Update(state, model); | ||||
| return entity; | return entity; | ||||
| } | } | ||||
| internal static SocketGuildUser Create(SocketGuild guild, ClientState state, PresenceModel model) | internal static SocketGuildUser Create(SocketGuild guild, ClientState state, PresenceModel model) | ||||
| { | { | ||||
| var entity = new SocketGuildUser(guild, guild.Discord.GetOrCreateUser(state, model.User)); | |||||
| var entity = new SocketGuildUser(guild, guild.Client.GetOrCreateUser(state, model.User)); | |||||
| entity.Update(state, model, false); | entity.Update(state, model, false); | ||||
| return entity; | return entity; | ||||
| } | } | ||||
| @@ -159,22 +159,22 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task ModifyAsync(Action<GuildUserProperties> func, RequestOptions options = null) | public Task ModifyAsync(Action<GuildUserProperties> func, RequestOptions options = null) | ||||
| => UserHelper.ModifyAsync(this, Discord, func, options); | |||||
| => UserHelper.ModifyAsync(this, Client, func, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task KickAsync(string reason = null, RequestOptions options = null) | public Task KickAsync(string reason = null, RequestOptions options = null) | ||||
| => UserHelper.KickAsync(this, Discord, reason, options); | |||||
| => UserHelper.KickAsync(this, Client, reason, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task AddRoleAsync(IRole role, RequestOptions options = null) | public Task AddRoleAsync(IRole role, RequestOptions options = null) | ||||
| => AddRolesAsync(new[] { role }, options); | => AddRolesAsync(new[] { role }, options); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null) | public Task AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null) | ||||
| => UserHelper.AddRolesAsync(this, Discord, roles, options); | |||||
| => UserHelper.AddRolesAsync(this, Client, roles, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task RemoveRoleAsync(IRole role, RequestOptions options = null) | public Task RemoveRoleAsync(IRole role, RequestOptions options = null) | ||||
| => RemoveRolesAsync(new[] { role }, options); | => RemoveRolesAsync(new[] { role }, options); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task RemoveRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null) | public Task RemoveRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null) | ||||
| => UserHelper.RemoveRolesAsync(this, Discord, roles, options); | |||||
| => UserHelper.RemoveRolesAsync(this, Client, roles, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public ChannelPermissions GetPermissions(IGuildChannel channel) | public ChannelPermissions GetPermissions(IGuildChannel channel) | ||||
| @@ -68,7 +68,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task ModifyAsync(Action<SelfUserProperties> func, RequestOptions options = null) | public Task ModifyAsync(Action<SelfUserProperties> func, RequestOptions options = null) | ||||
| => UserHelper.ModifyAsync(this, Discord, func, options); | |||||
| => UserHelper.ModifyAsync(this, Client, func, options); | |||||
| private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")}, Self)"; | private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")}, Self)"; | ||||
| internal new SocketSelfUser Clone() => MemberwiseClone() as SocketSelfUser; | internal new SocketSelfUser Clone() => MemberwiseClone() as SocketSelfUser; | ||||
| @@ -42,7 +42,7 @@ namespace Discord.WebSocket | |||||
| /// Gets mutual guilds shared with this user. | /// Gets mutual guilds shared with this user. | ||||
| /// </summary> | /// </summary> | ||||
| public IReadOnlyCollection<SocketGuild> MutualGuilds | public IReadOnlyCollection<SocketGuild> MutualGuilds | ||||
| => Discord.Guilds.Where(g => g.Users.Any(u => u.Id == Id)).ToImmutableArray(); | |||||
| => Client.Guilds.Where(g => g.Users.Any(u => u.Id == Id)).ToImmutableArray(); | |||||
| internal SocketUser(DiscordSocketClient discord, ulong id) | internal SocketUser(DiscordSocketClient discord, ulong id) | ||||
| : base(discord, id) | : base(discord, id) | ||||
| @@ -80,7 +80,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public async Task<IDMChannel> GetOrCreateDMChannelAsync(RequestOptions options = null) | public async Task<IDMChannel> GetOrCreateDMChannelAsync(RequestOptions options = null) | ||||
| => GlobalUser.DMChannel ?? await UserHelper.CreateDMChannelAsync(this, Discord, options).ConfigureAwait(false) as IDMChannel; | |||||
| => GlobalUser.DMChannel ?? await UserHelper.CreateDMChannelAsync(this, Client, options).ConfigureAwait(false) as IDMChannel; | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | ||||
| @@ -35,7 +35,7 @@ namespace Discord.WebSocket | |||||
| throw new NotSupportedException(); | throw new NotSupportedException(); | ||||
| internal SocketWebhookUser(SocketGuild guild, ulong id, ulong webhookId) | internal SocketWebhookUser(SocketGuild guild, ulong id, ulong webhookId) | ||||
| : base(guild.Discord, id) | |||||
| : base(guild.Client, id) | |||||
| { | { | ||||
| Guild = guild; | Guild = guild; | ||||
| WebhookId = webhookId; | WebhookId = webhookId; | ||||