Home > Net >  How to make a send command
How to make a send command

Time:07-03

I am making a discord bot and adding economy to it. I alredy made a wallet and balance system using SQLite. I want to make a send command, but when i do .send it gives me an error:

    if amount / 100 * 1   amount > Result_userBal:
TypeError: unsupported operand type(s) for /: 'str' and 'int'

My code is:

 @client.command(aliases=["pay", "s", "send" ])
async def Send(ctx, member: discord.Member, amount=None):
  db.commit()
  cursor = db.cursor()
  USERID = ctx.message.author.id
  USER_NAME = str(ctx.message.author)
  START_BAL = 0
  amt = amount
  TARGETID = discord.member
  cursor.execute (f"SELECT WalletID from Wallets WHERE WalletID={USERID}")
  result_userID = cursor.fetchone()
  cursor.execute(f"SELECT WalletBal from Wallets WHERE WalletID={USERID}") 
  Result_userBal = cursor.fetchone()
  

Note: I did not put it in here, but here i have a system to check if the account has a wallet, and if the amount is enough.

  else:
   cursor.execute(f"SELECT WalletID from Wallets WHERE WalletID= {USERID}") 
    
   cursor.execute(f"UPDATE Wallets SET WalletBal = WalletBal - {amt}")
   cursor.execute(f"UPDATE Wallets SET WalletBal = WalletBal - {amt/100}")
   db.commit()
   cursor.execute(f"SELECT WalletID from Wallets WHERE WalletID= {TARGETID}")
    
   cursor.execute(f"UPDATE Wallets SET WalletBal = WalletBal   {amt}")
   db.commit()
    
   await ctx.send ("The Transaction was succesfull!")

I am detracting 101% of the transaction amount to serve as a commision.

CodePudding user response:

It feels like most of the code you've provided is not relevant to the issue - all the error means is that the variable 'amount' is currently a string and thus, cannot be divided by 100 (an integer). Try putting the line

amount = int(amount)

just before your if statement to see if that helps. (I would've put this in a comment but I don't have the reputation yet)

  • Related