Skip to content Skip to sidebar Skip to footer

Send A Pm From Discord.py Rewrite

I'm trying to figure out how to send a pm from a discord.py rewrite bot. I can't do ctx.author.send('context') because it messaging someone other than the author of the message. he

Solution 1:

You can use a converter to resolve the User object of your victim automatically.

@bot.command()
async def spam(ctx, victim: discord.User, amount, *, message):
    for _ in range(amount):
        await victim.send(message)

You can then use their name, id, or a mention to specify them:

!spam Denard 1 spam spam spam
!spam @Denard 1 spam spam spam
!spam 1234 1 spam spam spam

Post a Comment for "Send A Pm From Discord.py Rewrite"