Skip to content
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

Open
wants to merge 3 commits into
base: current
Choose a base branch
from
Open

Add User Apps #266

wants to merge 3 commits into from

Conversation

fgardt
Copy link

@fgardt fgardt commented May 14, 2024

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 and interaction_context being separate properties brings but there were concerns regarding usability / it being too complex.

example:

#[poise::command(
    slash_command,
    install_context = "Guild|User",
    interaction_context = "Guild|BotDm|PrivateChannel"
)]
pub async fn info(ctx: Ctx<'_>) -> Result<(), CommandError> {
  // ...command impl...
}

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.

@fgardt fgardt marked this pull request as ready for review May 14, 2024 21:07
@GnomedDev
Copy link
Member

I would recommend adding an unstable feature flag to poise, which enables the unstable_discord_api flag in serenity.

@C0D3-M4513R
Copy link

Also probably the docs should be updated with the new install_context and interaction_context options, if the unstable feature is enabled?

I can also confirm, that this pr works as expected, when using the current branch of serenity (as is expected).

@GnomedDev
Copy link
Member

Hey, @fgardt do you plan on fixing the CI failures?

@fgardt
Copy link
Author

fgardt commented May 26, 2024

I'll look into it yeah

@fgardt fgardt force-pushed the feat/user_apps branch 4 times, most recently from b238074 to 3809973 Compare June 1, 2024 22:40
@techs-sus
Copy link

techs-sus commented Jun 15, 2024

hello, i've been testing this pr more in depth and subcommands work weirdly:

  • the "parent" of the subcommands have full authority over interaction and install contexts
  • the subcommands themselves cannot override the interaction context which results in interesting behavior

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

@jamesbt365
Copy link
Contributor

jamesbt365 commented Jun 15, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants