Pinging a random non-bot user in



import random
user = random.choice(message.guild.members)
await'Hello ' + user.mention)

My question is how do I ping a random, non-bot user in

Any help on this will be greatly appreciated, thanks!


You can check if a user is a bot with which returns a bool

Use a list comprehension to sort the members in the guild that are not bots(user accounts) and then use random.choice accordingly.

import random

humans = [m for m in message.guild.members if not]
random_member = random.choice(humans)

await"Hello {random_member.mention}")

Answered By – Yeti

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published