Search code examples
pythondiscord.pysenddm

AttributeError: 'ClientUser' object has no attribute 'create_dm' (discord.py, I'm trying to dm all members of a guild)


I've been trying to send a DM to all members of a guild, but I always get this error:

AttributeError: 'ClientUser' object has no attribute 'create_dm'

This is my code

@bot.command()
async def send(ctx, *, message):
    for member in ctx.guild.members:
        channel = await member.create_dm()
        channel.send(message)
    await ctx.send('Messages successfully sent!')

What am I doing wrong?


Solution

  • I figured it out, I have to await the channel.send