poise
poise copied to clipboard
`context_menu_command` doesn't work for subcommands
The context_menu_command
macro arguments doesn't work with subcommands
Maybe I'm doing it wrong, but this is the code I have :
use crate::{Context, Error};
use poise::serenity_prelude as serenity;
/// Get the avatar of a user or the icon of the current server.
#[poise::command(slash_command, subcommands("user", "server"))]
pub async fn picture(_: Context<'_>) -> Result<(), Error> {
Ok(())
}
/// Get the icon of the current server.
#[poise::command(slash_command, guild_only)]
pub async fn server(ctx: Context<'_>) -> Result<(), Error> {
ctx.say(
ctx.guild()
.unwrap()
.icon_url()
.unwrap_or("🫥 This server doesn't have an icon.".to_string())
.replace("webp", "png?size=4096"),
)
.await?;
Ok(())
}
/// Get the avatar of a user.
#[poise::command(context_menu_command = "Get avatar", slash_command)]
pub async fn user(
ctx: Context<'_>,
#[description = "Discord profile to query information about"] user: serenity::User,
) -> Result<(), Error> {
let response = user.face().replace("webp?size=1024", "png?size=4096");
ctx.say(response).await?;
Ok(())
}
/picture user
and /picture server
work fine when invoking them via slash commands, but when I try to invoke Get avatar
, I get no reponse (timeout) and the function is never called (but is still registered as a context menu command!)