mirror of
				https://gitlab.com/ddorn/tfjm-discord-bot.git
				synced 2025-11-04 08:22:12 +01:00 
			
		
		
		
	🐛 + ✨ fix TimeoutError and hug more people
This commit is contained in:
		@@ -20,6 +20,9 @@ from discord.ext.commands import (
 | 
				
			|||||||
    CommandError,
 | 
					    CommandError,
 | 
				
			||||||
    Group,
 | 
					    Group,
 | 
				
			||||||
    group,
 | 
					    group,
 | 
				
			||||||
 | 
					    MemberConverter,
 | 
				
			||||||
 | 
					    BadArgument,
 | 
				
			||||||
 | 
					    RoleConverter,
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from src.constants import *
 | 
					from src.constants import *
 | 
				
			||||||
@@ -110,9 +113,21 @@ class MiscCog(Cog, name="Divers"):
 | 
				
			|||||||
        await ctx.send("Tu t'es raté ! Kwaaack :duck:")
 | 
					        await ctx.send("Tu t'es raté ! Kwaaack :duck:")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @command()
 | 
					    @command()
 | 
				
			||||||
    async def hug(self, ctx, who: discord.Member):
 | 
					    async def hug(self, ctx, who):
 | 
				
			||||||
        """Fait un câlin à quelqu'un."""
 | 
					        """Fait un câlin à quelqu'un."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if who != "everyone":
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
 | 
					                who = await RoleConverter().convert(ctx, who)
 | 
				
			||||||
 | 
					            except BadArgument:
 | 
				
			||||||
 | 
					                try:
 | 
				
			||||||
 | 
					                    who = await MemberConverter().convert(ctx, who)
 | 
				
			||||||
 | 
					                except BadArgument:
 | 
				
			||||||
 | 
					                    return await ctx.send(
 | 
				
			||||||
 | 
					                        f'Je ne connais pas "{who}", verifie l\'orthographe '
 | 
				
			||||||
 | 
					                        f"et n'oublie pas les guillemets si il y a des espaces dans son nom. :wink:"
 | 
				
			||||||
 | 
					                    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bonuses = [
 | 
					        bonuses = [
 | 
				
			||||||
            "C'est trop meuuuugnon !",
 | 
					            "C'est trop meuuuugnon !",
 | 
				
			||||||
            "Ça remonte le moral ! :D",
 | 
					            "Ça remonte le moral ! :D",
 | 
				
			||||||
@@ -128,11 +143,20 @@ class MiscCog(Cog, name="Divers"):
 | 
				
			|||||||
                "Mais il a les bras trop courts ! :cactus:",
 | 
					                "Mais il a les bras trop courts ! :cactus:",
 | 
				
			||||||
                "Il en faut peu pour être heureux :wink:",
 | 
					                "Il en faut peu pour être heureux :wink:",
 | 
				
			||||||
            ]
 | 
					            ]
 | 
				
			||||||
 | 
					        elif who == "everyone" or who == ctx.guild.default_role:
 | 
				
			||||||
 | 
					            msg = f"{ctx.author.mention} fait un câlin a touuuut le monde !"
 | 
				
			||||||
 | 
					            bonuses += [
 | 
				
			||||||
 | 
					                "Ça fait beaucoup de gens pour un câlin !",
 | 
				
			||||||
 | 
					                "Plus on est, plus on est calins !",
 | 
				
			||||||
 | 
					                "C'est pas très COVID-19 tout ça !",
 | 
				
			||||||
 | 
					                "Tout le monde est heureux maintenant !",
 | 
				
			||||||
 | 
					            ]
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            msg = f"{ctx.author.mention} fait un gros câlin à {who.mention} !"
 | 
					            msg = f"{ctx.author.mention} fait un gros câlin à {who.mention} !"
 | 
				
			||||||
            bonuses += [
 | 
					            bonuses += [
 | 
				
			||||||
                f"Mais {who.display_name} n'apprécie pas...",
 | 
					                f"Mais {who.mention} n'apprécie pas...",
 | 
				
			||||||
                "Et ils s'en vont chasser des canards ensemble :wink:",
 | 
					                "Et ils s'en vont chasser des canards ensemble :wink:",
 | 
				
			||||||
 | 
					                "Oh ! Il sent bon...",
 | 
				
			||||||
            ]
 | 
					            ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bonus = random.choice(bonuses)
 | 
					        bonus = random.choice(bonuses)
 | 
				
			||||||
@@ -211,9 +235,13 @@ class MiscCog(Cog, name="Divers"):
 | 
				
			|||||||
        start = time()
 | 
					        start = time()
 | 
				
			||||||
        end = start + 24 * 60 * 60
 | 
					        end = start + 24 * 60 * 60
 | 
				
			||||||
        while time() < end:
 | 
					        while time() < end:
 | 
				
			||||||
            reaction, user = await self.bot.wait_for(
 | 
					
 | 
				
			||||||
                "reaction_add", check=check, timeout=end - time()
 | 
					            try:
 | 
				
			||||||
            )
 | 
					                reaction, user = await self.bot.wait_for(
 | 
				
			||||||
 | 
					                    "reaction_add", check=check, timeout=end - time()
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
 | 
					            except TimeoutError:
 | 
				
			||||||
 | 
					                return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if user.id == BOT:
 | 
					            if user.id == BOT:
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user