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

Make bookmark a context menu command #1176

Conversation

shtlrs
Copy link
Member

@shtlrs shtlrs commented Dec 23, 2022

NOTE
This needs to wait for this PR before it can be merged, since it will be the one syncing the command tree.
Once that has been completed & merged, bot-core version needs to be bumped and then merged into main, then this branch will be updated

Closes #1089

This adds the support of bookmarking a message from a context menu, but preserves the old behavior as well.

To not lose the functionality of choosing a custom title, a modal has been added where a user is prompted for a title, which they can freely skip.

Workflow

  1. As usual, a user needs to identify a message to bookmark
    image

  2. A user hovers on the message, then clicks on the ellipsis (three dots) -> Apps -> Bookmark
    image

  3. A user will be asked to choose a custom title for their bookmark, but they can freely ignore that step by clicking on Submit and the default title Bookmark will be chosen
    image

  4. Once submitted, the bookmark is sent as usual as a DM to the user, the only difference is that the bookmark embed in the invoked channel is now ephemeral
    image
    image

Copy link
Contributor

@Robin5605 Robin5605 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, thanks for the PR!
Just a few issues 🙂

bot/exts/utilities/bookmark.py Outdated Show resolved Hide resolved
bot/exts/utilities/bookmark.py Outdated Show resolved Hide resolved
bot/exts/utilities/bookmark.py Show resolved Hide resolved
@shtlrs shtlrs added status: needs review Author is waiting for someone to review and approve type: enhancement Changes or improvements to existing features labels Dec 27, 2022
bot/exts/utilities/bookmark.py Outdated Show resolved Hide resolved
bot/exts/utilities/bookmark.py Outdated Show resolved Hide resolved
bot/exts/utilities/bookmark.py Show resolved Hide resolved
"""Sends the bookmark embed to the user with the newly chosen title."""
title = self.bookmark_title.value or self.bookmark_title.default
await self.action_bookmark(interaction.channel, interaction.user, self.message, title)
view = SendBookmark(self.action_bookmark, interaction.user, interaction.channel, self.message, title)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this message is ephemeral, I don't think there's a need for the button that says "Click this to get your very own bookmark" or whatever it was. The whole point of the button was that multiple people wouldn't be running the .bookmark command in succession to the same message and flooding the channel - but with ephemeral messages, that's not an issue. So I think this button would just lead to more confusion and is unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one has also been resolved in cf49035

I just happened to make a new static method that builds an embed that's only used when the context menu command is invoked

bot/exts/utilities/bookmark.py Show resolved Hide resolved
Copy link
Member Author

@shtlrs shtlrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, comments have been addressed and it's ready for review again

bot/exts/utilities/bookmark.py Outdated Show resolved Hide resolved
bot/exts/utilities/bookmark.py Show resolved Hide resolved
bot/exts/utilities/bookmark.py Outdated Show resolved Hide resolved
bot/exts/utilities/bookmark.py Outdated Show resolved Hide resolved
bot/exts/utilities/bookmark.py Show resolved Hide resolved
bot/exts/utilities/bookmark.py Show resolved Hide resolved
"""Sends the bookmark embed to the user with the newly chosen title."""
title = self.bookmark_title.value or self.bookmark_title.default
await self.action_bookmark(interaction.channel, interaction.user, self.message, title)
view = SendBookmark(self.action_bookmark, interaction.user, interaction.channel, self.message, title)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one has also been resolved in cf49035

I just happened to make a new static method that builds an embed that's only used when the context menu command is invoked

@shtlrs shtlrs requested a review from Robin5605 January 14, 2023 09:42
Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Played around with the command and noticed a few things:

  • The command didn't seem to sync automatically, I had to run .int eval `await bot.tree.sync()` for it to appear.
  • The first time I use the command, this seems to stay there forever:
    image
    For bookmarks run after that it disappears normally, although after refreshing the client the same thing happens again.
  • Running the command in DMs with the bot gives a message saying you don't have permission to view that channel
    image
    It's pretty minor, and there's no point in allowing using the command in DMs, but the error message could be better.

Not sure if any of these are discord bugs rather than issues with the code, although worth looking into.

bot/exts/utilities/bookmark.py Outdated Show resolved Hide resolved
@shtlrs
Copy link
Member Author

shtlrs commented Jan 15, 2023

  • The command didn't seem to sync automatically, I had to run .int eval `await bot.tree.sync()` for it to appear.

I think you might have missed the description, this relies on the newest release of pydis_core, where the tree is synced upon loading extensions. So that might be the reason.

  • The first time I use the command, this seems to stay there forever:
    image
    For bookmarks run after that it disappears normally, although after refreshing the client the same thing happens again.

This has also happened to me, but since it threw no errors, i thought it could be a discord bug or something.
I couldn't seem to figure out why since, like you said, it only happens the first time.

  • Running the command in DMs with the bot gives a message saying you don't have permission to view that channel
    image
    It's pretty minor, and there's no point in allowing using the command in DMs, but the error message could be better.

Well, we could check if the interaction channel is part of a guild or not, if not then it's a DM --> we change the message
But the thing is, we are completely overlooking the dm_permissions method here, which does include read_permissions.

So I think it's just better to agree on not allowing the usage of such command in DMs, and if that's the case, we send a message saying so.

@wookie184
Copy link
Contributor

wookie184 commented Jan 15, 2023

I think you might have missed the description, this relies on the newest release of pydis_core, where the tree is synced upon loading extensions. So that might be the reason.

I noticed that but since the PR was merged I assumed poetry install would do fine. Is it just that the version used by this project needs to be bumped now?

Indeed, I'll send a PR to bump it.

@wookie184
Copy link
Contributor

Looks like there are some commits from other PRs that shouldn't be here

@shtlrs
Copy link
Member Author

shtlrs commented Jan 17, 2023

Looks like there are some commits from other PRs that shouldn't be here

I think those are the results of the rebase ?

@shtlrs shtlrs changed the base branch from main to command-match-errors January 22, 2023 20:05
@shtlrs shtlrs changed the base branch from command-match-errors to main January 22, 2023 20:05
Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also seems like the hanging command problem isn't there for me either any more👍

Amrou Bellalouna added 14 commits February 19, 2023 14:42
This removes the need of the `user_is_permitted_to_bookmark` func, and keeps the code cleaner & more coherent

It always relis on using interaction.response to reply instead of context, which might result in a failed interaction
This bus was introduced upon refactoring the perms check, and it calls channel from within a channel.
This bus was introduced upon refactoring the perms check.
It tries to access an author property from within a user, which doesn't exist.
This prompts the user for a custom title for their input.

This has been added to not lose the functionality of adding a custom title for a bookmark for those who need it.
This will be sent along the ephemeral message
@shtlrs shtlrs force-pushed the 1089-make-bookmark-a-context-menu-command branch from f262d72 to 0dae917 Compare February 19, 2023 13:44
@ChrisLovering ChrisLovering merged commit 310d199 into python-discord:main Feb 19, 2023
"""

bookmark_title = discord.ui.TextInput(
label="Choose a title for you bookmark (optional)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
label="Choose a title for you bookmark (optional)",
label="Choose a title for your bookmark (optional)",

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5d0ac27 (#1211)

@Xithrius Xithrius removed the status: needs review Author is waiting for someone to review and approve label Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Changes or improvements to existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow bookmarking a message from a context menu
6 participants