ajout id de 17 chiffres et déplacement du test dans la méthode cleanUser
This commit is contained in:
parent
79d8141166
commit
b057da6627
2 changed files with 3 additions and 2 deletions
|
@ -365,8 +365,7 @@ class Utils(commands.Cog):
|
|||
if len(args) > 2:
|
||||
question = args[0]
|
||||
for i in findall(r'\d+', question):
|
||||
if len(str(i)) == 18: # id de 18 chiffres
|
||||
question = cleanUser(ctx, question, i)
|
||||
question = cleanUser(ctx, question, i)
|
||||
propositions = args[1:]
|
||||
if len(propositions) <= 20:
|
||||
message = ""
|
||||
|
|
|
@ -26,6 +26,8 @@ def userOrNick(user):
|
|||
def cleanUser(ctx, stringMessage, stringID):
|
||||
"""récupère l'utilisateur avec son id"""
|
||||
stringMessage = stringMessage.replace("<@!", "").replace(">", "").replace("<@", "") # améliorer ça avec du regex
|
||||
if len(str(stringMessage)) not in (17, 18): # si ce n'est pas un ID valide
|
||||
return stringMessage
|
||||
associatedID = userOrNick(ctx.author.guild.get_member(int(stringID)))
|
||||
try:
|
||||
stringMessage = stringMessage.replace(stringID, associatedID)
|
||||
|
|
Reference in a new issue