@@ -45,6 +45,7 @@ namespace Discord.API
internal string AuthToken { get; private set; }
internal IRestClient RestClient { get; private set; }
internal ulong? CurrentUserId { get; set; }
internal ulong? CurrentApplicationId { get; set; }
internal bool UseSystemClock { get; set; }
internal Func<IRateLimitInfo, Task> DefaultRatelimitCallback { get; set; }
internal JsonSerializer Serializer => _serializer;
@@ -1191,7 +1192,7 @@ namespace Discord.API
{
options = RequestOptions.CreateOrClone(options);
return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{CurrentUser Id}/commands", new BucketIds(), options: options).ConfigureAwait(false);
return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{CurrentApplication Id}/commands", new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task<ApplicationCommand> GetGlobalApplicationCommandAsync(ulong id, RequestOptions options = null)
@@ -1202,7 +1203,7 @@ namespace Discord.API
try
{
return await SendAsync<ApplicationCommand>("GET", () => $"applications/{CurrentUser Id}/commands/{id}", new BucketIds(), options: options).ConfigureAwait(false);
return await SendAsync<ApplicationCommand>("GET", () => $"applications/{CurrentApplication Id}/commands/{id}", new BucketIds(), options: options).ConfigureAwait(false);
}
catch (HttpException x) when (x.HttpCode == HttpStatusCode.NotFound) { return null; }
}
@@ -1222,38 +1223,38 @@ namespace Discord.API
options = RequestOptions.CreateOrClone(options);
return await SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{CurrentUser Id}/commands", command, new BucketIds(), options: options).ConfigureAwait(false);
return await SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{CurrentApplication Id}/commands", command, new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task<ApplicationCommand> ModifyGlobalApplicationCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null)
{
options = RequestOptions.CreateOrClone(options);
return await SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentUser Id}/commands/{commandId}", command, new BucketIds(), options: options).ConfigureAwait(false);
return await SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentApplication Id}/commands/{commandId}", command, new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task<ApplicationCommand> ModifyGlobalApplicationUserCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null)
{
options = RequestOptions.CreateOrClone(options);
return await SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentUser Id}/commands/{commandId}", command, new BucketIds(), options: options).ConfigureAwait(false);
return await SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentApplication Id}/commands/{commandId}", command, new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task<ApplicationCommand> ModifyGlobalApplicationMessageCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null)
{
options = RequestOptions.CreateOrClone(options);
return await SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentUser Id}/commands/{commandId}", command, new BucketIds(), options: options).ConfigureAwait(false);
return await SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentApplication Id}/commands/{commandId}", command, new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task DeleteGlobalApplicationCommandAsync(ulong commandId, RequestOptions options = null)
{
options = RequestOptions.CreateOrClone(options);
await SendAsync("DELETE", () => $"applications/{CurrentUser Id}/commands/{commandId}", new BucketIds(), options: options).ConfigureAwait(false);
await SendAsync("DELETE", () => $"applications/{CurrentApplication Id}/commands/{commandId}", new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task<ApplicationCommand[]> BulkOverwriteGlobalApplicationCommandsAsync(CreateApplicationCommandParams[] commands, RequestOptions options = null)
{
options = RequestOptions.CreateOrClone(options);
return await SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{CurrentUser Id}/commands", commands, new BucketIds(), options: options).ConfigureAwait(false);
return await SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{CurrentApplication Id}/commands", commands, new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task<ApplicationCommand[]> GetGuildApplicationCommandsAsync(ulong guildId, RequestOptions options = null)
@@ -1262,7 +1263,7 @@ namespace Discord.API
var bucket = new BucketIds(guildId: guildId);
return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{CurrentUser Id}/guilds/{guildId}/commands", bucket, options: options).ConfigureAwait(false);
return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{CurrentApplication Id}/guilds/{guildId}/commands", bucket, options: options).ConfigureAwait(false);
}
public async Task<ApplicationCommand> GetGuildApplicationCommandAsync(ulong guildId, ulong commandId, RequestOptions options = null)
@@ -1273,7 +1274,7 @@ namespace Discord.API
try
{
return await SendAsync<ApplicationCommand>("GET", () => $"applications/{CurrentUser Id}/guilds/{guildId}/commands/{commandId}", bucket, options: options);
return await SendAsync<ApplicationCommand>("GET", () => $"applications/{CurrentApplication Id}/guilds/{guildId}/commands/{commandId}", bucket, options: options);
}
catch (HttpException x) when (x.HttpCode == HttpStatusCode.NotFound) { return null; }
}
@@ -1295,7 +1296,7 @@ namespace Discord.API
var bucket = new BucketIds(guildId: guildId);
return await SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{CurrentUser Id}/guilds/{guildId}/commands", command, bucket, options: options).ConfigureAwait(false);
return await SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{CurrentApplication Id}/guilds/{guildId}/commands", command, bucket, options: options).ConfigureAwait(false);
}
public async Task<ApplicationCommand> ModifyGuildApplicationCommandAsync(ModifyApplicationCommandParams command, ulong guildId, ulong commandId, RequestOptions options = null)
{
@@ -1303,7 +1304,7 @@ namespace Discord.API
var bucket = new BucketIds(guildId: guildId);
return await SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentUser Id}/guilds/{guildId}/commands/{commandId}", command, bucket, options: options).ConfigureAwait(false);
return await SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentApplication Id}/guilds/{guildId}/commands/{commandId}", command, bucket, options: options).ConfigureAwait(false);
}
public async Task DeleteGuildApplicationCommandAsync(ulong guildId, ulong commandId, RequestOptions options = null)
{
@@ -1311,7 +1312,7 @@ namespace Discord.API
var bucket = new BucketIds(guildId: guildId);
await SendAsync<ApplicationCommand>("DELETE", () => $"applications/{CurrentUser Id}/guilds/{guildId}/commands/{commandId}", bucket, options: options).ConfigureAwait(false);
await SendAsync<ApplicationCommand>("DELETE", () => $"applications/{CurrentApplication Id}/guilds/{guildId}/commands/{commandId}", bucket, options: options).ConfigureAwait(false);
}
public async Task<ApplicationCommand[]> BulkOverwriteGuildApplicationCommandsAsync(ulong guildId, CreateApplicationCommandParams[] commands, RequestOptions options = null)
@@ -1320,7 +1321,7 @@ namespace Discord.API
var bucket = new BucketIds(guildId: guildId);
return await SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{CurrentUser Id}/guilds/{guildId}/commands", commands, bucket, options: options).ConfigureAwait(false);
return await SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{CurrentApplication Id}/guilds/{guildId}/commands", commands, bucket, options: options).ConfigureAwait(false);
}
#endregion
@@ -1353,19 +1354,19 @@ namespace Discord.API
options = RequestOptions.CreateOrClone(options);
return await NullifyNotFound(SendAsync<Message>("GET", () => $"webhooks/{CurrentUser Id}/{interactionToken}/messages/@original", new BucketIds(), options: options)).ConfigureAwait(false);
return await NullifyNotFound(SendAsync<Message>("GET", () => $"webhooks/{CurrentApplication Id}/{interactionToken}/messages/@original", new BucketIds(), options: options)).ConfigureAwait(false);
}
public async Task<Message> ModifyInteractionResponseAsync(ModifyInteractionResponseParams args, string interactionToken, RequestOptions options = null)
{
options = RequestOptions.CreateOrClone(options);
return await SendJsonAsync<Message>("PATCH", () => $"webhooks/{CurrentUser Id}/{interactionToken}/messages/@original", args, new BucketIds(), options: options);
return await SendJsonAsync<Message>("PATCH", () => $"webhooks/{CurrentApplication Id}/{interactionToken}/messages/@original", args, new BucketIds(), options: options);
}
public async Task DeleteInteractionResponseAsync(string interactionToken, RequestOptions options = null)
{
options = RequestOptions.CreateOrClone(options);
await SendAsync("DELETE", () => $"webhooks/{CurrentUser Id}/{interactionToken}/messages/@original", new BucketIds(), options: options);
await SendAsync("DELETE", () => $"webhooks/{CurrentApplication Id}/{interactionToken}/messages/@original", new BucketIds(), options: options);
}
public async Task<Message> CreateInteractionFollowupMessageAsync(CreateWebhookMessageParams args, string token, RequestOptions options = null)
@@ -1379,9 +1380,9 @@ namespace Discord.API
options = RequestOptions.CreateOrClone(options);
if (!args.File.IsSpecified)
return await SendJsonAsync<Message>("POST", () => $"webhooks/{CurrentUser Id}/{token}?wait=true", args, new BucketIds(), options: options).ConfigureAwait(false);
return await SendJsonAsync<Message>("POST", () => $"webhooks/{CurrentApplication Id}/{token}?wait=true", args, new BucketIds(), options: options).ConfigureAwait(false);
else
return await SendMultipartAsync<Message>("POST", () => $"webhooks/{CurrentUser Id}/{token}?wait=true", args.ToDictionary(), new BucketIds(), options: options).ConfigureAwait(false);
return await SendMultipartAsync<Message>("POST", () => $"webhooks/{CurrentApplication Id}/{token}?wait=true", args.ToDictionary(), new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task<Message> CreateInteractionFollowupMessageAsync(UploadWebhookFileParams args, string token, RequestOptions options = null)
@@ -1395,7 +1396,7 @@ namespace Discord.API
options = RequestOptions.CreateOrClone(options);
var ids = new BucketIds();
return await SendMultipartAsync<Message>("POST", () => $"webhooks/{CurrentUser Id}/{token}?wait=true", args.ToDictionary(), ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false);
return await SendMultipartAsync<Message>("POST", () => $"webhooks/{CurrentApplication Id}/{token}?wait=true", args.ToDictionary(), ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false);
}
public async Task<Message> ModifyInteractionFollowupMessageAsync(ModifyInteractionResponseParams args, ulong id, string token, RequestOptions options = null)
@@ -1408,7 +1409,7 @@ namespace Discord.API
options = RequestOptions.CreateOrClone(options);
return await SendJsonAsync<Message>("PATCH", () => $"webhooks/{CurrentUser Id}/{token}/messages/{id}", args, new BucketIds(), options: options).ConfigureAwait(false);
return await SendJsonAsync<Message>("PATCH", () => $"webhooks/{CurrentApplication Id}/{token}/messages/{id}", args, new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task DeleteInteractionFollowupMessageAsync(ulong id, string token, RequestOptions options = null)
@@ -1417,7 +1418,7 @@ namespace Discord.API
options = RequestOptions.CreateOrClone(options);
await SendAsync("DELETE", () => $"webhooks/{CurrentUser Id}/{token}/messages/{id}", new BucketIds(), options: options).ConfigureAwait(false);
await SendAsync("DELETE", () => $"webhooks/{CurrentApplication Id}/{token}/messages/{id}", new BucketIds(), options: options).ConfigureAwait(false);
}
#endregion
@@ -1428,7 +1429,7 @@ namespace Discord.API
options = RequestOptions.CreateOrClone(options);
return await SendAsync<GuildApplicationCommandPermission[]>("GET", () => $"applications/{CurrentUser Id}/guilds/{guildId}/commands/permissions", new BucketIds(), options: options).ConfigureAwait(false);
return await SendAsync<GuildApplicationCommandPermission[]>("GET", () => $"applications/{CurrentApplication Id}/guilds/{guildId}/commands/permissions", new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task<GuildApplicationCommandPermission> GetGuildApplicationCommandPermissionAsync(ulong guildId, ulong commandId, RequestOptions options = null)
@@ -1438,7 +1439,7 @@ namespace Discord.API
options = RequestOptions.CreateOrClone(options);
return await SendAsync<GuildApplicationCommandPermission>("GET", () => $"applications/{CurrentUser Id}/guilds/{guildId}/commands/{commandId}/permissions", new BucketIds(), options: options).ConfigureAwait(false);
return await SendAsync<GuildApplicationCommandPermission>("GET", () => $"applications/{CurrentApplication Id}/guilds/{guildId}/commands/{commandId}/permissions", new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task<GuildApplicationCommandPermission> ModifyApplicationCommandPermissionsAsync(ModifyGuildApplicationCommandPermissionsParams permissions, ulong guildId, ulong commandId, RequestOptions options = null)
@@ -1448,7 +1449,7 @@ namespace Discord.API
options = RequestOptions.CreateOrClone(options);
return await SendJsonAsync<GuildApplicationCommandPermission>("PUT", () => $"applications/{CurrentUser Id}/guilds/{guildId}/commands/{commandId}/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false);
return await SendJsonAsync<GuildApplicationCommandPermission>("PUT", () => $"applications/{CurrentApplication Id}/guilds/{guildId}/commands/{commandId}/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task<IReadOnlyCollection<GuildApplicationCommandPermission>> BatchModifyApplicationCommandPermissionsAsync(ModifyGuildApplicationCommandPermissions[] permissions, ulong guildId, RequestOptions options = null)
@@ -1458,7 +1459,7 @@ namespace Discord.API
options = RequestOptions.CreateOrClone(options);
return await SendJsonAsync<GuildApplicationCommandPermission[]>("PUT", () => $"applications/{CurrentUser Id}/guilds/{guildId}/commands/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false);
return await SendJsonAsync<GuildApplicationCommandPermission[]>("PUT", () => $"applications/{CurrentApplication Id}/guilds/{guildId}/commands/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false);
}
#endregion