| @@ -17,7 +17,7 @@ using System.Threading.Tasks; | |||
| namespace Discord.API | |||
| { | |||
| public class DiscordRawClient | |||
| public class DiscordAPIClient | |||
| { | |||
| internal event EventHandler<SentRequestEventArgs> 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", "*/*"); | |||
| @@ -47,13 +47,13 @@ namespace Discord | |||
| /// <inheritdoc /> | |||
| public async Task Accept() | |||
| { | |||
| await Discord.BaseClient.AcceptInvite(Code).ConfigureAwait(false); | |||
| await Discord.APIClient.AcceptInvite(Code).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task Delete() | |||
| { | |||
| await Discord.BaseClient.DeleteInvite(Code).ConfigureAwait(false); | |||
| await Discord.APIClient.DeleteInvite(Code).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| @@ -105,7 +105,7 @@ | |||
| <Compile Include="Common\Entities\Users\Game.cs" /> | |||
| <Compile Include="Common\Entities\Users\StreamType.cs" /> | |||
| <Compile Include="DiscordConfig.cs" /> | |||
| <Compile Include="API\DiscordRawClient.cs" /> | |||
| <Compile Include="API\DiscordAPIClient.cs" /> | |||
| <Compile Include="API\Int53Attribute.cs" /> | |||
| <Compile Include="Preconditions.cs" /> | |||
| <Compile Include="Net\Converters\DiscordContractResolver.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; } | |||
| @@ -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<IEnumerable<Connection>> 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<IChannel> 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<IEnumerable<DMChannel>> 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<Invite> 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<Guild> 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<GuildEmbed> 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<IEnumerable<UserGuild>> 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<Guild> 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<User> 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<User> 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<IEnumerable<User>> 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<IEnumerable<VoiceRegion>> 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<VoiceRegion> 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<VoiceRegion> 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<IChannel> IDiscordClient.GetChannel(ulong id) | |||
| => await GetChannel(id).ConfigureAwait(false); | |||
| @@ -60,14 +60,14 @@ namespace Discord.Rest | |||
| public async Task<IEnumerable<Message>> 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)); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task<IEnumerable<Message>> 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<Message> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| @@ -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<Message> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task DeleteMessages(IEnumerable<IMessage> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task TriggerTyping() | |||
| { | |||
| await Discord.BaseClient.TriggerTypingIndicator(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.TriggerTypingIndicator(Id).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task Close() | |||
| { | |||
| await Discord.BaseClient.DeleteChannel(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.DeleteChannel(Id).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task Update() | |||
| { | |||
| var model = await Discord.BaseClient.GetChannel(Id).ConfigureAwait(false); | |||
| var model = await Discord.APIClient.GetChannel(Id).ConfigureAwait(false); | |||
| Update(model); | |||
| } | |||
| @@ -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 | |||
| /// <summary> Downloads a collection of all invites to this channel. </summary> | |||
| public async Task<IEnumerable<InviteMetadata>> 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 }); | |||
| } | |||
| /// <inheritdoc /> | |||
| 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 }); | |||
| } | |||
| /// <inheritdoc /> | |||
| 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 | |||
| /// <inheritdoc /> | |||
| 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task Delete() | |||
| { | |||
| await Discord.BaseClient.DeleteChannel(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.DeleteChannel(Id).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task Update() | |||
| { | |||
| var model = await Discord.BaseClient.GetChannel(Id).ConfigureAwait(false); | |||
| var model = await Discord.APIClient.GetChannel(Id).ConfigureAwait(false); | |||
| Update(model); | |||
| } | |||
| @@ -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<IEnumerable<Message>> 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)); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task<IEnumerable<Message>> 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<Message> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| @@ -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<Message> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task DeleteMessages(IEnumerable<IMessage> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task TriggerTyping() | |||
| { | |||
| await Discord.BaseClient.TriggerTypingIndicator(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.TriggerTypingIndicator(Id).ConfigureAwait(false); | |||
| } | |||
| private string DebuggerDisplay => $"{Name} ({Id}, Text)"; | |||
| @@ -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); | |||
| } | |||
| @@ -115,7 +115,7 @@ namespace Discord.Rest | |||
| /// <inheritdoc /> | |||
| public async Task Update() | |||
| { | |||
| var response = await Discord.BaseClient.GetGuild(Id).ConfigureAwait(false); | |||
| var response = await Discord.APIClient.GetGuild(Id).ConfigureAwait(false); | |||
| Update(response); | |||
| } | |||
| /// <inheritdoc /> | |||
| @@ -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); | |||
| } | |||
| /// <inheritdoc /> | |||
| @@ -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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task ModifyChannels(IEnumerable<ModifyGuildChannelsParams> args) | |||
| { | |||
| await Discord.BaseClient.ModifyGuildChannels(Id, args).ConfigureAwait(false); | |||
| await Discord.APIClient.ModifyGuildChannels(Id, args).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task ModifyRoles(IEnumerable<ModifyGuildRolesParams> args) | |||
| { | |||
| var models = await Discord.BaseClient.ModifyGuildRoles(Id, args).ConfigureAwait(false); | |||
| var models = await Discord.APIClient.ModifyGuildRoles(Id, args).ConfigureAwait(false); | |||
| Update(models); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task Leave() | |||
| { | |||
| await Discord.BaseClient.LeaveGuild(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.LeaveGuild(Id).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task Delete() | |||
| { | |||
| await Discord.BaseClient.DeleteGuild(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.DeleteGuild(Id).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task<IEnumerable<User>> 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)); | |||
| } | |||
| /// <inheritdoc /> | |||
| @@ -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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public Task RemoveBan(IUser user) => RemoveBan(user.Id); | |||
| /// <inheritdoc /> | |||
| public async Task RemoveBan(ulong userId) | |||
| { | |||
| await Discord.BaseClient.RemoveGuildBan(Id, userId).ConfigureAwait(false); | |||
| await Discord.APIClient.RemoveGuildBan(Id, userId).ConfigureAwait(false); | |||
| } | |||
| /// <summary> Gets the channel in this guild with the provided id, or null if not found. </summary> | |||
| public async Task<GuildChannel> 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 | |||
| /// <summary> Gets a collection of all channels in this guild. </summary> | |||
| public async Task<IEnumerable<GuildChannel>> 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)); | |||
| } | |||
| /// <summary> Creates a new text channel. </summary> | |||
| @@ -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); | |||
| } | |||
| /// <summary> Creates a new voice channel. </summary> | |||
| @@ -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); | |||
| } | |||
| /// <summary> Gets a collection of all integrations attached to this guild. </summary> | |||
| public async Task<IEnumerable<GuildIntegration>> 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)); | |||
| } | |||
| /// <summary> Creates a new integration for this guild. </summary> | |||
| public async Task<GuildIntegration> 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); | |||
| } | |||
| /// <summary> Gets a collection of all invites to this guild. </summary> | |||
| public async Task<IEnumerable<InviteMetadata>> 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)); | |||
| } | |||
| /// <summary> Creates a new invite to this guild. </summary> | |||
| @@ -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<IEnumerable<GuildUser>> 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)); | |||
| } | |||
| /// <summary> Gets a paged collection of all users in this guild. </summary> | |||
| public async Task<IEnumerable<GuildUser>> 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)); | |||
| } | |||
| /// <summary> Gets the user in this guild with the provided id, or null if not found. </summary> | |||
| public async Task<GuildUser> 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; | |||
| } | |||
| @@ -60,7 +60,7 @@ namespace Discord.Rest | |||
| /// <summary> </summary> | |||
| public async Task Delete() | |||
| { | |||
| await Discord.BaseClient.DeleteGuildIntegration(Guild.Id, Id).ConfigureAwait(false); | |||
| await Discord.APIClient.DeleteGuildIntegration(Guild.Id, Id).ConfigureAwait(false); | |||
| } | |||
| /// <summary> </summary> | |||
| public async Task Modify(Action<ModifyGuildIntegrationParams> 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); | |||
| } | |||
| /// <summary> </summary> | |||
| 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; | |||
| @@ -42,12 +42,12 @@ namespace Discord | |||
| /// <inheritdoc /> | |||
| public async Task Leave() | |||
| { | |||
| await Discord.BaseClient.LeaveGuild(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.LeaveGuild(Id).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task Delete() | |||
| { | |||
| await Discord.BaseClient.DeleteGuild(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.DeleteGuild(Id).ConfigureAwait(false); | |||
| } | |||
| public override string ToString() => Name; | |||
| @@ -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; | |||
| @@ -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); | |||
| } | |||
| /// <summary> Deletes this message. </summary> | |||
| public async Task Delete() | |||
| => await Discord.BaseClient.DeleteGuildRole(Guild.Id, Id).ConfigureAwait(false); | |||
| => await Discord.APIClient.DeleteGuildRole(Guild.Id, Id).ConfigureAwait(false); | |||
| /// <inheritdoc /> | |||
| public override string ToString() => Name; | |||
| @@ -76,7 +76,7 @@ namespace Discord.Rest | |||
| async Task<IEnumerable<IGuildUser>> 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)); | |||
| } | |||
| } | |||
| @@ -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<string>(); //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) | |||
| @@ -30,7 +30,7 @@ namespace Discord.Rest | |||
| /// <inheritdoc /> | |||
| 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); | |||
| } | |||
| } | |||
| @@ -48,7 +48,7 @@ namespace Discord.Rest | |||
| public async Task<DMChannel> 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); | |||
| } | |||
| @@ -27,7 +27,7 @@ namespace Discord.WebSocket | |||
| } | |||
| } | |||
| public DiscordRawClient BaseClient | |||
| public DiscordAPIClient APIClient | |||
| { | |||
| get | |||
| { | |||
| @@ -75,7 +75,7 @@ namespace Discord.WebSocket | |||
| public async Task<Message> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| @@ -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<Message> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task DeleteMessages(IEnumerable<IMessage> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task TriggerTyping() | |||
| { | |||
| await Discord.BaseClient.TriggerTypingIndicator(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.TriggerTypingIndicator(Id).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task Close() | |||
| { | |||
| await Discord.BaseClient.DeleteChannel(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.DeleteChannel(Id).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| @@ -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); | |||
| } | |||
| /// <summary> Gets a user in this channel with the given id. </summary> | |||
| @@ -82,7 +82,7 @@ namespace Discord.WebSocket | |||
| /// <summary> Downloads a collection of all invites to this channel. </summary> | |||
| public async Task<IEnumerable<InviteMetadata>> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task RemovePermissionOverwrite(IUser user) | |||
| { | |||
| await Discord.BaseClient.DeleteChannelPermission(Id, user.Id).ConfigureAwait(false); | |||
| await Discord.APIClient.DeleteChannelPermission(Id, user.Id).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task RemovePermissionOverwrite(IRole role) | |||
| { | |||
| await Discord.BaseClient.DeleteChannelPermission(Id, role.Id).ConfigureAwait(false); | |||
| await Discord.APIClient.DeleteChannelPermission(Id, role.Id).ConfigureAwait(false); | |||
| } | |||
| /// <summary> Creates a new invite to this channel. </summary> | |||
| @@ -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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task Delete() | |||
| { | |||
| await Discord.BaseClient.DeleteChannel(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.DeleteChannel(Id).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| @@ -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); | |||
| } | |||
| /// <summary> Gets the message from this channel's cache with the given id, or null if none was found. </summary> | |||
| @@ -73,7 +73,7 @@ namespace Discord.WebSocket | |||
| public async Task<Message> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| @@ -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<Message> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task DeleteMessages(IEnumerable<IMessage> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task TriggerTyping() | |||
| { | |||
| await Discord.BaseClient.TriggerTypingIndicator(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.TriggerTypingIndicator(Id).ConfigureAwait(false); | |||
| } | |||
| private string DebuggerDisplay => $"{Name} ({Id}, Text)"; | |||
| @@ -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) | |||
| @@ -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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task ModifyEmbed(Action<ModifyGuildEmbedParams> 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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task ModifyChannels(IEnumerable<ModifyGuildChannelsParams> args) | |||
| { | |||
| await Discord.BaseClient.ModifyGuildChannels(Id, args).ConfigureAwait(false); | |||
| await Discord.APIClient.ModifyGuildChannels(Id, args).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task ModifyRoles(IEnumerable<ModifyGuildRolesParams> args) | |||
| { | |||
| await Discord.BaseClient.ModifyGuildRoles(Id, args).ConfigureAwait(false); | |||
| await Discord.APIClient.ModifyGuildRoles(Id, args).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task Leave() | |||
| { | |||
| await Discord.BaseClient.LeaveGuild(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.LeaveGuild(Id).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task Delete() | |||
| { | |||
| await Discord.BaseClient.DeleteGuild(Id).ConfigureAwait(false); | |||
| await Discord.APIClient.DeleteGuild(Id).ConfigureAwait(false); | |||
| } | |||
| /// <inheritdoc /> | |||
| public async Task<IEnumerable<User>> 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)); | |||
| } | |||
| /// <inheritdoc /> | |||
| @@ -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); | |||
| } | |||
| /// <inheritdoc /> | |||
| public Task RemoveBan(IUser user) => RemoveBan(user.Id); | |||
| /// <inheritdoc /> | |||
| public async Task RemoveBan(ulong userId) | |||
| { | |||
| await Discord.BaseClient.RemoveGuildBan(Id, userId).ConfigureAwait(false); | |||
| await Discord.APIClient.RemoveGuildBan(Id, userId).ConfigureAwait(false); | |||
| } | |||
| /// <summary> Gets the channel in this guild with the provided id, or null if not found. </summary> | |||
| public async Task<GuildChannel> 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 | |||
| /// <summary> Gets a collection of all channels in this guild. </summary> | |||
| public async Task<IEnumerable<GuildChannel>> 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)); | |||
| } | |||
| /// <summary> Creates a new text channel. </summary> | |||
| @@ -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); | |||
| } | |||
| /// <summary> Creates a new voice channel. </summary> | |||
| @@ -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); | |||
| } | |||
| /// <summary> Gets a collection of all integrations attached to this guild. </summary> | |||
| public async Task<IEnumerable<GuildIntegration>> 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)); | |||
| } | |||
| /// <summary> Creates a new integration for this guild. </summary> | |||
| public async Task<GuildIntegration> 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); | |||
| } | |||
| /// <summary> Gets a collection of all invites to this guild. </summary> | |||
| public async Task<IEnumerable<InviteMetadata>> 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)); | |||
| } | |||
| /// <summary> Creates a new invite to this guild. </summary> | |||
| @@ -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<IEnumerable<GuildUser>> 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)); | |||
| } | |||
| /// <summary> Gets a paged collection of all users in this guild. </summary> | |||
| public async Task<IEnumerable<GuildUser>> 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)); | |||
| } | |||
| /// <summary> Gets the user in this guild with the provided id, or null if not found. </summary> | |||
| public async Task<GuildUser> 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; | |||
| } | |||
| @@ -60,7 +60,7 @@ namespace Discord.WebSocket | |||
| /// <summary> </summary> | |||
| public async Task Delete() | |||
| { | |||
| await Discord.BaseClient.DeleteGuildIntegration(Guild.Id, Id).ConfigureAwait(false); | |||
| await Discord.APIClient.DeleteGuildIntegration(Guild.Id, Id).ConfigureAwait(false); | |||
| } | |||
| /// <summary> </summary> | |||
| public async Task Modify(Action<ModifyGuildIntegrationParams> 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); | |||
| } | |||
| /// <summary> </summary> | |||
| 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; | |||
| @@ -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); | |||
| } | |||
| /// <inheritdoc /> | |||
| @@ -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; | |||
| @@ -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); | |||
| } | |||
| /// <summary> Deletes this message. </summary> | |||
| public async Task Delete() | |||
| => await Discord.BaseClient.DeleteGuildRole(Guild.Id, Id).ConfigureAwait(false); | |||
| => await Discord.APIClient.DeleteGuildRole(Guild.Id, Id).ConfigureAwait(false); | |||
| /// <inheritdoc /> | |||
| public override string ToString() => Name; | |||
| @@ -75,7 +75,7 @@ namespace Discord.WebSocket | |||
| async Task<IEnumerable<IGuildUser>> 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)); | |||
| } | |||
| } | |||
| @@ -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<string>(); //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) | |||
| @@ -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() | |||
| @@ -48,7 +48,7 @@ namespace Discord.WebSocket | |||
| public async Task<DMChannel> 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); | |||
| } | |||
| @@ -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(); | |||
| } | |||
| } | |||