Send Random Item in MongoDb with Discord.Py

Viewed 14

Im attempting to make my bot send a random value of a specific field

#edit
@bot.command()
async def edit(ctx):
    edit = db.edit.aggregate({ 'edit': { 'edit': 1 } })
    await ctx.reply(edit)

https://i.stack.imgur.com/XdxGl.png

1 Answers

You need to provide a lot more information, but if it's anything like a list of values you could just separate it using the .split method and then using random.choice() to pick a random value.

I would also recommend you consider using some sort of relational database eg SQL as it will better serve your needs.

Related