0
import discord
import random
from discord.ext import commands

client = commands.Bot(command_prefix=".")
@client.command()
async def qs(ctx):
    m = ["a",
         "d",
         "f",
         "g"]
    await ctx.author.send(f'{random.choice(m)')

client.run('TOKEN')

Hi everyone, I have a list and every time someone uses the command, the bot send a random item of that list, but once that item is sent the item has to be deleted from the list.

  • 3
    Does this answer your question? [What is the most pythonic way to pop a random element from a list?](https://stackoverflow.com/questions/10048069/what-is-the-most-pythonic-way-to-pop-a-random-element-from-a-list) – Vishal Singh Jul 16 '20 at 22:19

1 Answers1

0
random.shuffle(m)
await ctx.author.send(f'{m.pop()}')
Vishal Singh
  • 6,014
  • 2
  • 17
  • 33