-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add User Apps #266
base: current
Are you sure you want to change the base?
Add User Apps #266
Conversation
I would recommend adding an |
Also probably the docs should be updated with the new I can also confirm, that this pr works as expected, when using the current branch of serenity (as is expected). |
Hey, @fgardt do you plan on fixing the CI failures? |
I'll look into it yeah |
b238074
to
3809973
Compare
hello, i've been testing this pr more in depth and subcommands work weirdly:
lets say you have a parent command: /bot and you want to make a "reload" command for the bot owner which reloads the bot #[poise::command(
slash_command,
subcommands("reload"),
install_context = "Guild|User",
// hmm... only 1 command needs to be different; so lets do a non-restrictive selection
interaction_context = "Guild|BotDm|PrivateChannel"
)]
pub async fn bot(_: Ctx<'_>) -> Result<(), CommandError> {}
#[poise::command(
slash_command,
owners_only,
// great! now we can make this a botdm command to prevent confusion?
install_context = "User",
interaction_context = "BotDm"
)]
pub async fn reload(ctx: Ctx<'_>) -> Result<(), CommandError> {
// ... reload logic
} sadly, the subcommand has no control over its interaction_context or its install_context, which means the command will show up in guilds and in group dms, which is not the intended behavior |
Subcommands inherit context and permissions from the parent, this is a limitation of discord itself. At most extra documentation (if there isn't any of inheriting context) can be added, but its already mentioned for permissions in our docs. |
Any idea when this will be merged/released? I'd like to see this functionality become available. |
You are welcome to use this as your base for the mean time but it would be nice to see the API in serenity be updated first before this rolls out. It'll happen when it does and there is no ETA for this feature. |
Any update on this? |
Considering this isn't merged or hasn't had a single commit since your question answers itself, no, there is no update on this. |
What is missing from this pr? |
User Apps should reasonably be stabilized on serenity first as the upstream discord API is stable now. |
I just tested this PR and it only registers 2 commands out of 15 at the user level. #[poise::command(
slash_command,
prefix_command,
rename = "avatar",
category = "utils",
required_bot_permissions = "SEND_MESSAGES | EMBED_LINKS",
ephemeral,
install_context = "Guild | User"
)]
pub async fn command(...) ... |
@sawa-ko I've been using this PR's User install context feature in a couple of my bots and it appears to work fine. You might need to restart your Discord client (or Ctrl+R) when you add new global commands to your bot, as it doesn't do a good job of picking them up automatically. |
@zkxs I did it, I also reinstalled the app and the same commands still appear, I also tried from the web / ios app and same result. |
@sawa-ko did you set |
@fgardt Hum, I have tried it and same result. I have noticed that in some servers the commands appear and in others only 2 appear, what can it be? |
@fgardt The Discord docs say:
So unless serenity has its own special behavior when @sawa-ko It might be helpful if you can share the command setup for a working and a broken command so we can compare. You only showed one example in #266 (comment), and it's unclear if that's one of the 2 working or the 13 broken. Or are all your commands set up identically? Is the bot installed to any of the servers you're testing against? Or is it only installed to your user? Is your command registration code registering all 15 commands globally? |
Command working: /// Check the bot's latency
///
/// This command will show you the bot's latency, the server it is currently on,
/// the number of members on the server, the bot's memory usage, and the bot's
/// ping with discord.
#[poise::command(
slash_command,
prefix_command,
rename = "ping",
category = "general",
required_bot_permissions = "SEND_MESSAGES",
ephemeral,
install_context = "Guild | User",
interaction_context = "Guild | BotDm | PrivateChannel"
)]
pub async fn command(ctx: CommandContext<'_>) -> CommandResult {} Command not working: #[poise::command(
slash_command,
prefix_command,
rename = "avatar",
category = "utils",
required_bot_permissions = "SEND_MESSAGES | EMBED_LINKS",
ephemeral,
install_context = "Guild | User",
interaction_context = "Guild | BotDm | PrivateChannel"
)]
pub async fn command(
ctx: CommandContext<'_>,
#[description = "User with the avatar that you need."] user: User,
) -> CommandResult {}
|
@sawa-ko Seeing as those commands have identical setups (the difference in |
@zkxs I don't think it's that because if I add the bot to the server they all appear. |
Ok, I saw what the problem was, I forgot that they are subcommands, not proper commands. 😭 Sorryyyyy. |
Huh, does anyone know if subcommands are supposed to work in user-installable apps? It's unclear to me if this is functionality that's missing in Discord itself or if this is an oversight in serenity, poise, or this PR. |
@zkxs my use case is using subcommands (only 1 layer tho) and they work perfectly fine as userapps |
Hello. My understanding is that User apps are now stable in Discord and serenity. Is there a way I can help to move this forward as I'd like to have my bot be a User App as well. |
Not until serenity-rs/serenity#3018 and a release. You can speed things along by reviewing the aforementioned PR. |
Unfortunately I do not have write access or I would look through it. It does seem mostly bookkeeping. |
Ayy the serenity pr was merged |
yeah I'll update this PR accordingly |
A new serenity release has (finally) happened, nothing should be blocking this anymore. |
this is the implementation for user apps that I've been using like this since 3 days after user apps got announced / released to beta.
I like the flexibility that having
install_context
andinteraction_context
being separate properties brings but there were concerns regarding usability / it being too complex.example:
note: this added the
unstable_discord_api
feature to the serenity dependency, that should probably be removed again(?) I have not found a nice way to feature guard this without having to chain the feature flag in everywhere and some other issues.