kiddo42069
kiddo42069

Reputation: 19

discord.py bot can't dm multiple users with a role


@client.command()
async def eventsoon(ctx):
  role = discord.utils.get(ctx.message.guild.roles, name='Golden God')
  for member in ctx.message.guild.members:
    if role in member.roles:
      await member.send("ur mom")

I want the bot to dm users with golden god role, it doesnt work aand gives no errors

Upvotes: 0

Views: 80

Answers (1)

RiveN
RiveN

Reputation: 2663

I tested your code and it's probably happening because you didn't enable Privileged Gateway intents and your bot can't get all members. Enable Server Members Intent on the Discord Developer site in the Bot section.

discord site screenshot

Then, add them to your code. Example:

intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix="!", intents=intents)

Upvotes: 0

Related Questions