From 5f72df637ab81d2efdae8e7271ea6b0e090c543d Mon Sep 17 00:00:00 2001
From: Milipi <robin.artus@ensiie.fr>
Date: Thu, 8 Apr 2021 00:31:11 +0200
Subject: [PATCH] Ajout mention et suppression message utilisateur

---
 bot.py         |  28 ++++++++++++++++++++--------
 characters.pkl | Bin 3963 -> 4205 bytes
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/bot.py b/bot.py
index ed3c6ca..df73091 100644
--- a/bot.py
+++ b/bot.py
@@ -240,27 +240,37 @@ bot = commands.Bot(command_prefix=':')
 async def on_ready():
     print(f'{bot.user.name} has connected to Discord!')
 
-@bot.command(name='roll', help='Roll dices. 2args : number of dices and number of sides')
+@bot.command(name='roll', help='Roll dices. 2args : number of dice and number of sides')
 async def roll(ctx, number_of_dice: int, number_of_sides: int):
+    mention=ctx.message.author.mention
+    await ctx.message.delete()
     dice = [
         str(random.choice(range(1, number_of_sides + 1)))
         for _ in range(number_of_dice)
     ]
-    await ctx.send(', '.join(dice))
+    await ctx.send('{} {} {} '.format(number_of_dice,number_of_sides,dice[0]))
+    if (number_of_dice==1 and (dice[0]==1 or dice[0]==number_of_sides)):
+        await ctx.send("{1}\n*Critique !*\nRolling d{2} : {0}".format(dice[0]),mention,number_of_sides)
+    else:
+        await ctx.send('{} Rolling {}d{} : '.format(mention,number_of_dice,number_of_sides) + ', '.join(dice))
 
 @bot.command(name='getmychars', help='Affiche la liste des personnages du joueur')
 async def getmychars(ctx):
     try:
+        mention=ctx.message.author.mention
+        await ctx.message.delete()
         author = '{}'.format(ctx.message.author)
         chars = getAllCharactersByOwner(author)
         chars = "\n-".join(char.name for char in chars)
-        await ctx.send("You possess the following characters :\n- {0}".format(chars))
+        await ctx.send("{1} You possess the following characters :\n- {0}".format(chars,mention))
     except Exception as e:
         await ctx.send('Exception : {}'.format(e))
 
 @bot.command(name='getchar', help='Affiche les détails du personnage indiqué')
 async def getchar(ctx, name = None):
+    mention=ctx.message.author.mention
     author = '{}'.format(ctx.message.author)
+    await ctx.message.delete()
     try:
         if name is None:
             char= getMainCharactersByOwner(author)
@@ -426,7 +436,9 @@ async def delsys(ctx, name):
     
 @bot.command(name='r', help='Simulates rolling dice for a character attribute / competence')
 async def r(ctx, what, characterName = None):
+    mention=ctx.message.author.mention
     author = '{}'.format(ctx.message.author)
+    await ctx.message.delete()
     try:
         if characterName is None:
             char= getMainCharactersByOwner(author)
@@ -443,7 +455,7 @@ async def r(ctx, what, characterName = None):
                     attrbonus = char.getAttribute(comp.attribute)
                     maxdice = max(roll)
                     res = maxdice + dicebonus + attrbonus
-                    await ctx.send('Roll : {5}\nThe result for the {0} check is : {1} ({2} + {3} + {4})'.format(what, res,maxdice,dicebonus,attrbonus,roll))
+                    await ctx.send('{6} Roll : {5}\nThe result for the {0} check is : {1} ({2} + {3} + {4})'.format(what, res,maxdice,dicebonus,attrbonus,roll,mention))
                     return
                 else:
                     await ctx.send("Competences not implemented yet")
@@ -455,11 +467,11 @@ async def r(ctx, what, characterName = None):
                     custom = floor((int(attr.level)-10)/2)
                     res =  randompart - custom
                     if randompart==1:
-                        await ctx.send('*Réussite critique !*\nThe result for the {0} check is : {1} ({2} - {3})'.format(what, res,randompart,custom))
+                        await ctx.send('{4}\n*Réussite critique !*\nThe result for the {0} check is : {1} ({2} - {3})'.format(what, res,randompart,custom,mention))
                     elif randompart==20:
-                        await ctx.send('*Échec critique !*\nThe result for the {0} check is : {1} ({2} - {3})'.format(what, res,randompart,custom))
+                        await ctx.send('{4}\n*Échec critique !*\nThe result for the {0} check is : {1} ({2} - {3})'.format(what, res,randompart,custom,mention))
                     else:
-                        await ctx.send('The result for the {0} check is : {1} ({2} - {3})'.format(what, res,randompart,custom))
+                        await ctx.send('{4} The result for the {0} check is : {1} ({2} - {3})'.format(what, res,randompart,custom,mention))
                     return
                 elif char.system=="LN":
                     roll = []
@@ -469,7 +481,7 @@ async def r(ctx, what, characterName = None):
                     dicebonus = attr.level - len(noduplicates)
                     maxdice = max(roll)
                     res = maxdice + dicebonus + attr.level
-                    await ctx.send('Roll : {5}\nThe result for the {0} check is : {1} ({2} + {3} + {4})'.format(what, res,maxdice,dicebonus,attr.level,roll))
+                    await ctx.send('{6} Roll : {5}\nThe result for the {0} check is : {1} ({2} + {3} + {4})'.format(what, res,maxdice,dicebonus,attr.level,roll,mention))
                     return
                 else:
                     await ctx.send('Character system {} not supported yet'.format(char.system))
diff --git a/characters.pkl b/characters.pkl
index de0e8434de88dab154f892c28823646b49e879e7..84f97f4d4463349240a3400af5e39a172cccb8ee 100644
GIT binary patch
delta 130
zcmew@_f~<mfn{ovz(!UMCP^VL^~92r#KO{4F8?A0D+NO%%PBof6$Mi!zhjlzY{|5a
znYA;+IwN%QM<%(=Tx|KAlRvRaOqORgns`&5k!Nxuv*ct?cIk=pMJ6v{6H#UHOi3)7
il3~%q;~wu^lwVw|Y;0s=I3>fj17t>qRYz%3svZEZxGEq3

delta 42
ycmaE>@LP_xfn{m||3+30CN54d^~92r#KO|l%?eBxm?yKcDsL8M%jaZD)dK(@@C-fx

-- 
GitLab