|
|
@@ -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/{CurrentUserId}/commands", new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/commands/{id}", new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendAsync<ApplicationCommand>("GET", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/commands", command, new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/commands/{commandId}", new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
await SendAsync("DELETE", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/commands", commands, new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/guilds/{guildId}/commands", bucket, options: options).ConfigureAwait(false); |
|
|
|
return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/guilds/{guildId}/commands/{commandId}", bucket, options: options); |
|
|
|
return await SendAsync<ApplicationCommand>("GET", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/guilds/{guildId}/commands", command, bucket, options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/guilds/{guildId}/commands/{commandId}", command, bucket, options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/guilds/{guildId}/commands/{commandId}", bucket, options: options).ConfigureAwait(false); |
|
|
|
await SendAsync<ApplicationCommand>("DELETE", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/guilds/{guildId}/commands", commands, bucket, options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options)).ConfigureAwait(false); |
|
|
|
return await NullifyNotFound(SendAsync<Message>("GET", () => $"webhooks/{CurrentApplicationId}/{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/{CurrentUserId}/{interactionToken}/messages/@original", args, new BucketIds(), options: options); |
|
|
|
return await SendJsonAsync<Message>("PATCH", () => $"webhooks/{CurrentApplicationId}/{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/{CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options); |
|
|
|
await SendAsync("DELETE", () => $"webhooks/{CurrentApplicationId}/{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/{CurrentUserId}/{token}?wait=true", args, new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<Message>("POST", () => $"webhooks/{CurrentApplicationId}/{token}?wait=true", args, new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
else |
|
|
|
return await SendMultipartAsync<Message>("POST", () => $"webhooks/{CurrentUserId}/{token}?wait=true", args.ToDictionary(), new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendMultipartAsync<Message>("POST", () => $"webhooks/{CurrentApplicationId}/{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/{CurrentUserId}/{token}?wait=true", args.ToDictionary(), ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false); |
|
|
|
return await SendMultipartAsync<Message>("POST", () => $"webhooks/{CurrentApplicationId}/{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/{CurrentUserId}/{token}/messages/{id}", args, new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<Message>("PATCH", () => $"webhooks/{CurrentApplicationId}/{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/{CurrentUserId}/{token}/messages/{id}", new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
await SendAsync("DELETE", () => $"webhooks/{CurrentApplicationId}/{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/{CurrentUserId}/guilds/{guildId}/commands/permissions", new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendAsync<GuildApplicationCommandPermission[]>("GET", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendAsync<GuildApplicationCommandPermission>("GET", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<GuildApplicationCommandPermission>("PUT", () => $"applications/{CurrentApplicationId}/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/{CurrentUserId}/guilds/{guildId}/commands/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<GuildApplicationCommandPermission[]>("PUT", () => $"applications/{CurrentApplicationId}/guilds/{guildId}/commands/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
} |
|
|
|
#endregion |
|
|
|
|
|
|
|