'Python mention random users from role
How can I mention multiple random users from a role member
by using a command in a discord channel.
@bot.command(pass_context=True)
async def mention(ctx):
# ''
await bot.say
Solution 1:[1]
this should work fine but it does not ping multiple members it chooses a random one from a list
@client.command()
async def mention(ctx):
role = discord.utils.get(ctx.guild.roles, name='role_name')
members = [member for member in ctx.guild.members if role in member.roles]
member = random.choice(members)
await ctx.send(f'{member.mention}')```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |