-1

I have a command that I made to choose a random member for the server, but for some reason, whenever I run it, it only mentions itself.. As if it cannot detect that there are other members in the server besides itself. Here is the code: ok


client = commands.Bot(command_prefix=['%', "v", "V"],
                      case_insensitive=True,
                      help_command=None)


intents = discord.Intents().all()
intents = True

@client.event
async def on_ready():
    print('Bot is Online! ;)')

    servers = len(client.guilds)
    members = 0
    for guild in client.guilds:
        members += guild.member_count - 1

    await client.change_presence(activity=discord.Activity(
        type=discord.ActivityType.watching,
        name=f'{servers} servers and {members} members | %help'))

@client.command()
async def choosemem(ctx):
    guild = ctx.guild
    await ctx.send(f"{random.choice(guild.members).mention} has been chosen")

This Is the full code, including the status, and the intents.

1 Answers1

0

You need to add the intents value in client= commands.Bot as well

intents = discord.Intents().all()


client = commands.Bot(command_prefix=['%', "v", "V"],
                      case_insensitive=True,
                      help_command=None,
                      intents = intents)
DARK _
  • 1
  • 1
  • Yes, I did that. It is still returning the bot itself. Edit: I went back to the dev portal and enabled all intents. Now it works, thanks. How can I mark this question as answered? – Sarvesh Jagtap Jun 20 '21 at 20:15