Answer the question
In order to leave comments, you need to log in
How to tag a member with a specific role?
It is required that after the conditional command !command, the bot selects a member with a specific role (for example, Role1).
import discord
from discord.ext import commands
from config import settings
bot = commands.Bot(command_prefix = settings['prefix'], intents = discord.Intents.all())
@bot.command()
async def day(ctx):
await ctx.send(choice(ctx.guild.members).mention)
bot.run(settings['token'])
Answer the question
In order to leave comments, you need to log in
import random
...
@bot.command()
async def cmdname(ctx, *, role: discord.Role):
"""Choose random user from specified role"""
m = random.choice(role.members)
await ctx.send(m.mention)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question