I need to write the name of a random user on the server to a variable.
this is about how I present this code:
import discord
from discord.ext import commands
import random
@client.command()
async def hi(ctx):
user = discord.utils.get(ctx.guild.members, name = random)
await ctx.send(user + ' hi!')
You can get a list of all members with ctx.guild.members
and then pick a random element of the list with random.choice(list)
:
import discord
from discord.ext import commands
import random
@client.command()
async def hi(ctx):
user = random.choice(ctx.guild.members)
await ctx.send(user + ' hi!')