robertwayne / dpymenus

Simplified menus for discord.py developers.
https://dpymenus.com/
MIT License
26 stars 4 forks source link

Allow menus to work in DMs. #45

Open ahdbarjoud opened 3 years ago

ahdbarjoud commented 3 years ago

I'm not sure if this is possible already, but it would be nice if I can send menus in DMs without cluttering DMs.

I have an on_raw_reaction event where if a certain reaction is made, I want to send a menu to the user's DM but the menu only accepts Context.

robertwayne commented 3 years ago

You can use .set_destination(x) on your menu object and pass in a User, Member, or Context object.

Take a look at this example in the commented code at the bottom for an idea on how to set it up.

robertwayne commented 3 years ago

I'm going to close this as it is getting old.

If this wasn't what you needed, you can reopen and I'll help you get it going! :)

ahdbarjoud commented 3 years ago

Don't I have to create a PaginatedMenu instance and pass ctx to it?

robertwayne commented 3 years ago

You can use it on any of the menu types.

Generally though, it's going to look like this:

menu = PaginatedMenu(ctx) 
menu.set_destination(ctx.author)  # this would DM the user, and the menu would be interacted from within that

By default, set_destination uses the context.channel.

ahdbarjoud commented 3 years ago

Yes but I'm using this in on_raw_reaction_add so I don't get the context to add. I know I can create context by fetching the message from payload.message_id, but I'm having this as a last resort as I want to make as less requests as possible.