Rapptz / discord-ext-menus

MIT License
234 stars 87 forks source link

Menu.start() cannot send to DMs #40

Closed tuzonghua closed 3 years ago

tuzonghua commented 3 years ago

Menu.start() accepts a channel argument of type discord.abc.Messageable, which should mean menus can be sent to DMs. However, it looks like it calls permissions_for here, which doesn't exist on the discord.Member class, even though that class implements the Messageable ABC.

For example, this returns an error AttributeError: 'Member' object has no attribute 'permissions_for':

@bot.command()
async def menu_example(ctx):
    m = MyMenu()
    await m.start(ctx, channel=ctx.author)

Let me know if I'm misunderstanding how this should work.

diceroll123 commented 3 years ago

You're going to have to use a modified context if you're going to... change the context of the command mid-way.

snvgglebear commented 3 years ago

You can override the send_initial_message function and use ctx.author.send.

diceroll123 commented 3 years ago

I missed your original point, OP.

What's wrong here is that you're calling a Member object a Messageable object.

Simply do

dm = await ctx.author.create_dm()
await m.start(ctx, channel=dm)

And it shoooould work

tuzonghua commented 3 years ago

@diceroll123 Yes, that worked perfectly. I just missed how to get a DMChannel to call start() with.