From 2be3020689686dcb5ee3e9452b1833ab07104ca8 Mon Sep 17 00:00:00 2001 From: RogueException Date: Mon, 16 May 2016 02:04:49 -0300 Subject: [PATCH] Renamed DiscordRawClient to DiscordAPIClient --- ...iscordRawClient.cs => DiscordAPIClient.cs} | 4 +- .../Common/Entities/Invites/Invite.cs | 4 +- src/Discord.Net/Discord.Net.csproj | 2 +- src/Discord.Net/IDiscordClient.cs | 2 +- src/Discord.Net/Rest/DiscordClient.cs | 56 +++++++++---------- .../Rest/Entities/Channels/DMChannel.cs | 18 +++--- .../Rest/Entities/Channels/GuildChannel.cs | 18 +++--- .../Rest/Entities/Channels/TextChannel.cs | 16 +++--- .../Rest/Entities/Channels/VoiceChannel.cs | 2 +- src/Discord.Net/Rest/Entities/Guilds/Guild.cs | 48 ++++++++-------- .../Rest/Entities/Guilds/GuildIntegration.cs | 6 +- .../Rest/Entities/Guilds/UserGuild.cs | 4 +- src/Discord.Net/Rest/Entities/Message.cs | 8 +-- src/Discord.Net/Rest/Entities/Role.cs | 6 +- .../Rest/Entities/Users/GuildUser.cs | 8 +-- .../Rest/Entities/Users/SelfUser.cs | 4 +- src/Discord.Net/Rest/Entities/Users/User.cs | 2 +- src/Discord.Net/WebSocket/DiscordClient.cs | 2 +- .../WebSocket/Entities/Channels/DMChannel.cs | 12 ++-- .../Entities/Channels/GuildChannel.cs | 16 +++--- .../Entities/Channels/TextChannel.cs | 12 ++-- .../Entities/Channels/VoiceChannel.cs | 2 +- .../WebSocket/Entities/Guilds/Guild.cs | 46 +++++++-------- .../Entities/Guilds/GuildIntegration.cs | 6 +- src/Discord.Net/WebSocket/Entities/Message.cs | 8 +-- src/Discord.Net/WebSocket/Entities/Role.cs | 6 +- .../WebSocket/Entities/Users/GuildUser.cs | 6 +- .../WebSocket/Entities/Users/SelfUser.cs | 2 +- .../WebSocket/Entities/Users/User.cs | 2 +- src/Discord.Net/WebSocket/MessageCache.cs | 2 +- 30 files changed, 165 insertions(+), 165 deletions(-) rename src/Discord.Net/API/{DiscordRawClient.cs => DiscordAPIClient.cs} (99%) diff --git a/src/Discord.Net/API/DiscordRawClient.cs b/src/Discord.Net/API/DiscordAPIClient.cs similarity index 99% rename from src/Discord.Net/API/DiscordRawClient.cs rename to src/Discord.Net/API/DiscordAPIClient.cs index 765078d3c..bf0c1be96 100644 --- a/src/Discord.Net/API/DiscordRawClient.cs +++ b/src/Discord.Net/API/DiscordAPIClient.cs @@ -17,7 +17,7 @@ using System.Threading.Tasks; namespace Discord.API { - public class DiscordRawClient + public class DiscordAPIClient { internal event EventHandler SentRequest; @@ -30,7 +30,7 @@ namespace Discord.API public IRestClient RestClient { get; private set; } public IRequestQueue RequestQueue { get; private set; } - public DiscordRawClient(RestClientProvider restClientProvider) + public DiscordAPIClient(RestClientProvider restClientProvider) { _restClient = restClientProvider(DiscordConfig.ClientAPIUrl); _restClient.SetHeader("accept", "*/*"); diff --git a/src/Discord.Net/Common/Entities/Invites/Invite.cs b/src/Discord.Net/Common/Entities/Invites/Invite.cs index e18bc9079..88bd3b161 100644 --- a/src/Discord.Net/Common/Entities/Invites/Invite.cs +++ b/src/Discord.Net/Common/Entities/Invites/Invite.cs @@ -47,13 +47,13 @@ namespace Discord /// public async Task Accept() { - await Discord.BaseClient.AcceptInvite(Code).ConfigureAwait(false); + await Discord.APIClient.AcceptInvite(Code).ConfigureAwait(false); } /// public async Task Delete() { - await Discord.BaseClient.DeleteInvite(Code).ConfigureAwait(false); + await Discord.APIClient.DeleteInvite(Code).ConfigureAwait(false); } /// diff --git a/src/Discord.Net/Discord.Net.csproj b/src/Discord.Net/Discord.Net.csproj index 7a34de007..45360f3ab 100644 --- a/src/Discord.Net/Discord.Net.csproj +++ b/src/Discord.Net/Discord.Net.csproj @@ -105,7 +105,7 @@ - + diff --git a/src/Discord.Net/IDiscordClient.cs b/src/Discord.Net/IDiscordClient.cs index 068f56bff..e7a1cc31f 100644 --- a/src/Discord.Net/IDiscordClient.cs +++ b/src/Discord.Net/IDiscordClient.cs @@ -10,7 +10,7 @@ namespace Discord public interface IDiscordClient { TokenType AuthTokenType { get; } - DiscordRawClient BaseClient { get; } + DiscordAPIClient APIClient { get; } IRestClient RestClient { get; } IRequestQueue RequestQueue { get; } diff --git a/src/Discord.Net/Rest/DiscordClient.cs b/src/Discord.Net/Rest/DiscordClient.cs index f57f9694c..8cd35dd23 100644 --- a/src/Discord.Net/Rest/DiscordClient.cs +++ b/src/Discord.Net/Rest/DiscordClient.cs @@ -24,11 +24,11 @@ namespace Discord.Rest private SelfUser _currentUser; public bool IsLoggedIn { get; private set; } - public API.DiscordRawClient BaseClient { get; private set; } + public API.DiscordAPIClient APIClient { get; private set; } - public TokenType AuthTokenType => BaseClient.AuthTokenType; - public IRestClient RestClient => BaseClient.RestClient; - public IRequestQueue RequestQueue => BaseClient.RequestQueue; + public TokenType AuthTokenType => APIClient.AuthTokenType; + public IRestClient RestClient => APIClient.RestClient; + public IRequestQueue RequestQueue => APIClient.RequestQueue; public DiscordClient(DiscordConfig config = null) { @@ -40,7 +40,7 @@ namespace Discord.Rest _connectionLock = new SemaphoreSlim(1, 1); _log = new LogManager(config.LogLevel); _userAgent = DiscordConfig.UserAgent; - BaseClient = new API.DiscordRawClient(_restClientProvider); + APIClient = new API.DiscordAPIClient(_restClientProvider); _log.Message += (s,e) => Log.Raise(this, e); } @@ -72,7 +72,7 @@ namespace Discord.Rest _cancelTokenSource = new CancellationTokenSource(); var args = new LoginParams { Email = email, Password = password }; - await BaseClient.Login(args, _cancelTokenSource.Token).ConfigureAwait(false); + await APIClient.Login(args, _cancelTokenSource.Token).ConfigureAwait(false); await CompleteLogin(false).ConfigureAwait(false); } catch { await LogoutInternal().ConfigureAwait(false); throw; } @@ -85,22 +85,22 @@ namespace Discord.Rest { _cancelTokenSource = new CancellationTokenSource(); - await BaseClient.Login(tokenType, token, _cancelTokenSource.Token).ConfigureAwait(false); + await APIClient.Login(tokenType, token, _cancelTokenSource.Token).ConfigureAwait(false); await CompleteLogin(validateToken).ConfigureAwait(false); } catch { await LogoutInternal().ConfigureAwait(false); throw; } } private async Task CompleteLogin(bool validateToken) { - BaseClient.SentRequest += (s, e) => _log.Verbose("Rest", $"{e.Method} {e.Endpoint}: {e.Milliseconds} ms"); + APIClient.SentRequest += (s, e) => _log.Verbose("Rest", $"{e.Method} {e.Endpoint}: {e.Milliseconds} ms"); if (validateToken) { try { - await BaseClient.ValidateToken().ConfigureAwait(false); + await APIClient.ValidateToken().ConfigureAwait(false); } - catch { await BaseClient.Logout().ConfigureAwait(false); } + catch { await APIClient.Logout().ConfigureAwait(false); } } IsLoggedIn = true; @@ -127,7 +127,7 @@ namespace Discord.Rest catch { } } - await BaseClient.Logout().ConfigureAwait(false); + await APIClient.Logout().ConfigureAwait(false); _currentUser = null; if (wasLoggedIn) @@ -139,18 +139,18 @@ namespace Discord.Rest public async Task> GetConnections() { - var models = await BaseClient.GetCurrentUserConnections().ConfigureAwait(false); + var models = await APIClient.GetCurrentUserConnections().ConfigureAwait(false); return models.Select(x => new Connection(x)); } public async Task GetChannel(ulong id) { - var model = await BaseClient.GetChannel(id).ConfigureAwait(false); + var model = await APIClient.GetChannel(id).ConfigureAwait(false); if (model != null) { if (model.GuildId != null) { - var guildModel = await BaseClient.GetGuild(model.GuildId.Value).ConfigureAwait(false); + var guildModel = await APIClient.GetGuild(model.GuildId.Value).ConfigureAwait(false); if (guildModel != null) { var guild = new Guild(this, guildModel); @@ -164,13 +164,13 @@ namespace Discord.Rest } public async Task> GetDMChannels() { - var models = await BaseClient.GetCurrentUserDMs().ConfigureAwait(false); + var models = await APIClient.GetCurrentUserDMs().ConfigureAwait(false); return models.Select(x => new DMChannel(this, x)); } public async Task GetInvite(string inviteIdOrXkcd) { - var model = await BaseClient.GetInvite(inviteIdOrXkcd).ConfigureAwait(false); + var model = await APIClient.GetInvite(inviteIdOrXkcd).ConfigureAwait(false); if (model != null) return new Invite(this, model); return null; @@ -178,41 +178,41 @@ namespace Discord.Rest public async Task GetGuild(ulong id) { - var model = await BaseClient.GetGuild(id).ConfigureAwait(false); + var model = await APIClient.GetGuild(id).ConfigureAwait(false); if (model != null) return new Guild(this, model); return null; } public async Task GetGuildEmbed(ulong id) { - var model = await BaseClient.GetGuildEmbed(id).ConfigureAwait(false); + var model = await APIClient.GetGuildEmbed(id).ConfigureAwait(false); if (model != null) return new GuildEmbed(model); return null; } public async Task> GetGuilds() { - var models = await BaseClient.GetCurrentUserGuilds().ConfigureAwait(false); + var models = await APIClient.GetCurrentUserGuilds().ConfigureAwait(false); return models.Select(x => new UserGuild(this, x)); } public async Task CreateGuild(string name, IVoiceRegion region, Stream jpegIcon = null) { var args = new CreateGuildParams(); - var model = await BaseClient.CreateGuild(args).ConfigureAwait(false); + var model = await APIClient.CreateGuild(args).ConfigureAwait(false); return new Guild(this, model); } public async Task GetUser(ulong id) { - var model = await BaseClient.GetUser(id).ConfigureAwait(false); + var model = await APIClient.GetUser(id).ConfigureAwait(false); if (model != null) return new PublicUser(this, model); return null; } public async Task GetUser(string username, ushort discriminator) { - var model = await BaseClient.GetUser(username, discriminator).ConfigureAwait(false); + var model = await APIClient.GetUser(username, discriminator).ConfigureAwait(false); if (model != null) return new PublicUser(this, model); return null; @@ -222,7 +222,7 @@ namespace Discord.Rest var user = _currentUser; if (user == null) { - var model = await BaseClient.GetCurrentUser().ConfigureAwait(false); + var model = await APIClient.GetCurrentUser().ConfigureAwait(false); user = new SelfUser(this, model); _currentUser = user; } @@ -230,23 +230,23 @@ namespace Discord.Rest } public async Task> QueryUsers(string query, int limit) { - var models = await BaseClient.QueryUsers(query, limit).ConfigureAwait(false); + var models = await APIClient.QueryUsers(query, limit).ConfigureAwait(false); return models.Select(x => new PublicUser(this, x)); } public async Task> GetVoiceRegions() { - var models = await BaseClient.GetVoiceRegions().ConfigureAwait(false); + var models = await APIClient.GetVoiceRegions().ConfigureAwait(false); return models.Select(x => new VoiceRegion(x)); } public async Task GetVoiceRegion(string id) { - var models = await BaseClient.GetVoiceRegions().ConfigureAwait(false); + var models = await APIClient.GetVoiceRegions().ConfigureAwait(false); return models.Select(x => new VoiceRegion(x)).Where(x => x.Id == id).FirstOrDefault(); } public async Task GetOptimalVoiceRegion() { - var models = await BaseClient.GetVoiceRegions().ConfigureAwait(false); + var models = await APIClient.GetVoiceRegions().ConfigureAwait(false); return models.Select(x => new VoiceRegion(x)).Where(x => x.IsOptimal).FirstOrDefault(); } @@ -261,7 +261,7 @@ namespace Discord.Rest } public void Dispose() => Dispose(true); - API.DiscordRawClient IDiscordClient.BaseClient => BaseClient; + API.DiscordAPIClient IDiscordClient.APIClient => APIClient; async Task IDiscordClient.GetChannel(ulong id) => await GetChannel(id).ConfigureAwait(false); diff --git a/src/Discord.Net/Rest/Entities/Channels/DMChannel.cs b/src/Discord.Net/Rest/Entities/Channels/DMChannel.cs index 8d8c5897b..b62bbc6f6 100644 --- a/src/Discord.Net/Rest/Entities/Channels/DMChannel.cs +++ b/src/Discord.Net/Rest/Entities/Channels/DMChannel.cs @@ -60,14 +60,14 @@ namespace Discord.Rest public async Task> GetMessages(int limit = DiscordConfig.MaxMessagesPerBatch) { var args = new GetChannelMessagesParams { Limit = limit }; - var models = await Discord.BaseClient.GetChannelMessages(Id, args).ConfigureAwait(false); + var models = await Discord.APIClient.GetChannelMessages(Id, args).ConfigureAwait(false); return models.Select(x => new Message(this, x)); } /// public async Task> GetMessages(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) { var args = new GetChannelMessagesParams { Limit = limit }; - var models = await Discord.BaseClient.GetChannelMessages(Id, args).ConfigureAwait(false); + var models = await Discord.APIClient.GetChannelMessages(Id, args).ConfigureAwait(false); return models.Select(x => new Message(this, x)); } @@ -75,7 +75,7 @@ namespace Discord.Rest public async Task SendMessage(string text, bool isTTS = false) { var args = new CreateMessageParams { Content = text, IsTTS = isTTS }; - var model = await Discord.BaseClient.CreateDMMessage(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateDMMessage(Id, args).ConfigureAwait(false); return new Message(this, model); } /// @@ -85,7 +85,7 @@ namespace Discord.Rest using (var file = File.OpenRead(filePath)) { var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS }; - var model = await Discord.BaseClient.UploadDMFile(Id, file, args).ConfigureAwait(false); + var model = await Discord.APIClient.UploadDMFile(Id, file, args).ConfigureAwait(false); return new Message(this, model); } } @@ -93,32 +93,32 @@ namespace Discord.Rest public async Task SendFile(Stream stream, string filename, string text = null, bool isTTS = false) { var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS }; - var model = await Discord.BaseClient.UploadDMFile(Id, stream, args).ConfigureAwait(false); + var model = await Discord.APIClient.UploadDMFile(Id, stream, args).ConfigureAwait(false); return new Message(this, model); } /// public async Task DeleteMessages(IEnumerable messages) { - await Discord.BaseClient.DeleteDMMessages(Id, new DeleteMessagesParam { MessageIds = messages.Select(x => x.Id) }).ConfigureAwait(false); + await Discord.APIClient.DeleteDMMessages(Id, new DeleteMessagesParam { MessageIds = messages.Select(x => x.Id) }).ConfigureAwait(false); } /// public async Task TriggerTyping() { - await Discord.BaseClient.TriggerTypingIndicator(Id).ConfigureAwait(false); + await Discord.APIClient.TriggerTypingIndicator(Id).ConfigureAwait(false); } /// public async Task Close() { - await Discord.BaseClient.DeleteChannel(Id).ConfigureAwait(false); + await Discord.APIClient.DeleteChannel(Id).ConfigureAwait(false); } /// public async Task Update() { - var model = await Discord.BaseClient.GetChannel(Id).ConfigureAwait(false); + var model = await Discord.APIClient.GetChannel(Id).ConfigureAwait(false); Update(model); } diff --git a/src/Discord.Net/Rest/Entities/Channels/GuildChannel.cs b/src/Discord.Net/Rest/Entities/Channels/GuildChannel.cs index 1c3f64310..bdb92ffce 100644 --- a/src/Discord.Net/Rest/Entities/Channels/GuildChannel.cs +++ b/src/Discord.Net/Rest/Entities/Channels/GuildChannel.cs @@ -55,7 +55,7 @@ namespace Discord.Rest var args = new ModifyGuildChannelParams(); func(args); - var model = await Discord.BaseClient.ModifyGuildChannel(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.ModifyGuildChannel(Id, args).ConfigureAwait(false); Update(model); } @@ -78,7 +78,7 @@ namespace Discord.Rest /// Downloads a collection of all invites to this channel. public async Task> GetInvites() { - var models = await Discord.BaseClient.GetChannelInvites(Id).ConfigureAwait(false); + var models = await Discord.APIClient.GetChannelInvites(Id).ConfigureAwait(false); return models.Select(x => new InviteMetadata(Discord, x)); } @@ -86,20 +86,20 @@ namespace Discord.Rest public async Task AddPermissionOverwrite(IUser user, OverwritePermissions perms) { var args = new ModifyChannelPermissionsParams { Allow = perms.AllowValue, Deny = perms.DenyValue }; - await Discord.BaseClient.ModifyChannelPermissions(Id, user.Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyChannelPermissions(Id, user.Id, args).ConfigureAwait(false); _overwrites[user.Id] = new Overwrite(new API.Overwrite { Allow = perms.AllowValue, Deny = perms.DenyValue, TargetId = user.Id, TargetType = PermissionTarget.User }); } /// public async Task AddPermissionOverwrite(IRole role, OverwritePermissions perms) { var args = new ModifyChannelPermissionsParams { Allow = perms.AllowValue, Deny = perms.DenyValue }; - await Discord.BaseClient.ModifyChannelPermissions(Id, role.Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyChannelPermissions(Id, role.Id, args).ConfigureAwait(false); _overwrites[role.Id] = new Overwrite(new API.Overwrite { Allow = perms.AllowValue, Deny = perms.DenyValue, TargetId = role.Id, TargetType = PermissionTarget.Role }); } /// public async Task RemovePermissionOverwrite(IUser user) { - await Discord.BaseClient.DeleteChannelPermission(Id, user.Id).ConfigureAwait(false); + await Discord.APIClient.DeleteChannelPermission(Id, user.Id).ConfigureAwait(false); Overwrite value; _overwrites.TryRemove(user.Id, out value); @@ -107,7 +107,7 @@ namespace Discord.Rest /// public async Task RemovePermissionOverwrite(IRole role) { - await Discord.BaseClient.DeleteChannelPermission(Id, role.Id).ConfigureAwait(false); + await Discord.APIClient.DeleteChannelPermission(Id, role.Id).ConfigureAwait(false); Overwrite value; _overwrites.TryRemove(role.Id, out value); @@ -127,19 +127,19 @@ namespace Discord.Rest Temporary = isTemporary, XkcdPass = withXkcd }; - var model = await Discord.BaseClient.CreateChannelInvite(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateChannelInvite(Id, args).ConfigureAwait(false); return new InviteMetadata(Discord, model); } /// public async Task Delete() { - await Discord.BaseClient.DeleteChannel(Id).ConfigureAwait(false); + await Discord.APIClient.DeleteChannel(Id).ConfigureAwait(false); } /// public async Task Update() { - var model = await Discord.BaseClient.GetChannel(Id).ConfigureAwait(false); + var model = await Discord.APIClient.GetChannel(Id).ConfigureAwait(false); Update(model); } diff --git a/src/Discord.Net/Rest/Entities/Channels/TextChannel.cs b/src/Discord.Net/Rest/Entities/Channels/TextChannel.cs index 9fef515f2..ee579ae0c 100644 --- a/src/Discord.Net/Rest/Entities/Channels/TextChannel.cs +++ b/src/Discord.Net/Rest/Entities/Channels/TextChannel.cs @@ -35,7 +35,7 @@ namespace Discord.Rest var args = new ModifyTextChannelParams(); func(args); - var model = await Discord.BaseClient.ModifyGuildChannel(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.ModifyGuildChannel(Id, args).ConfigureAwait(false); Update(model); } @@ -64,14 +64,14 @@ namespace Discord.Rest public async Task> GetMessages(int limit = DiscordConfig.MaxMessagesPerBatch) { var args = new GetChannelMessagesParams { Limit = limit }; - var models = await Discord.BaseClient.GetChannelMessages(Id, args).ConfigureAwait(false); + var models = await Discord.APIClient.GetChannelMessages(Id, args).ConfigureAwait(false); return models.Select(x => new Message(this, x)); } /// public async Task> GetMessages(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch) { var args = new GetChannelMessagesParams { Limit = limit }; - var models = await Discord.BaseClient.GetChannelMessages(Id, args).ConfigureAwait(false); + var models = await Discord.APIClient.GetChannelMessages(Id, args).ConfigureAwait(false); return models.Select(x => new Message(this, x)); } @@ -79,7 +79,7 @@ namespace Discord.Rest public async Task SendMessage(string text, bool isTTS = false) { var args = new CreateMessageParams { Content = text, IsTTS = isTTS }; - var model = await Discord.BaseClient.CreateMessage(Guild.Id, Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateMessage(Guild.Id, Id, args).ConfigureAwait(false); return new Message(this, model); } /// @@ -89,7 +89,7 @@ namespace Discord.Rest using (var file = File.OpenRead(filePath)) { var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS }; - var model = await Discord.BaseClient.UploadFile(Guild.Id, Id, file, args).ConfigureAwait(false); + var model = await Discord.APIClient.UploadFile(Guild.Id, Id, file, args).ConfigureAwait(false); return new Message(this, model); } } @@ -97,20 +97,20 @@ namespace Discord.Rest public async Task SendFile(Stream stream, string filename, string text = null, bool isTTS = false) { var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS }; - var model = await Discord.BaseClient.UploadFile(Guild.Id, Id, stream, args).ConfigureAwait(false); + var model = await Discord.APIClient.UploadFile(Guild.Id, Id, stream, args).ConfigureAwait(false); return new Message(this, model); } /// public async Task DeleteMessages(IEnumerable messages) { - await Discord.BaseClient.DeleteMessages(Guild.Id, Id, new DeleteMessagesParam { MessageIds = messages.Select(x => x.Id) }).ConfigureAwait(false); + await Discord.APIClient.DeleteMessages(Guild.Id, Id, new DeleteMessagesParam { MessageIds = messages.Select(x => x.Id) }).ConfigureAwait(false); } /// public async Task TriggerTyping() { - await Discord.BaseClient.TriggerTypingIndicator(Id).ConfigureAwait(false); + await Discord.APIClient.TriggerTypingIndicator(Id).ConfigureAwait(false); } private string DebuggerDisplay => $"{Name} ({Id}, Text)"; diff --git a/src/Discord.Net/Rest/Entities/Channels/VoiceChannel.cs b/src/Discord.Net/Rest/Entities/Channels/VoiceChannel.cs index eeab53ebf..a2c6c8c49 100644 --- a/src/Discord.Net/Rest/Entities/Channels/VoiceChannel.cs +++ b/src/Discord.Net/Rest/Entities/Channels/VoiceChannel.cs @@ -30,7 +30,7 @@ namespace Discord.Rest var args = new ModifyVoiceChannelParams(); func(args); - var model = await Discord.BaseClient.ModifyGuildChannel(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.ModifyGuildChannel(Id, args).ConfigureAwait(false); Update(model); } diff --git a/src/Discord.Net/Rest/Entities/Guilds/Guild.cs b/src/Discord.Net/Rest/Entities/Guilds/Guild.cs index d9015dea7..87d15108c 100644 --- a/src/Discord.Net/Rest/Entities/Guilds/Guild.cs +++ b/src/Discord.Net/Rest/Entities/Guilds/Guild.cs @@ -115,7 +115,7 @@ namespace Discord.Rest /// public async Task Update() { - var response = await Discord.BaseClient.GetGuild(Id).ConfigureAwait(false); + var response = await Discord.APIClient.GetGuild(Id).ConfigureAwait(false); Update(response); } /// @@ -125,7 +125,7 @@ namespace Discord.Rest var args = new ModifyGuildParams(); func(args); - var model = await Discord.BaseClient.ModifyGuild(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.ModifyGuild(Id, args).ConfigureAwait(false); Update(model); } /// @@ -135,35 +135,35 @@ namespace Discord.Rest var args = new ModifyGuildEmbedParams(); func(args); - var model = await Discord.BaseClient.ModifyGuildEmbed(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.ModifyGuildEmbed(Id, args).ConfigureAwait(false); Update(model); } /// public async Task ModifyChannels(IEnumerable args) { - await Discord.BaseClient.ModifyGuildChannels(Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyGuildChannels(Id, args).ConfigureAwait(false); } /// public async Task ModifyRoles(IEnumerable args) { - var models = await Discord.BaseClient.ModifyGuildRoles(Id, args).ConfigureAwait(false); + var models = await Discord.APIClient.ModifyGuildRoles(Id, args).ConfigureAwait(false); Update(models); } /// public async Task Leave() { - await Discord.BaseClient.LeaveGuild(Id).ConfigureAwait(false); + await Discord.APIClient.LeaveGuild(Id).ConfigureAwait(false); } /// public async Task Delete() { - await Discord.BaseClient.DeleteGuild(Id).ConfigureAwait(false); + await Discord.APIClient.DeleteGuild(Id).ConfigureAwait(false); } /// public async Task> GetBans() { - var models = await Discord.BaseClient.GetGuildBans(Id).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildBans(Id).ConfigureAwait(false); return models.Select(x => new PublicUser(Discord, x)); } /// @@ -175,20 +175,20 @@ namespace Discord.Rest { PruneDays = pruneDays }; - await Discord.BaseClient.CreateGuildBan(Id, userId, args).ConfigureAwait(false); + await Discord.APIClient.CreateGuildBan(Id, userId, args).ConfigureAwait(false); } /// public Task RemoveBan(IUser user) => RemoveBan(user.Id); /// public async Task RemoveBan(ulong userId) { - await Discord.BaseClient.RemoveGuildBan(Id, userId).ConfigureAwait(false); + await Discord.APIClient.RemoveGuildBan(Id, userId).ConfigureAwait(false); } /// Gets the channel in this guild with the provided id, or null if not found. public async Task GetChannel(ulong id) { - var model = await Discord.BaseClient.GetChannel(Id, id).ConfigureAwait(false); + var model = await Discord.APIClient.GetChannel(Id, id).ConfigureAwait(false); if (model != null) return ToChannel(model); return null; @@ -196,7 +196,7 @@ namespace Discord.Rest /// Gets a collection of all channels in this guild. public async Task> GetChannels() { - var models = await Discord.BaseClient.GetGuildChannels(Id).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildChannels(Id).ConfigureAwait(false); return models.Select(x => ToChannel(x)); } /// Creates a new text channel. @@ -205,7 +205,7 @@ namespace Discord.Rest if (name == null) throw new ArgumentNullException(nameof(name)); var args = new CreateGuildChannelParams() { Name = name, Type = ChannelType.Text }; - var model = await Discord.BaseClient.CreateGuildChannel(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateGuildChannel(Id, args).ConfigureAwait(false); return new TextChannel(this, model); } /// Creates a new voice channel. @@ -214,28 +214,28 @@ namespace Discord.Rest if (name == null) throw new ArgumentNullException(nameof(name)); var args = new CreateGuildChannelParams { Name = name, Type = ChannelType.Voice }; - var model = await Discord.BaseClient.CreateGuildChannel(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateGuildChannel(Id, args).ConfigureAwait(false); return new VoiceChannel(this, model); } /// Gets a collection of all integrations attached to this guild. public async Task> GetIntegrations() { - var models = await Discord.BaseClient.GetGuildIntegrations(Id).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildIntegrations(Id).ConfigureAwait(false); return models.Select(x => new GuildIntegration(this, x)); } /// Creates a new integration for this guild. public async Task CreateIntegration(ulong id, string type) { var args = new CreateGuildIntegrationParams { Id = id, Type = type }; - var model = await Discord.BaseClient.CreateGuildIntegration(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateGuildIntegration(Id, args).ConfigureAwait(false); return new GuildIntegration(this, model); } /// Gets a collection of all invites to this guild. public async Task> GetInvites() { - var models = await Discord.BaseClient.GetGuildInvites(Id).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildInvites(Id).ConfigureAwait(false); return models.Select(x => new InviteMetadata(Discord, x)); } /// Creates a new invite to this guild. @@ -251,7 +251,7 @@ namespace Discord.Rest Temporary = isTemporary, XkcdPass = withXkcd }; - var model = await Discord.BaseClient.CreateChannelInvite(DefaultChannelId, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateChannelInvite(DefaultChannelId, args).ConfigureAwait(false); return new InviteMetadata(Discord, model); } @@ -269,7 +269,7 @@ namespace Discord.Rest { if (name == null) throw new ArgumentNullException(nameof(name)); - var model = await Discord.BaseClient.CreateGuildRole(Id).ConfigureAwait(false); + var model = await Discord.APIClient.CreateGuildRole(Id).ConfigureAwait(false); var role = new Role(this, model); await role.Modify(x => @@ -287,20 +287,20 @@ namespace Discord.Rest public async Task> GetUsers() { var args = new GetGuildMembersParams(); - var models = await Discord.BaseClient.GetGuildMembers(Id, args).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildMembers(Id, args).ConfigureAwait(false); return models.Select(x => new GuildUser(this, x)); } /// Gets a paged collection of all users in this guild. public async Task> GetUsers(int limit, int offset) { var args = new GetGuildMembersParams { Limit = limit, Offset = offset }; - var models = await Discord.BaseClient.GetGuildMembers(Id, args).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildMembers(Id, args).ConfigureAwait(false); return models.Select(x => new GuildUser(this, x)); } /// Gets the user in this guild with the provided id, or null if not found. public async Task GetUser(ulong id) { - var model = await Discord.BaseClient.GetGuildMember(Id, id).ConfigureAwait(false); + var model = await Discord.APIClient.GetGuildMember(Id, id).ConfigureAwait(false); if (model != null) return new GuildUser(this, model); return null; @@ -316,9 +316,9 @@ namespace Discord.Rest var args = new GuildPruneParams() { Days = days }; GetGuildPruneCountResponse model; if (simulate) - model = await Discord.BaseClient.GetGuildPruneCount(Id, args).ConfigureAwait(false); + model = await Discord.APIClient.GetGuildPruneCount(Id, args).ConfigureAwait(false); else - model = await Discord.BaseClient.BeginGuildPrune(Id, args).ConfigureAwait(false); + model = await Discord.APIClient.BeginGuildPrune(Id, args).ConfigureAwait(false); return model.Pruned; } diff --git a/src/Discord.Net/Rest/Entities/Guilds/GuildIntegration.cs b/src/Discord.Net/Rest/Entities/Guilds/GuildIntegration.cs index 2d0152d01..c8dd61ede 100644 --- a/src/Discord.Net/Rest/Entities/Guilds/GuildIntegration.cs +++ b/src/Discord.Net/Rest/Entities/Guilds/GuildIntegration.cs @@ -60,7 +60,7 @@ namespace Discord.Rest /// public async Task Delete() { - await Discord.BaseClient.DeleteGuildIntegration(Guild.Id, Id).ConfigureAwait(false); + await Discord.APIClient.DeleteGuildIntegration(Guild.Id, Id).ConfigureAwait(false); } /// public async Task Modify(Action func) @@ -69,14 +69,14 @@ namespace Discord.Rest var args = new ModifyGuildIntegrationParams(); func(args); - var model = await Discord.BaseClient.ModifyGuildIntegration(Guild.Id, Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.ModifyGuildIntegration(Guild.Id, Id, args).ConfigureAwait(false); Update(model); } /// public async Task Sync() { - await Discord.BaseClient.SyncGuildIntegration(Guild.Id, Id).ConfigureAwait(false); + await Discord.APIClient.SyncGuildIntegration(Guild.Id, Id).ConfigureAwait(false); } public override string ToString() => Name; diff --git a/src/Discord.Net/Rest/Entities/Guilds/UserGuild.cs b/src/Discord.Net/Rest/Entities/Guilds/UserGuild.cs index 367a37cdb..0679ccf21 100644 --- a/src/Discord.Net/Rest/Entities/Guilds/UserGuild.cs +++ b/src/Discord.Net/Rest/Entities/Guilds/UserGuild.cs @@ -42,12 +42,12 @@ namespace Discord /// public async Task Leave() { - await Discord.BaseClient.LeaveGuild(Id).ConfigureAwait(false); + await Discord.APIClient.LeaveGuild(Id).ConfigureAwait(false); } /// public async Task Delete() { - await Discord.BaseClient.DeleteGuild(Id).ConfigureAwait(false); + await Discord.APIClient.DeleteGuild(Id).ConfigureAwait(false); } public override string ToString() => Name; diff --git a/src/Discord.Net/Rest/Entities/Message.cs b/src/Discord.Net/Rest/Entities/Message.cs index a037a0202..962c5af05 100644 --- a/src/Discord.Net/Rest/Entities/Message.cs +++ b/src/Discord.Net/Rest/Entities/Message.cs @@ -125,9 +125,9 @@ namespace Discord.Rest Model model; if (guildChannel != null) - model = await Discord.BaseClient.ModifyMessage(guildChannel.Guild.Id, Channel.Id, Id, args).ConfigureAwait(false); + model = await Discord.APIClient.ModifyMessage(guildChannel.Guild.Id, Channel.Id, Id, args).ConfigureAwait(false); else - model = await Discord.BaseClient.ModifyDMMessage(Channel.Id, Id, args).ConfigureAwait(false); + model = await Discord.APIClient.ModifyDMMessage(Channel.Id, Id, args).ConfigureAwait(false); Update(model); } @@ -136,9 +136,9 @@ namespace Discord.Rest { var guildChannel = Channel as GuildChannel; if (guildChannel != null) - await Discord.BaseClient.DeleteMessage(guildChannel.Id, Channel.Id, Id).ConfigureAwait(false); + await Discord.APIClient.DeleteMessage(guildChannel.Id, Channel.Id, Id).ConfigureAwait(false); else - await Discord.BaseClient.DeleteDMMessage(Channel.Id, Id).ConfigureAwait(false); + await Discord.APIClient.DeleteDMMessage(Channel.Id, Id).ConfigureAwait(false); } public override string ToString() => Text; diff --git a/src/Discord.Net/Rest/Entities/Role.cs b/src/Discord.Net/Rest/Entities/Role.cs index 465c089e6..cd6789c47 100644 --- a/src/Discord.Net/Rest/Entities/Role.cs +++ b/src/Discord.Net/Rest/Entities/Role.cs @@ -60,12 +60,12 @@ namespace Discord.Rest var args = new ModifyGuildRoleParams(); func(args); - var response = await Discord.BaseClient.ModifyGuildRole(Guild.Id, Id, args).ConfigureAwait(false); + var response = await Discord.APIClient.ModifyGuildRole(Guild.Id, Id, args).ConfigureAwait(false); Update(response); } /// Deletes this message. public async Task Delete() - => await Discord.BaseClient.DeleteGuildRole(Guild.Id, Id).ConfigureAwait(false); + => await Discord.APIClient.DeleteGuildRole(Guild.Id, Id).ConfigureAwait(false); /// public override string ToString() => Name; @@ -76,7 +76,7 @@ namespace Discord.Rest async Task> IRole.GetUsers() { //A tad hacky, but it works - var models = await Discord.BaseClient.GetGuildMembers(Guild.Id, new GetGuildMembersParams()).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildMembers(Guild.Id, new GetGuildMembersParams()).ConfigureAwait(false); return models.Where(x => x.Roles.Contains(Id)).Select(x => new GuildUser(Guild, x)); } } diff --git a/src/Discord.Net/Rest/Entities/Users/GuildUser.cs b/src/Discord.Net/Rest/Entities/Users/GuildUser.cs index f3472d932..3f5779965 100644 --- a/src/Discord.Net/Rest/Entities/Users/GuildUser.cs +++ b/src/Discord.Net/Rest/Entities/Users/GuildUser.cs @@ -55,7 +55,7 @@ namespace Discord.Rest public async Task Update() { - var model = await Discord.BaseClient.GetGuildMember(Guild.Id, Id).ConfigureAwait(false); + var model = await Discord.APIClient.GetGuildMember(Guild.Id, Id).ConfigureAwait(false); Update(model); } @@ -71,7 +71,7 @@ namespace Discord.Rest public async Task Kick() { - await Discord.BaseClient.RemoveGuildMember(Guild.Id, Id).ConfigureAwait(false); + await Discord.APIClient.RemoveGuildMember(Guild.Id, Id).ConfigureAwait(false); } public ChannelPermissions GetPermissions(IGuildChannel channel) @@ -91,13 +91,13 @@ namespace Discord.Rest if (isCurrentUser && args.Nickname.IsSpecified) { var nickArgs = new ModifyCurrentUserNickParams { Nickname = args.Nickname.Value }; - await Discord.BaseClient.ModifyCurrentUserNick(Guild.Id, nickArgs).ConfigureAwait(false); + await Discord.APIClient.ModifyCurrentUserNick(Guild.Id, nickArgs).ConfigureAwait(false); args.Nickname = new API.Optional(); //Remove } if (!isCurrentUser || args.Deaf.IsSpecified || args.Mute.IsSpecified || args.Roles.IsSpecified) { - await Discord.BaseClient.ModifyGuildMember(Guild.Id, Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyGuildMember(Guild.Id, Id, args).ConfigureAwait(false); if (args.Deaf.IsSpecified) IsDeaf = args.Deaf.Value; if (args.Mute.IsSpecified) diff --git a/src/Discord.Net/Rest/Entities/Users/SelfUser.cs b/src/Discord.Net/Rest/Entities/Users/SelfUser.cs index 513acf0d2..503773382 100644 --- a/src/Discord.Net/Rest/Entities/Users/SelfUser.cs +++ b/src/Discord.Net/Rest/Entities/Users/SelfUser.cs @@ -30,7 +30,7 @@ namespace Discord.Rest /// public async Task Update() { - var model = await Discord.BaseClient.GetCurrentUser().ConfigureAwait(false); + var model = await Discord.APIClient.GetCurrentUser().ConfigureAwait(false); Update(model); } @@ -41,7 +41,7 @@ namespace Discord.Rest var args = new ModifyCurrentUserParams(); func(args); - var model = await Discord.BaseClient.ModifyCurrentUser(args).ConfigureAwait(false); + var model = await Discord.APIClient.ModifyCurrentUser(args).ConfigureAwait(false); Update(model); } } diff --git a/src/Discord.Net/Rest/Entities/Users/User.cs b/src/Discord.Net/Rest/Entities/Users/User.cs index c44e1a0a5..0469b19d3 100644 --- a/src/Discord.Net/Rest/Entities/Users/User.cs +++ b/src/Discord.Net/Rest/Entities/Users/User.cs @@ -48,7 +48,7 @@ namespace Discord.Rest public async Task CreateDMChannel() { var args = new CreateDMChannelParams { RecipientId = Id }; - var model = await Discord.BaseClient.CreateDMChannel(args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateDMChannel(args).ConfigureAwait(false); return new DMChannel(Discord, model); } diff --git a/src/Discord.Net/WebSocket/DiscordClient.cs b/src/Discord.Net/WebSocket/DiscordClient.cs index 0af5cceb9..de342d2b2 100644 --- a/src/Discord.Net/WebSocket/DiscordClient.cs +++ b/src/Discord.Net/WebSocket/DiscordClient.cs @@ -27,7 +27,7 @@ namespace Discord.WebSocket } } - public DiscordRawClient BaseClient + public DiscordAPIClient APIClient { get { diff --git a/src/Discord.Net/WebSocket/Entities/Channels/DMChannel.cs b/src/Discord.Net/WebSocket/Entities/Channels/DMChannel.cs index 89c2f9047..abc5dd725 100644 --- a/src/Discord.Net/WebSocket/Entities/Channels/DMChannel.cs +++ b/src/Discord.Net/WebSocket/Entities/Channels/DMChannel.cs @@ -75,7 +75,7 @@ namespace Discord.WebSocket public async Task SendMessage(string text, bool isTTS = false) { var args = new CreateMessageParams { Content = text, IsTTS = isTTS }; - var model = await Discord.BaseClient.CreateDMMessage(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateDMMessage(Id, args).ConfigureAwait(false); return new Message(this, model); } /// @@ -85,7 +85,7 @@ namespace Discord.WebSocket using (var file = File.OpenRead(filePath)) { var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS }; - var model = await Discord.BaseClient.UploadDMFile(Id, file, args).ConfigureAwait(false); + var model = await Discord.APIClient.UploadDMFile(Id, file, args).ConfigureAwait(false); return new Message(this, model); } } @@ -93,26 +93,26 @@ namespace Discord.WebSocket public async Task SendFile(Stream stream, string filename, string text = null, bool isTTS = false) { var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS }; - var model = await Discord.BaseClient.UploadDMFile(Id, stream, args).ConfigureAwait(false); + var model = await Discord.APIClient.UploadDMFile(Id, stream, args).ConfigureAwait(false); return new Message(this, model); } /// public async Task DeleteMessages(IEnumerable messages) { - await Discord.BaseClient.DeleteDMMessages(Id, new DeleteMessagesParam { MessageIds = messages.Select(x => x.Id) }).ConfigureAwait(false); + await Discord.APIClient.DeleteDMMessages(Id, new DeleteMessagesParam { MessageIds = messages.Select(x => x.Id) }).ConfigureAwait(false); } /// public async Task TriggerTyping() { - await Discord.BaseClient.TriggerTypingIndicator(Id).ConfigureAwait(false); + await Discord.APIClient.TriggerTypingIndicator(Id).ConfigureAwait(false); } /// public async Task Close() { - await Discord.BaseClient.DeleteChannel(Id).ConfigureAwait(false); + await Discord.APIClient.DeleteChannel(Id).ConfigureAwait(false); } /// diff --git a/src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs b/src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs index 6b3427a8c..5d8a6db68 100644 --- a/src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs +++ b/src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs @@ -57,7 +57,7 @@ namespace Discord.WebSocket var args = new ModifyGuildChannelParams(); func(args); - await Discord.BaseClient.ModifyGuildChannel(Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyGuildChannel(Id, args).ConfigureAwait(false); } /// Gets a user in this channel with the given id. @@ -82,7 +82,7 @@ namespace Discord.WebSocket /// Downloads a collection of all invites to this channel. public async Task> GetInvites() { - var models = await Discord.BaseClient.GetChannelInvites(Id).ConfigureAwait(false); + var models = await Discord.APIClient.GetChannelInvites(Id).ConfigureAwait(false); return models.Select(x => new InviteMetadata(Discord, x)); } @@ -90,23 +90,23 @@ namespace Discord.WebSocket public async Task AddPermissionOverwrite(IUser user, OverwritePermissions perms) { var args = new ModifyChannelPermissionsParams { Allow = perms.AllowValue, Deny = perms.DenyValue }; - await Discord.BaseClient.ModifyChannelPermissions(Id, user.Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyChannelPermissions(Id, user.Id, args).ConfigureAwait(false); } /// public async Task AddPermissionOverwrite(IRole role, OverwritePermissions perms) { var args = new ModifyChannelPermissionsParams { Allow = perms.AllowValue, Deny = perms.DenyValue }; - await Discord.BaseClient.ModifyChannelPermissions(Id, role.Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyChannelPermissions(Id, role.Id, args).ConfigureAwait(false); } /// public async Task RemovePermissionOverwrite(IUser user) { - await Discord.BaseClient.DeleteChannelPermission(Id, user.Id).ConfigureAwait(false); + await Discord.APIClient.DeleteChannelPermission(Id, user.Id).ConfigureAwait(false); } /// public async Task RemovePermissionOverwrite(IRole role) { - await Discord.BaseClient.DeleteChannelPermission(Id, role.Id).ConfigureAwait(false); + await Discord.APIClient.DeleteChannelPermission(Id, role.Id).ConfigureAwait(false); } /// Creates a new invite to this channel. @@ -123,14 +123,14 @@ namespace Discord.WebSocket Temporary = isTemporary, XkcdPass = withXkcd }; - var model = await Discord.BaseClient.CreateChannelInvite(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateChannelInvite(Id, args).ConfigureAwait(false); return new InviteMetadata(Discord, model); } /// public async Task Delete() { - await Discord.BaseClient.DeleteChannel(Id).ConfigureAwait(false); + await Discord.APIClient.DeleteChannel(Id).ConfigureAwait(false); } /// diff --git a/src/Discord.Net/WebSocket/Entities/Channels/TextChannel.cs b/src/Discord.Net/WebSocket/Entities/Channels/TextChannel.cs index 16801a91a..760fd6c84 100644 --- a/src/Discord.Net/WebSocket/Entities/Channels/TextChannel.cs +++ b/src/Discord.Net/WebSocket/Entities/Channels/TextChannel.cs @@ -42,7 +42,7 @@ namespace Discord.WebSocket var args = new ModifyTextChannelParams(); func(args); - await Discord.BaseClient.ModifyGuildChannel(Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyGuildChannel(Id, args).ConfigureAwait(false); } /// Gets the message from this channel's cache with the given id, or null if none was found. @@ -73,7 +73,7 @@ namespace Discord.WebSocket public async Task SendMessage(string text, bool isTTS = false) { var args = new CreateMessageParams { Content = text, IsTTS = isTTS }; - var model = await Discord.BaseClient.CreateMessage(Guild.Id, Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateMessage(Guild.Id, Id, args).ConfigureAwait(false); return new Message(this, model); } /// @@ -83,7 +83,7 @@ namespace Discord.WebSocket using (var file = File.OpenRead(filePath)) { var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS }; - var model = await Discord.BaseClient.UploadFile(Guild.Id, Id, file, args).ConfigureAwait(false); + var model = await Discord.APIClient.UploadFile(Guild.Id, Id, file, args).ConfigureAwait(false); return new Message(this, model); } } @@ -91,20 +91,20 @@ namespace Discord.WebSocket public async Task SendFile(Stream stream, string filename, string text = null, bool isTTS = false) { var args = new UploadFileParams { Filename = filename, Content = text, IsTTS = isTTS }; - var model = await Discord.BaseClient.UploadFile(Guild.Id, Id, stream, args).ConfigureAwait(false); + var model = await Discord.APIClient.UploadFile(Guild.Id, Id, stream, args).ConfigureAwait(false); return new Message(this, model); } /// public async Task DeleteMessages(IEnumerable messages) { - await Discord.BaseClient.DeleteMessages(Guild.Id, Id, new DeleteMessagesParam { MessageIds = messages.Select(x => x.Id) }).ConfigureAwait(false); + await Discord.APIClient.DeleteMessages(Guild.Id, Id, new DeleteMessagesParam { MessageIds = messages.Select(x => x.Id) }).ConfigureAwait(false); } /// public async Task TriggerTyping() { - await Discord.BaseClient.TriggerTypingIndicator(Id).ConfigureAwait(false); + await Discord.APIClient.TriggerTypingIndicator(Id).ConfigureAwait(false); } private string DebuggerDisplay => $"{Name} ({Id}, Text)"; diff --git a/src/Discord.Net/WebSocket/Entities/Channels/VoiceChannel.cs b/src/Discord.Net/WebSocket/Entities/Channels/VoiceChannel.cs index 24865c401..d9cc49500 100644 --- a/src/Discord.Net/WebSocket/Entities/Channels/VoiceChannel.cs +++ b/src/Discord.Net/WebSocket/Entities/Channels/VoiceChannel.cs @@ -34,7 +34,7 @@ namespace Discord.WebSocket var args = new ModifyVoiceChannelParams(); func(args); - await Discord.BaseClient.ModifyGuildChannel(Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyGuildChannel(Id, args).ConfigureAwait(false); } public override GuildUser GetUser(ulong id) diff --git a/src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs b/src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs index c5dfb4b5b..8ccb68fe3 100644 --- a/src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs +++ b/src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs @@ -121,7 +121,7 @@ namespace Discord.WebSocket var args = new ModifyGuildParams(); func(args); - await Discord.BaseClient.ModifyGuild(Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyGuild(Id, args).ConfigureAwait(false); } /// public async Task ModifyEmbed(Action func) @@ -130,33 +130,33 @@ namespace Discord.WebSocket var args = new ModifyGuildEmbedParams(); func(args); - await Discord.BaseClient.ModifyGuildEmbed(Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyGuildEmbed(Id, args).ConfigureAwait(false); } /// public async Task ModifyChannels(IEnumerable args) { - await Discord.BaseClient.ModifyGuildChannels(Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyGuildChannels(Id, args).ConfigureAwait(false); } /// public async Task ModifyRoles(IEnumerable args) { - await Discord.BaseClient.ModifyGuildRoles(Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyGuildRoles(Id, args).ConfigureAwait(false); } /// public async Task Leave() { - await Discord.BaseClient.LeaveGuild(Id).ConfigureAwait(false); + await Discord.APIClient.LeaveGuild(Id).ConfigureAwait(false); } /// public async Task Delete() { - await Discord.BaseClient.DeleteGuild(Id).ConfigureAwait(false); + await Discord.APIClient.DeleteGuild(Id).ConfigureAwait(false); } /// public async Task> GetBans() { - var models = await Discord.BaseClient.GetGuildBans(Id).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildBans(Id).ConfigureAwait(false); return models.Select(x => new PublicUser(Discord, x)); } /// @@ -168,20 +168,20 @@ namespace Discord.WebSocket { PruneDays = pruneDays }; - await Discord.BaseClient.CreateGuildBan(Id, userId, args).ConfigureAwait(false); + await Discord.APIClient.CreateGuildBan(Id, userId, args).ConfigureAwait(false); } /// public Task RemoveBan(IUser user) => RemoveBan(user.Id); /// public async Task RemoveBan(ulong userId) { - await Discord.BaseClient.RemoveGuildBan(Id, userId).ConfigureAwait(false); + await Discord.APIClient.RemoveGuildBan(Id, userId).ConfigureAwait(false); } /// Gets the channel in this guild with the provided id, or null if not found. public async Task GetChannel(ulong id) { - var model = await Discord.BaseClient.GetChannel(Id, id).ConfigureAwait(false); + var model = await Discord.APIClient.GetChannel(Id, id).ConfigureAwait(false); if (model != null) return ToChannel(model); return null; @@ -189,7 +189,7 @@ namespace Discord.WebSocket /// Gets a collection of all channels in this guild. public async Task> GetChannels() { - var models = await Discord.BaseClient.GetGuildChannels(Id).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildChannels(Id).ConfigureAwait(false); return models.Select(x => ToChannel(x)); } /// Creates a new text channel. @@ -198,7 +198,7 @@ namespace Discord.WebSocket if (name == null) throw new ArgumentNullException(nameof(name)); var args = new CreateGuildChannelParams() { Name = name, Type = ChannelType.Text }; - var model = await Discord.BaseClient.CreateGuildChannel(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateGuildChannel(Id, args).ConfigureAwait(false); return new TextChannel(this, model); } /// Creates a new voice channel. @@ -207,28 +207,28 @@ namespace Discord.WebSocket if (name == null) throw new ArgumentNullException(nameof(name)); var args = new CreateGuildChannelParams { Name = name, Type = ChannelType.Voice }; - var model = await Discord.BaseClient.CreateGuildChannel(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateGuildChannel(Id, args).ConfigureAwait(false); return new VoiceChannel(this, model); } /// Gets a collection of all integrations attached to this guild. public async Task> GetIntegrations() { - var models = await Discord.BaseClient.GetGuildIntegrations(Id).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildIntegrations(Id).ConfigureAwait(false); return models.Select(x => new GuildIntegration(this, x)); } /// Creates a new integration for this guild. public async Task CreateIntegration(ulong id, string type) { var args = new CreateGuildIntegrationParams { Id = id, Type = type }; - var model = await Discord.BaseClient.CreateGuildIntegration(Id, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateGuildIntegration(Id, args).ConfigureAwait(false); return new GuildIntegration(this, model); } /// Gets a collection of all invites to this guild. public async Task> GetInvites() { - var models = await Discord.BaseClient.GetGuildInvites(Id).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildInvites(Id).ConfigureAwait(false); return models.Select(x => new InviteMetadata(Discord, x)); } /// Creates a new invite to this guild. @@ -244,7 +244,7 @@ namespace Discord.WebSocket Temporary = isTemporary, XkcdPass = withXkcd }; - var model = await Discord.BaseClient.CreateChannelInvite(DefaultChannelId, args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateChannelInvite(DefaultChannelId, args).ConfigureAwait(false); return new InviteMetadata(Discord, model); } @@ -262,7 +262,7 @@ namespace Discord.WebSocket { if (name == null) throw new ArgumentNullException(nameof(name)); - var model = await Discord.BaseClient.CreateGuildRole(Id).ConfigureAwait(false); + var model = await Discord.APIClient.CreateGuildRole(Id).ConfigureAwait(false); var role = new Role(this, model); await role.Modify(x => @@ -280,20 +280,20 @@ namespace Discord.WebSocket public async Task> GetUsers() { var args = new GetGuildMembersParams(); - var models = await Discord.BaseClient.GetGuildMembers(Id, args).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildMembers(Id, args).ConfigureAwait(false); return models.Select(x => new GuildUser(this, x)); } /// Gets a paged collection of all users in this guild. public async Task> GetUsers(int limit, int offset) { var args = new GetGuildMembersParams { Limit = limit, Offset = offset }; - var models = await Discord.BaseClient.GetGuildMembers(Id, args).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildMembers(Id, args).ConfigureAwait(false); return models.Select(x => new GuildUser(this, x)); } /// Gets the user in this guild with the provided id, or null if not found. public async Task GetUser(ulong id) { - var model = await Discord.BaseClient.GetGuildMember(Id, id).ConfigureAwait(false); + var model = await Discord.APIClient.GetGuildMember(Id, id).ConfigureAwait(false); if (model != null) return new GuildUser(this, model); return null; @@ -309,9 +309,9 @@ namespace Discord.WebSocket var args = new GuildPruneParams() { Days = days }; GetGuildPruneCountResponse model; if (simulate) - model = await Discord.BaseClient.GetGuildPruneCount(Id, args).ConfigureAwait(false); + model = await Discord.APIClient.GetGuildPruneCount(Id, args).ConfigureAwait(false); else - model = await Discord.BaseClient.BeginGuildPrune(Id, args).ConfigureAwait(false); + model = await Discord.APIClient.BeginGuildPrune(Id, args).ConfigureAwait(false); return model.Pruned; } diff --git a/src/Discord.Net/WebSocket/Entities/Guilds/GuildIntegration.cs b/src/Discord.Net/WebSocket/Entities/Guilds/GuildIntegration.cs index 9d93ee37a..fbb810e90 100644 --- a/src/Discord.Net/WebSocket/Entities/Guilds/GuildIntegration.cs +++ b/src/Discord.Net/WebSocket/Entities/Guilds/GuildIntegration.cs @@ -60,7 +60,7 @@ namespace Discord.WebSocket /// public async Task Delete() { - await Discord.BaseClient.DeleteGuildIntegration(Guild.Id, Id).ConfigureAwait(false); + await Discord.APIClient.DeleteGuildIntegration(Guild.Id, Id).ConfigureAwait(false); } /// public async Task Modify(Action func) @@ -69,12 +69,12 @@ namespace Discord.WebSocket var args = new ModifyGuildIntegrationParams(); func(args); - await Discord.BaseClient.ModifyGuildIntegration(Guild.Id, Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyGuildIntegration(Guild.Id, Id, args).ConfigureAwait(false); } /// public async Task Sync() { - await Discord.BaseClient.SyncGuildIntegration(Guild.Id, Id).ConfigureAwait(false); + await Discord.APIClient.SyncGuildIntegration(Guild.Id, Id).ConfigureAwait(false); } public override string ToString() => Name; diff --git a/src/Discord.Net/WebSocket/Entities/Message.cs b/src/Discord.Net/WebSocket/Entities/Message.cs index 8a22828fe..dcd1dbf36 100644 --- a/src/Discord.Net/WebSocket/Entities/Message.cs +++ b/src/Discord.Net/WebSocket/Entities/Message.cs @@ -124,9 +124,9 @@ namespace Discord.WebSocket var guildChannel = Channel as GuildChannel; if (guildChannel != null) - await Discord.BaseClient.ModifyMessage(guildChannel.Guild.Id, Channel.Id, Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyMessage(guildChannel.Guild.Id, Channel.Id, Id, args).ConfigureAwait(false); else - await Discord.BaseClient.ModifyDMMessage(Channel.Id, Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyDMMessage(Channel.Id, Id, args).ConfigureAwait(false); } /// @@ -134,9 +134,9 @@ namespace Discord.WebSocket { var guildChannel = Channel as GuildChannel; if (guildChannel != null) - await Discord.BaseClient.DeleteMessage(guildChannel.Id, Channel.Id, Id).ConfigureAwait(false); + await Discord.APIClient.DeleteMessage(guildChannel.Id, Channel.Id, Id).ConfigureAwait(false); else - await Discord.BaseClient.DeleteDMMessage(Channel.Id, Id).ConfigureAwait(false); + await Discord.APIClient.DeleteDMMessage(Channel.Id, Id).ConfigureAwait(false); } public override string ToString() => Text; diff --git a/src/Discord.Net/WebSocket/Entities/Role.cs b/src/Discord.Net/WebSocket/Entities/Role.cs index 04ecec344..24af5f1d8 100644 --- a/src/Discord.Net/WebSocket/Entities/Role.cs +++ b/src/Discord.Net/WebSocket/Entities/Role.cs @@ -60,11 +60,11 @@ namespace Discord.WebSocket var args = new ModifyGuildRoleParams(); func(args); - await Discord.BaseClient.ModifyGuildRole(Guild.Id, Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyGuildRole(Guild.Id, Id, args).ConfigureAwait(false); } /// Deletes this message. public async Task Delete() - => await Discord.BaseClient.DeleteGuildRole(Guild.Id, Id).ConfigureAwait(false); + => await Discord.APIClient.DeleteGuildRole(Guild.Id, Id).ConfigureAwait(false); /// public override string ToString() => Name; @@ -75,7 +75,7 @@ namespace Discord.WebSocket async Task> IRole.GetUsers() { //A tad hacky, but it works - var models = await Discord.BaseClient.GetGuildMembers(Guild.Id, new GetGuildMembersParams()).ConfigureAwait(false); + var models = await Discord.APIClient.GetGuildMembers(Guild.Id, new GetGuildMembersParams()).ConfigureAwait(false); return models.Where(x => x.Roles.Contains(Id)).Select(x => new GuildUser(Guild, x)); } } diff --git a/src/Discord.Net/WebSocket/Entities/Users/GuildUser.cs b/src/Discord.Net/WebSocket/Entities/Users/GuildUser.cs index 8e8f25029..0dde4a8c5 100644 --- a/src/Discord.Net/WebSocket/Entities/Users/GuildUser.cs +++ b/src/Discord.Net/WebSocket/Entities/Users/GuildUser.cs @@ -69,7 +69,7 @@ namespace Discord.WebSocket public async Task Kick() { - await Discord.BaseClient.RemoveGuildMember(Guild.Id, Id).ConfigureAwait(false); + await Discord.APIClient.RemoveGuildMember(Guild.Id, Id).ConfigureAwait(false); } public GuildPermissions GetGuildPermissions() @@ -93,13 +93,13 @@ namespace Discord.WebSocket if (isCurrentUser && args.Nickname.IsSpecified) { var nickArgs = new ModifyCurrentUserNickParams { Nickname = args.Nickname.Value }; - await Discord.BaseClient.ModifyCurrentUserNick(Guild.Id, nickArgs).ConfigureAwait(false); + await Discord.APIClient.ModifyCurrentUserNick(Guild.Id, nickArgs).ConfigureAwait(false); args.Nickname = new API.Optional(); //Remove } if (!isCurrentUser || args.Deaf.IsSpecified || args.Mute.IsSpecified || args.Roles.IsSpecified) { - await Discord.BaseClient.ModifyGuildMember(Guild.Id, Id, args).ConfigureAwait(false); + await Discord.APIClient.ModifyGuildMember(Guild.Id, Id, args).ConfigureAwait(false); if (args.Deaf.IsSpecified) IsDeaf = args.Deaf.Value; if (args.Mute.IsSpecified) diff --git a/src/Discord.Net/WebSocket/Entities/Users/SelfUser.cs b/src/Discord.Net/WebSocket/Entities/Users/SelfUser.cs index b852fbc15..9b97cf58e 100644 --- a/src/Discord.Net/WebSocket/Entities/Users/SelfUser.cs +++ b/src/Discord.Net/WebSocket/Entities/Users/SelfUser.cs @@ -34,7 +34,7 @@ namespace Discord.WebSocket var args = new ModifyCurrentUserParams(); func(args); - await Discord.BaseClient.ModifyCurrentUser(args).ConfigureAwait(false); + await Discord.APIClient.ModifyCurrentUser(args).ConfigureAwait(false); } Task IUpdateable.Update() diff --git a/src/Discord.Net/WebSocket/Entities/Users/User.cs b/src/Discord.Net/WebSocket/Entities/Users/User.cs index 0eb985e15..f43465544 100644 --- a/src/Discord.Net/WebSocket/Entities/Users/User.cs +++ b/src/Discord.Net/WebSocket/Entities/Users/User.cs @@ -48,7 +48,7 @@ namespace Discord.WebSocket public async Task CreateDMChannel() { var args = new CreateDMChannelParams { RecipientId = Id }; - var model = await Discord.BaseClient.CreateDMChannel(args).ConfigureAwait(false); + var model = await Discord.APIClient.CreateDMChannel(args).ConfigureAwait(false); return new DMChannel(Discord, model); } diff --git a/src/Discord.Net/WebSocket/MessageCache.cs b/src/Discord.Net/WebSocket/MessageCache.cs index 1552dd2b1..d81fb3498 100644 --- a/src/Discord.Net/WebSocket/MessageCache.cs +++ b/src/Discord.Net/WebSocket/MessageCache.cs @@ -99,7 +99,7 @@ namespace Discord.WebSocket RelativeDirection = dir, RelativeMessageId = dir == Direction.Before ? cachedMessages[0].Id : cachedMessages[cachedMessages.Count - 1].Id }; - var downloadedMessages = await _discord.BaseClient.GetChannelMessages(_channel.Id, args).ConfigureAwait(false); + var downloadedMessages = await _discord.APIClient.GetChannelMessages(_channel.Id, args).ConfigureAwait(false); return cachedMessages.AsEnumerable().Concat(downloadedMessages.Select(x => new Message(_channel, x))).ToImmutableArray(); } }