Untitled
unknown
plain_text
6 months ago
1.7 kB
2
Indexable
# /BALANCE SLASH COMMAND --------------------------------------------------------------------------------------------- @nextcord.slash_command(description="Check a coin balance.") async def balance(self, interaction: nextcord.Interaction, member: nextcord.Member = None): await interaction.response.defer() # Defer the response user_id = member.id if member else interaction.user.id # Use provided member or the user who invoked the command conn = sqlite3.connect('currency.db') cursor = conn.cursor() cursor.execute("SELECT balance FROM currency WHERE user_id = ?", (user_id,)) result = cursor.fetchone() if result: balance = result[0] else: balance = 0 cursor.execute("INSERT INTO currency (user_id, balance) VALUES (?, ?)", (user_id, balance)) conn.commit() conn.close() if member: if balance == 0: embed = nextcord.Embed(title="", description=f"{member.mention} has a balance of **{balance}** 🪙.", color=nextcord.Color.red()) else: embed = nextcord.Embed(title="", description=f"{member.mention}'s balance is: **{balance:,}** 🪙.", color=nextcord.Color.gold()) else: if balance == 0: embed = nextcord.Embed(title="", description=f"Your balance is **{balance}** 🪙.", color=nextcord.Color.red()) else: embed = nextcord.Embed(title="", description=f"Your balance is **{balance:,}** 🪙.", color=nextcord.Color.gold()) await interaction.followup.send(embed=embed, ephemeral=True) # Use followup to send the message
Editor is loading...
Leave a Comment