serenity
serenity copied to clipboard
Unable to set permissions for slash commands
Description
Unable to set permissions for a slash command
Version
Cargo.toml is:
[dependencies.serenity]
default-features = false
features = [
"client",
"gateway",
"rustls_backend",
"model",
"collector"
]
version = "0.11"
Example Output
Trying to set permissions for a slash command like so:
let permissions = GuildId::set_application_commands_permissions(&guild_id, &ctx, |commands| {
commands
.create_application_command(|permission| {
permission
.id(<my_command_id>)
.create_permissions(|perm| {
perm
.kind(ApplicationCommandPermissionType::Role)
.id(<my_user_id>)
.permission(true)
})
})
})
.await.unwrap();
Generates a panic:
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Http(UnsuccessfulRequest(ErrorResponse { status_code: 405, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("discord.com")), port: None, path: "/api/v10/applications/<my_application_id>/guilds/<my_guild_id>/commands/permissions", query: None, fragment: None }, error: DiscordJsonError { code: 0, message: "405: Method Not Allowed", errors: [] } }))', src/main.rs:119:16
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I validated which endpoint serenity is using to set permissions for slash commands, it is sending PUT https://discord.com/api/v10/applications/<my_application_id>/guilds/<my_gulid_id>/commands/permissions
to update slash command permissions.
According to the discord docs this endpoint has been disabled with permissions v2 update to the api.
Serenity should be updated to edit each application command individually respecting rate limits.
I am happy to take this task on and generate a PR if no one else is looking at it currently.
This would also be helpful for me!
set_application_commands_permissions was deprecated in next minor version (#2077) and removed in next breaking version (#2078)
This issue can be closed