Skip to content
Advertisement

result1 sends what’s in it weird (picture below)

class EconomyCog(commands.Cog, name="Help"):

def __init__(self, bot):
    self.bot = bot

@commands.command()
async def Money(self, ctx):
    db = sqlite3.connect("main.sqlite")
    cursor = db.cursor()
    cursor.execute(f"SELECT money FROM main WHERE member_id = {ctx.message.author.id}")
    result = cursor.fetchone()
    if result is None:
        sql = ("INSERT INTO main(member_id, money) VALUES(?,?)")
        val = (ctx.message.author.id, 500)
        cursor.execute(sql, val)
        await ctx.send("Because you didn't have an account, I just made one for you!")
        db.commit()
    else:
        emoji = ":dollar:"
        cursor.execute(f"SELECT money FROM main WHERE member_id = {ctx.message.author.id}")
        result1 = cursor.fetchone()
        embed = discord.Embed(title = f"{ctx.message.author.name}'s Money", description=f"${result1} {emoji}", color = discord.Colour.random())
        await ctx.send(embed=embed)
        cursor.close()
        db.close()

Everything works fine, but now when the amount is sent it looks like this: enter image description here

when I try the {result1[1]}(where the money is at) the command doesn’t even work. What am I missing?

Advertisement

Answer

The tuple is of length 1, so you should be using {result1[0]} rather than {result1[1]}.

Advertisement