fix mention in vote

This commit is contained in:
Mylloon 2021-05-08 02:22:22 +02:00
parent 316e95760b
commit c1131967b6

View file

@ -300,10 +300,11 @@ class Utils(commands.Cog):
else: else:
return f"{user.name}#{user.discriminator}" return f"{user.name}#{user.discriminator}"
def _cleanUser(self, ctx, stringMessage, stringID, option = 0): def _cleanUser(self, ctx, stringMessage, stringID):
associatedId = self._userOrNick(ctx.author.guild.get_member(int(stringID))) stringMessage = stringMessage.replace("<@!", "").replace(">", "").replace("<@", "")
associatedID = self._userOrNick(ctx.author.guild.get_member(int(stringID)))
try: try:
stringMessage = stringMessage.replace(stringID, associatedId) stringMessage = stringMessage.replace(stringID, associatedID)
except: except:
pass pass
return stringMessage return stringMessage
@ -313,7 +314,7 @@ class Utils(commands.Cog):
"""Fais un sondage.\n ➡ Syntaxe: .sondage "<Question>" "<Proposition1>" "<Proposition...>" "<Proposition20>" """ """Fais un sondage.\n ➡ Syntaxe: .sondage "<Question>" "<Proposition1>" "<Proposition...>" "<Proposition20>" """
args = list(args) args = list(args)
if len(args) > 2: if len(args) > 2:
question = args[0].replace("<@!", "").replace(">", "").replace("<@", "") question = args[0]
for i in re.findall(r'\d+', question): for i in re.findall(r'\d+', question):
question = self._cleanUser(ctx, question, i) question = self._cleanUser(ctx, question, i)
propositions = args[1:] propositions = args[1:]
@ -351,7 +352,7 @@ class Utils(commands.Cog):
@commands.command(name='avis', aliases=['vote']) @commands.command(name='avis', aliases=['vote'])
async def _avis(self, ctx, *args): async def _avis(self, ctx, *args):
"""Demande un avis.\n ➡ Syntaxe: .avis "[Titre]" "<Demande>" """ """Demande un avis.\n ➡ Syntaxe: .avis/vote "[Titre]" "<Demande>" """
args = list(args) args = list(args)
if len(args) > 2 or len(args) == 0: if len(args) > 2 or len(args) == 0:
return await ctx.send("Désolé, la syntaxe est mauvaise.") return await ctx.send("Désolé, la syntaxe est mauvaise.")
@ -359,11 +360,14 @@ class Utils(commands.Cog):
if len(args) == 1: if len(args) == 1:
titre = "Nouveau vote" titre = "Nouveau vote"
else: else:
titre = args[0].replace("<@!", "").replace(">", "").replace("<@", "") titre = args[0]
for findedId in re.findall(r'\d+', titre): for findedId in re.findall(r'\d+', titre):
titre = self._cleanUser(ctx, titre, findedId) titre = self._cleanUser(ctx, titre, findedId)
args = args[1:] args = args[1:]
embed = discord.Embed(title = titre, description = f"```{args[0]}```", color = discord.Colour.random()).set_footer(text = self._userOrNick(ctx.author), icon_url = ctx.author.avatar_url) demande = args[0]
for findedMention in re.findall(r'<@[!]?\d*>', demande):
demande = demande.replace(findedMention, f"`{findedMention}`")
embed = discord.Embed(title = titre, description = f"`{demande}`", color = discord.Colour.random()).set_footer(text = self._userOrNick(ctx.author), icon_url = ctx.author.avatar_url)
message = await ctx.send(embed = embed) message = await ctx.send(embed = embed)
reactions = ['', '🤷', ''] reactions = ['', '🤷', '']
for i in reactions: for i in reactions: