ajout nouvelle méthode isSlash + fix bug chifumi
This commit is contained in:
parent
a46cb38b2d
commit
3cd0f482b8
1 changed files with 14 additions and 14 deletions
|
@ -3,6 +3,7 @@ import asyncio
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from random import randint, choice
|
from random import randint, choice
|
||||||
from discord_slash import cog_ext
|
from discord_slash import cog_ext
|
||||||
|
from utils.core import isSlash
|
||||||
|
|
||||||
def setup(client):
|
def setup(client):
|
||||||
client.add_cog(Games(client))
|
client.add_cog(Games(client))
|
||||||
|
@ -16,28 +17,27 @@ class Games(commands.Cog):
|
||||||
@commands.command(name='chifumi', aliases = ["shifumi", "ppc"])
|
@commands.command(name='chifumi', aliases = ["shifumi", "ppc"])
|
||||||
async def _chifumi(self, ctx, *choix):
|
async def _chifumi(self, ctx, *choix):
|
||||||
"""Un simple Chifumi contre le bot.\n ➡ Syntaxe: {PREFIX}chifumi/shifumi/ppc <pierre/papier/ciseaux>"""
|
"""Un simple Chifumi contre le bot.\n ➡ Syntaxe: {PREFIX}chifumi/shifumi/ppc <pierre/papier/ciseaux>"""
|
||||||
fromSlash = False
|
choix, fromSlash, _ = isSlash(choix)
|
||||||
if len(choix) < 1:
|
if choix == None:
|
||||||
raise ModuleNotFoundError
|
raise ModuleNotFoundError
|
||||||
if choix[-1] == True:
|
|
||||||
fromSlash = choix[-1]
|
|
||||||
choix = choix[0]
|
|
||||||
|
|
||||||
choix_jeu = ["Pierre ✊", "Papier 🧻", "Ciseaux ✂"]
|
choix_jeu = ["Pierre ✊", "Papier 🧻", "Ciseaux ✂"]
|
||||||
orditxt = choice(choix_jeu)
|
orditxt = choice(choix_jeu)
|
||||||
ordi = choix_jeu.index(orditxt)
|
ordi = choix_jeu.index(orditxt)
|
||||||
|
|
||||||
PIERRE = 0
|
pierre = 0
|
||||||
PAPIER = 1
|
papier = 1
|
||||||
CISEAUX = 2
|
ciseaux = 2
|
||||||
|
|
||||||
choix = choix.lower()
|
choix = choix.lower()
|
||||||
if choix == "pierre":
|
if choix == "pierre":
|
||||||
choix = PIERRE
|
choix = pierre
|
||||||
if choix == "papier" or choix == "feuille":
|
elif choix == "papier" or choix == "feuille":
|
||||||
choix = PAPIER
|
choix = papier
|
||||||
if choix == "ciseaux" or choix == "ciseau":
|
elif choix == "ciseaux" or choix == "ciseau":
|
||||||
choix = CISEAUX
|
choix = ciseaux
|
||||||
|
else:
|
||||||
|
return await ctx.send("Je n'ai pas compris ce que tu as joué, réessaie.")
|
||||||
|
|
||||||
description = (f"{choix_jeu[choix][:-1]} VS {choix_jeu[ordi][:-1]}\n\n**"
|
description = (f"{choix_jeu[choix][:-1]} VS {choix_jeu[ordi][:-1]}\n\n**"
|
||||||
f"{('Égalité !', 'Tu as perdu !', 'Tu as gagné !')[(choix != ordi) + ((choix > ordi and ordi +1 == choix) or (choix < ordi and choix + ordi == 2))]}**")
|
f"{('Égalité !', 'Tu as perdu !', 'Tu as gagné !')[(choix != ordi) + ((choix > ordi and ordi +1 == choix) or (choix < ordi and choix + ordi == 2))]}**")
|
||||||
|
@ -107,7 +107,7 @@ class Games(commands.Cog):
|
||||||
@commands.command(name='pileouface', aliases=['pf'])
|
@commands.command(name='pileouface', aliases=['pf'])
|
||||||
async def _pileouface(self, ctx, fromSlash = None):
|
async def _pileouface(self, ctx, fromSlash = None):
|
||||||
"""Pile ou face.\n ➡ Syntaxe: {PREFIX}pileouface/pf"""
|
"""Pile ou face.\n ➡ Syntaxe: {PREFIX}pileouface/pf"""
|
||||||
if fromSlash == None:
|
if fromSlash != True:
|
||||||
fromSlash = False
|
fromSlash = False
|
||||||
if fromSlash != True:
|
if fromSlash != True:
|
||||||
await ctx.message.add_reaction(emoji = '✅')
|
await ctx.message.add_reaction(emoji = '✅')
|
||||||
|
|
Reference in a new issue