jeudi 5 novembre 2020

discory.py random send random string not working

I have the following code:

import string
import random

@client.command()
async def random(ctx):
    await ctx.send(''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(5)))

but for some reason it always puts out the error 'Command' object has no attribute 'choice'.

But when I just run

>>> import string
>>> import random
>>> ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(5))

in console it works perfectly fine and outputs the random strings I want. How can I fix this?




Aucun commentaire:

Enregistrer un commentaire