here's the code
import discord
from discord.ext import commands
from random import randrange
import aiosqlite
import asyncio
import time
async def checkBal(self, ctx, user : discord.Member):
db = await aiosqlite.connect('ArchDornanDatabase.db')
cursor = await db.cursor()
await cursor.execute(f"SELECT * FROM MainTable WHERE UserID = {user.id}, GuildID = {ctx.guild.id}")
result = await cursor.fetchone()
if result:
return
if not result:
await cursor.execute(f"INSERT INTO MainTable(GuildID, UserID, Wallet, Warns), VALUES(?,?,?,?)", (ctx.guild.id, user.Id, 0, 0))
await db.commit()
await cursor.close()
await db.close()
class Bal(commands.Cog):
@commands.command
async def bal(self, ctx, user : discord.Member=None):
if user is None:
user = ctx.author
await checkBal(self=self, ctx=ctx, user=user)
db = await aiosqlite.connect('ArchDornanDatabase.db')
cursor = await db.cursor()
await cursor.execute(f"SELECT * FROM MainTable WHERE UserID = {ctx.author.id}, GuildID = {ctx.guild.id}")
embed=discord.Embed(title="**Wallet Balance**", description=f"{user} has {result[2]} coins in their wallet!", color=0xffffff)
await ctx.send(embed=embed)
def setup(bot):
bot.add_cog(Bal(bot))
print('Bal is loaded')