#π how to get the bot to auto give coins when winning and lose coins when losing? pls help
32 messages Β· Page 1 of 1 (latest)
@untold spoke
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
pls
@untold spoke is this related to python?
yes
Python
but
making a bot
so
Are you making a bot? We need more details
but
ye
im making a bot
out of python language
Share your code and try to explain the issue again
okay
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
@bot.command(aliases=["slotpvp"])
async def slots_pvp(ctx, player2: discord.Member, bet: int):
if player2 == ctx.author:
return await ctx.send("β You canβt play against yourself!")
await ensure_user_exists(ctx.author.id)
await ensure_user_exists(player2.id)
if bet <= 0:
return await ctx.send("β Invalid bet!")
bal1 = await get_balance(ctx.author.id)
bal2 = await get_balance(player2.id)
if bal1 < bet or bal2 < bet:
return await ctx.send("β One of you doesnβt have enough CatCoins!")
emojis = ["π", "π", "π", "π", "π", "β"]
await ctx.send(f"π° **{ctx.author.display_name}** vs **{player2.display_name}** β spinning for {bet} CatCoins each...")
await asyncio.sleep(2)
def roll():
result = [random.choice(emojis) for _ in range(3)]
score = sum(emojis.index(e) + 1 for e in result)
return result, score
r1, s1 = roll()
r2, s2 = roll()
msg = (
f"π° {ctx.author.display_name}: {' | '.join(r1)} = {s1}\n"
f"π° {player2.display_name}: {' | '.join(r2)} = {s2}\n\n"
)
if s1 > s2:
await update_balance(ctx.author.id, bet)
await update_balance(player2.id, -bet)
msg += f"π **{ctx.author.display_name}** wins **{bet} CatCoins!**"
elif s2 > s1:
await update_balance(ctx.author.id, -bet)
await update_balance(player2.id, bet)
msg += f"π **{player2.display_name}** wins **{bet} CatCoins!**"
else:
msg += "πΌ Tie! No CatCoins lost."
await ctx.send(msg)
Hey @untold spoke!
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
@bot.command(aliases=["slotpvp"])
async def slots_pvp(ctx, player2: discord.Member, bet: int):
if player2 == ctx.author:
return await ctx.send("β You canβt play against yourself!")
await ensure_user_exists(ctx.author.id)
await ensure_user_exists(player2.id)
if bet <= 0:
return await ctx.send("β Invalid bet!")
bal1 = await get_balance(ctx.author.id)
bal2 = await get_balance(player2.id)
if bal1 < bet or bal2 < bet:
return await ctx.send("β One of you doesnβt have enough CatCoins!")
emojis = ["π", "π", "π", "π", "π", "β"]
await ctx.send(f"π° **{ctx.author.display_name}** vs **{player2.display_name}** β spinning for {bet} CatCoins each...")
await asyncio.sleep(2)
def roll():
result = [random.choice(emojis) for _ in range(3)]
score = sum(emojis.index(e) + 1 for e in result)
return result, score
r1, s1 = roll()
r2, s2 = roll()
msg = (
f"π° {ctx.author.display_name}: {' | '.join(r1)} = {s1}\n"
f"π° {player2.display_name}: {' | '.join(r2)} = {s2}\n\n"
)
if s1 > s2:
await update_balance(ctx.author.id, bet)
await update_balance(player2.id, -bet)
msg += f"π **{ctx.author.display_name}** wins **{bet} CatCoins!**"
elif s2 > s1:
await update_balance(ctx.author.id, -bet)
await update_balance(player2.id, bet)
msg += f"π **{player2.display_name}** wins **{bet} CatCoins!**"
else:
msg += "πΌ Tie! No CatCoins lost."
await ctx.send(msg)
like this
@viscid sentinel
idk how to add money when wiining
e
Why should we invest time here and fix some code for you, that is 100% AI-generated, where you didn't invest any personal effort, and where everything code-wise is so far out of your understanding that even if we did invest multiple hours, you probably wouldn't take anything away from it?
We're not your "Fix broken ChatGPT code" utility.
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.