0
votes

I'm trying to make this Discord bot in python that when you give the command sends a private message to two people and try to get the message that is sent after

@client.command()
async def dm(ctx, member_1:discord.Member, member_2:discord.Member):
    await member_1.send(f'sup member 1 type something')
    await member_2.send(f'sup member 2 type something')

    def check(m):
            return m.author == ctx.author

    msg1 = await client.wait_for('message', check=check)

    def check_2(m):
            return m.member_2 == discord.Member

    msg2 = await client.wait_for('message', check=check_2)

    print(msg1.content)
    print(msg2.content)

my problem is that when the second member sends the message it gives me a error 'Message' object has no attribute 'member_2'

if I delete the second member it works fine and gets my input and prints out what I typed but with the second member types something and it prints nothing, when the second member sends his message the error shows up

what should i put in the second check to work?

1

1 Answers

0
votes

All you have to do is fix the second return statement.

Inside the check functions, m is the message that the function is supposed to check. Of course this m will not have a member_2 attribute by default.

But the real problem is: why are you checking

m.member_2 == discord.Member

If you want to check if the author is a member (which it has to be) then you would have to type

type(m.author) == discord.Member

What you want is to check if the author of that message is member_2. Then you have to type the same thing as you did in your first check function:

return m.author == member_2

Here's the fixed code. By the way, I'm assuming that msg_1 is the message that member 1 sends and not the ctx.author.

    def check_1(m):
        return m.author == member_1  # checks if the person who sent it is member_1

    msg1 = await client.wait_for('message', check=check_1)

    def check_2(m):
        return m.author == member_2  # checks if the person who sent it is member_2

    msg2 = await client.wait_for('message', check=check_2)