Hi i'm having trouble with my function check_thunes()
it raises an error coroutine was never awaited
check_thunes()
is fonction to check if the player input right value and if not send a message to inform the player. I need to apply it to other game later. I made the fonction async to be able to send message.
this is my code :
import discord
import time
from random import randrange,choices
import os
from replit import db
from keep_alive import keep_alive
token = os.environ['token']
client = discord.Client()
@client.event
async def on_ready():
print("le bot est prêt")
@client.event
async def check_thunes(mise,joueur):
if joueur in db.keys(): #trouve la thune du joueur dans la db
thune=int(db[joueur])
else:
db[joueur]="1000"
thune=int(db[joueur])
reste=str(thune-mise)
db[joueur]=reste
if mise<=0:
await message.channel.send("Vous ne pouvez pas miser 0 crédit")
return erreur
if thune<=0:
await message.channel.send("Vous n'avez plus d'thune, mais voici un coup de pouce de 1k")
db[joueur]=str(1000)
return
if mise>thune:
await message.channel.send("Vous n'avez pas assez d'thune")
return
reste=str(thune-mise)
db[joueur]=reste
return reste,thune
@client.event
async def on_message(message):
msg=message.content
if msg.startswith("!roulette") :
#le message doir se présenter sous la forme
# !roulette nb(0,50) mise(1,thune)
gain=0
thune=0
reste=0
nombre=""
mise=""
joueur=str(message.author.name)
nb_g=int(randrange(51))
erreur=0
for i in range(10, 12): #trouve le nombre choisit
nombre+=msg[i]
nombre=int(nombre)
for i in range(12,len(msg)): #trouve la mise
mise+=msg[i]
mise=int(mise)
if joueur in db.keys(): #trouve la thune du joueur dans la db
thune=int(db[joueur])
else:
db[joueur]="1000"
thune=int(db[joueur])
reste=str(thune-mise)
db[joueur]=reste
#controleur des valeurs choisies
if nombre>50:
await message.channel.send("Le nombre choisit doit être entre 0 et 50")
return
check_thunes(mise, joueur)
#calcul des gains
if nombre==nb_g : #regza le premier gagnant du bot
gain=mise*2
elif (nombre%2==0 and nb_g%2==0) or (nombre%2==1 and nb_g%2==1 ) :
gain=round(mise*1.25)
else :
gain=0
if int(reste)+int(gain)>=0:
db[joueur]=str(int(reste)+int(gain))
elif int(reste)+int(gain)<0:
db[joueur]=str(0)
await message.channel.send("Vous n'avez plus d'thune")
return
if gain-mise>=0 :
await message.channel.send(str("Vous aviez choisit "+str(nombre)+" et la roulette a donnée "+str(nb_g)))
await message.channel.send(str("Vous avez gagné "+str(gain-mise)))
await message.channel.send(str("Il vous reste "+str(int(reste)+gain)))
return
else:
await message.channel.send(str("Vous aviez choisit "+str(nombre)+" et la roulette a donnée "+str(nb_g)))
await message.channel.send(str("Vous avez perdu "+str(-(gain-mise))))
await message.channel.send(str("Il vous reste "+str(int(reste)+gain)))
return
Can you help me