A
A
Aslan Berk2021-04-04 23:29:54
Python
Aslan Berk, 2021-04-04 23:29:54

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

1 answer(s)
M
Maxim Nevzorov, 2021-04-06
@fixator10

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 question

Ask a Question

731 491 924 answers to any question