lundi 22 février 2021

How to store items for a single user discord.py

This is my first question so sorry if its a duplicate i did not know how to word it.

What i'm trying to do is lets say i have a >mine command it will generate random amount of coins from 100 to 500 and when i check >balance it shows that amount but I want it to be just for me so when someone else does >bal it will show only the amount they mined if that makes sense

here is the original code

from discord import *
from discord.ext import *
import random
from discord.ext import commands

bot = commands.Bot(command_prefix='>')
coinbalance = 0






@bot.command()
async def mine(ctx):
    coinsget = random.randint(100,500)
    coinstr = str(coinsget)


    global coinbalance
    await ctx.send(":pick: you went mining and collected "+coinstr+" coins!  :moneybag:")
    coinbalance = coinsget + coinbalance

@bot.command()
async def bal(ctx):
    balstr = str(coinbalance)



    await ctx.send("your balance = "+balstr)



bot.run('my token')

this was the original one I tried to use something with ctx.author but I could not come up with anything I could do.




Aucun commentaire:

Enregistrer un commentaire