Page d'aide du casino

This commit is contained in:
attilavs2 2025-05-09 16:33:19 +02:00
parent 3d52bb4b94
commit 0d2d1fe52a

View file

@ -49,7 +49,7 @@ async def roll(message):
roll += str(random.randint(1,d)) + " "
else:
roll += str(random.randint(1,int(spec[0])))
await message.channel.send(roll)
await message.reply(roll)
async def pinguncon(message):
#fcalva's server
@ -60,13 +60,13 @@ async def pinguncon(message):
elif message.guild.id == 1294017120631525416:
await message.channel.send("<@504751919760408617>")
else:
await message.channel.send("Pas dispo ici")
await message.reply("Pas dispo ici")
async def pingjuif(message):
if message.guild.id in [1008485562304450610, 1157767629738618941]:
await message.channel.send("<@459021187083927553>")
else:
message.channel.send("Pas dispo ici")
message.channel.reply("Pas dispo ici")
async def pingrand(message):
choice = random.choice(globals()["gmembers"][str(message.guild.id)])
@ -82,8 +82,7 @@ async def reload(message):
else:
cursor.execute(f"UPDATE roulette SET shots = {shots} WHERE gid = {gid}")
database.commit()
await message.channel.send("Revolver rechargé")
await message.reply("Revolver rechargé")
async def roulette(message):
cursor.execute(f"CREATE TABLE IF NOT EXISTS roulette (gid INT PRIMARY KEY, shots INT)")
@ -104,7 +103,7 @@ async def roulette(message):
await message.author.timeout(tdelt, reason="Vous avez perdu à la roulette...")
await message.channel.send(f"<@{uid}> s'est tiré une balle, et est dans un coma pendant 5 minutes")
except Exception as err:
await message.channel.send("Une erreur s'est produite : `" + str(err) + "`")
await message.reply("Une erreur s'est produite : `" + str(err) + "`")
nshots = random.randint(0,5)
cursor.execute(f"UPDATE roulette SET shots = {nshots} WHERE gid = {gid}")
database.commit()
@ -112,7 +111,7 @@ async def roulette(message):
shots -= 1
cursor.execute(f"UPDATE roulette SET shots = {shots} WHERE gid = {gid}")
database.commit()
await message.channel.send("Clic... il n'y avait pas de cartouche dans la chambre...")
await message.reply("Clic... il n'y avait pas de cartouche dans la chambre...")
async def casino_init(message):
usrid = int(message.author.id)
@ -123,7 +122,7 @@ async def casino_init(message):
database.commit()
await message.channel.send(f"Casino initialisé pour <@{usrid}>")
except:
await message.channel.send(f"Échec ! Réessayez plus tard")
await message.reply(f"Échec ! Réessayez plus tard")
init_global_str = "Essayer d'initialiser le casino du serveur avec ?init"
init_perso_str = "Essayez d'initialiser votre portemonnaie avec ?init"
@ -134,11 +133,11 @@ async def balance(message):
try:
cash = cursor.execute(f"SELECT cash FROM tab_{gid} WHERE id={usrid}").fetchone()
except:
await message.channel.send(init_global_str)
await message.reply(init_global_str)
if cash != None:
await message.channel.send(f"Vous avez {cash[0]}$")
await message.reply(f"Vous avez {cash[0]}$")
else:
await message.channel.send(init_perso_str)
await message.reply(init_perso_str)
async def collect(message):
collect_gain = 50
@ -150,11 +149,11 @@ async def collect(message):
try:
lst_coll = cursor.execute(f"SELECT lst_coll FROM tab_{gid} WHERE id={usrid}").fetchone()[0]
except:
await message.channel.send(init_perso_str)
await message.reply(init_perso_str)
return
if lst_coll >= curr_time - cooldown:
rtime = (-curr_time + cooldown + lst_coll)//60
await message.channel.send(f"Vous pourrez toucher votre RSA dans {rtime} minutes")
await message.reply(f"Vous pourrez toucher votre RSA dans {rtime} minutes")
return
cash = None
cash = cursor.execute(f"SELECT cash FROM tab_{gid} WHERE id={usrid}").fetchone()
@ -165,10 +164,10 @@ async def collect(message):
cursor.execute(f"UPDATE tab_{gid} SET cash = {cash} WHERE id={usrid}")
database.commit()
nc = cooldown//60
await message.channel.send(f"Vous avez recu {collect_gain}$ en RSA. Vous avez désormais {cash}$\n"\
await message.reply(f"Vous avez recu {collect_gain}$ en RSA. Vous avez désormais {cash}$\n"\
f"Revenez dans {nc} minutes pour votre prochain chèque")
else:
await message.channel.send(init_perso_str)
await message.reply(init_perso_str)
async def slot(message):
amnt = message.content.split(' ')[1]
@ -181,11 +180,11 @@ async def slot(message):
uid = int(message.author.id)
ret = cursor.execute(f"SELECT cash FROM tab_{gid} WHERE id={uid}").fetchone()
if ret == None:
await message.channel.send(init_perso_str)
await message.reply(init_perso_str)
return
cash = ret[0]
if amnt > cash:
await message.channel.send("Vous n'avez pas assez d'argent")
await message.reply("Vous n'avez pas assez d'argent")
return
roll = random.random()
gain = 0
@ -202,7 +201,7 @@ async def slot(message):
await message.channel.send(f"<@{uid}> a extrait {gain}$ des griffes de la machine")
if roll >= 19/20:
gain = int(round(amnt*4 + amnt*17*random.random()))
await message.channel.send(f"## <@{uid}> JACKPOT ! Vous avez gagné {gain}$ !")
await message.channel.send(f"# <@{uid}> JACKPOT ! Vous avez gagné {gain}$ !")
cash -= amnt-gain
cursor.execute(f"UPDATE tab_{gid} SET cash = {cash} WHERE id={uid}")
database.commit()
@ -220,7 +219,7 @@ async def leaderboard(message):
ucash = result[i][1]
msgstr += " "+str(i+1)+f". <@{uid}> - {ucash}$\n"
i += 1
await message.channel.send(msgstr, allowed_mentions=discord.AllowedMentions().none())
await message.reply(msgstr, allowed_mentions=discord.AllowedMentions().none())
async def transfer(message):
split = message.content.split(" ")
@ -230,33 +229,43 @@ async def transfer(message):
uid = int(message.author.id)
utili = cursor.execute(f"SELECT * FROM tab_{gid} WHERE id={uid}").fetchone()
if utili == None:
await message.channel.send(init_perso_str)
await message.reply(init_perso_str)
return
try:
tid = int(split[1].strip("<@").rstrip(">"))
except:
await message.channel.send("Destinataire invalide")
await message.reply("Destinataire invalide")
return
target = cursor.execute(f"SELECT * FROM tab_{gid} WHERE id={tid}").fetchone()
if target == None:
await message.channel.send("Destinataire non initialisé")
await message.reply("Destinataire non initialisé ou inexistant")
return
amnt = 0
try:
amnt = int(split[2])
except:
await message.channel.send("Quantité non valide")
await message.reply("Quantité non valide")
return
taxamnt = int(round(amnt*0.05))
if amnt + taxamnt > utili[1]:
await message.channel.send("Vous n'avez pas assez d'argent")
await message.reply("Vous n'avez pas assez d'argent")
return
ncashu = utili[1] - amnt - taxamnt
ncasht = target[1] + amnt
cursor.execute(f"UPDATE tab_{gid} SET cash={ncashu} WHERE id={uid}")
cursor.execute(f"UPDATE tab_{gid} SET cash={ncasht} WHERE id={tid}")
database.commit()
await message.channel.send(f"Transfert effectué. Une taxe de 5% ({taxamnt}) a été prélevée.")
await message.reply(f"Transfert effectué. Une taxe de 5% ({taxamnt}$) a été prélevée.")
async def casino_aide(message):
await message.channel.send("Commandes du casino Eco+\n"\
"?init : initialiser votre portefeuille\n"\
"?collect : Collectez votre revenu\n"\
"?cash : Consultez l'état de vos finances\n"\
"?lb : Consultez le top 5 des joueurs les plus riches\n"
"?transfer @dest <qtt> : Transférez <qtt> dollars à @dest\n"\
" (Une taxe de 5% est appliquée)\n"\
"?slot <qtt> : Jouez à la machine à sous avec une mise de <qtt>\n")
async def ecoaide(message):
await message.channel.send("Eco+, un bot Eco plus pour faire des conneries\n"\
@ -264,13 +273,16 @@ async def ecoaide(message):
"?pingunjuif : Ping le juif local\n"\
"?pingrand : Ping un membre aléatoire du serveur\n"\
"?roulette : Jouez à la roulette russe\n"\
"?reload : Réinitialisez la roulette russe\n")
"?reload : Réinitialisez la roulette russe\n"\
"?casino : Page d'aide du casino")
async def ecohelp(message):
await message.channel.send("Eco+ help page \n"\
"?pinguncon : Ping the local dumbass\n"\
"?pingrand : Ping a random user\n"\
"?roulette : Take one shot on six to get timed out")
"?roulette : Play russian roulette\n"\
"?reload : Reset the russian roulette\n"\
"?casino_en : English help page for the casino")
async def hello(message):
await message.channel.send('henlo')
@ -357,6 +369,7 @@ cmd_dict = {\
"?slot":slot,\
"?roll":roll,\
"?transfer":transfer,\
"?casino":casino_aide,\
}
@client.event
@ -371,14 +384,14 @@ async def on_message(message):
if content[0] != "?":
return
if not content in cmd_dict:
await message.channel.send("Commande non reconnue !")
await message.reply("Commande non reconnue !")
return
try:
await cmd_dict[content](message)
except Exception as err:
print(err)
await message.channel.send("Une erreur s'est produite : `" + str(err) + "`")
await message.reply("Une erreur s'est produite : `" + str(err) + "`")
def do_forgejo_thread():
forgejo.app.run(port=5000)