A
A
Andrey Volchara2020-10-08 21:44:18
Python
Andrey Volchara, 2020-10-08 21:44:18

How to tag a random user?

It is necessary that the bot respond to the !who command with "I think it's him" and tag a random user.
I saw a similar question on Habré with the solution below, but in this case the bot only tags itself.

from random import choice

await ctx.send(choice(ctx.guild.members).mention)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nevzorov, 2020-10-09
@vollchara

The problem is most likely the missing intents of the members: https://discordpy.readthedocs.io/en/stable/intents...
Enable the required "intents" AMQHhW5.pngin the bot settings in the discord panel, and if you use discord.py>= 1.5.0, add an argument intentsto the constructor of the bot object, for example:

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

bot = commands.Bot(..., intents=intents)

31kHBbt.png
m1yTqFv.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question