dpymenus icon indicating copy to clipboard operation
dpymenus copied to clipboard

Allow menus to work in DMs.

Open ahdbarjoud opened this issue 4 years ago • 5 comments

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.

ahdbarjoud avatar Apr 02 '21 22:04 ahdbarjoud

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 avatar Apr 03 '21 00:04 robertwayne

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! :)

robertwayne avatar Apr 05 '21 12:04 robertwayne

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

ahdbarjoud avatar Apr 05 '21 23:04 ahdbarjoud

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.

robertwayne avatar Apr 06 '21 00:04 robertwayne

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.

ahdbarjoud avatar Apr 06 '21 00:04 ahdbarjoud