Beispiel #1
0
    async def cmd_mithrollversus(self, *args, message, content, member, channel, guild, **_):
        match = CMD_VERSUS_REGEX.match(content)
        if not match:
            raise InvalidArgs(f"The command content must match regular the regular expression\n``{CMD_VERSUS_REGEX.pattern}``")
        d = {k:v for k, v in match.groupdict().items() if v is not None}
        comp_atk = d['comp_atk']
        atk_bonus = int(d.get('atk_bonus_sign', '+') + d.get('atk_bonus', '0'))
        comp_def = d.get('comp_def', comp_atk)
        def_bonus = int(d.get('def_bonus_sign', '+') + d.get('def_bonus', '0'))
        defenser = get_member(guild, d['def'])
        attacker = d.get('roller', None)
        attacker = member if attacker is None else get_member(guild, attacker)
        try:
            wsh1 = gc.open_by_key(CHAR_SHEET[str(attacker.id)]).sheet1
            wsh2 = gc.open_by_key(CHAR_SHEET[str(defenser.id)]).sheet1
        except:
            raise BotError("Impossible d'ouvrir la fiche de personnage du membre")
        datk = await roll_by_comp(parse_competences(wsh1), comp_atk.strip().lower(), atk_bonus)
        ddef = await roll_by_comp(parse_competences(wsh2), comp_def.strip().lower(), def_bonus)

        em = discord.Embed(
            title="Lancé de dés",
            description=f"{attacker.mention} **vs** {defenser.mention}",
            colour=attacker.colour
        ).set_footer(text=message.content).set_author(name=attacker.name, icon_url=attacker.avatar_url)
        em.add_field(name="Attaque", value=COMPROLL_DESC.format(**datk, member=attacker), inline=True)
        em.add_field(name="Défense", value=COMPROLL_DESC.format(**ddef, member=defenser), inline=True)
        em.add_field(name="Résultat", value=f"```diff\n{datk['verdict']}```**VS**```diff\n{ddef['verdict']}```", inline=False)
        if datk['verdict'] == "- Echec Critique":
            em.set_image(url=random_choice(FAIL_GIF))
        elif datk['verdict'] == "+ Réussite Critique":
            em.set_image(url=random_choice(SUCCES_GIF))
        await channel.send(embed=em)
Beispiel #2
0
 async def cmd_memberinfo(self, *args, member, channel, guild, **_):
     if args:
         member = get_member(guild, ' '.join(args))
         if not member:
             raise NotFound("Membre non trouvé :(")
     em = discord.Embed(title=member.display_name, colour=member.colour)
     em.add_field(name="Nom", value=member.name)
     em.add_field(name="Discriminator", value="#" + member.discriminator)
     em.add_field(name="ID", value=str(member.id))
     if member.id in [384274248799223818, 427867039135432714, 244453201036836864, 221290866717884417]:
         em.add_field(name="Type", value="Dragon")
     else:
         em.add_field(name="Type", value="Robot" if member.bot else "Humain")
     em.add_field(name="Status", value=str(member.status))
     em.add_field(name="Couleur", value=str(member.colour))
     em.add_field(name="Jeu", value=(lambda x: str(x) if x else "Aucun")(member.activity))
     if len(member.roles) > 1:
         em.add_field(name="Roles", value=', '.join([f"<@&{i.id}>" for i in reversed(member.roles) if i.id != guild.id]))
     else:
         em.add_field(name="Roles", value='Aucun')
     em.add_field(name="Serveur rejoint", value=format_time(member.joined_at), inline=False)
     em.add_field(name="Compte créé", value=format_time(member.created_at))
     # p = await member.profile()
     # badge = {"Staff": p.staff, "Partenaire": p.partner, "Bug Hunter": p.bug_hunter,
     #          "Nitro": p.nitro, "Early Supporter": p.early_supporter, "Hypesquad": p.hypesquad,
     #          "House of Brillance": p.hypesquad_houses.brilliance, "House of Balance": p.hypesquad_houses.brilliance,
     #          "House of Bravery": p.hypesquad_houses.bravery}
     # user_badge = [k for k, v in badge.items() if v]
     # if user_badge:
     #     em.add_field(name="Badges", value=format_time(member.created_at), inline=False)
     em.set_image(url=member.avatar_url)
     await channel.send(embed=em)
Beispiel #3
0
    async def cmd_mithroll(self, *args, message, channel, member, guild, content, **_):
        if '#' in content:
            content, target_query = content.split('#', 1)
            target = get_member(guild, target_query.strip())
        else:
            target = member
        if not args:
            raise InvalidArgs("Usage: /mithroll {comp_name} [+/-][nombre]")
        try:
            wsh = gc.open_by_key(CHAR_SHEET[str(target.id)]).sheet1
        except:
            raise BotError("Impossible d'ouvrir la fiche de personnage du membre")
        comp = parse_competences(wsh)
        re_result = re.search(r".*([+-])\s*(\d+)\s*$", content)
        if re_result:
            sign_char = re_result.group(1)
            name = content.split(sign_char, 1)[0]
            bonus = int(sign_char + re_result.group(2))
        else:
            name, bonus = content, 0

        d = await roll_by_comp(comp, name.strip().lower(), bonus)
        em = discord.Embed(
            title="Lancé de dés",
            description=COMPROLL_DESC.format(**d, member=member),
            colour=target.colour
        ).set_footer(text=message.content).set_author(name=target.name, icon_url=target.avatar_url)
        em.add_field(name="Résultat", value=f"```diff\n{d['verdict']}```")
        if d['verdict'] == "- Echec Critique":
            em.set_image(url=random_choice(FAIL_GIF))
        elif d['verdict'] == "+ Réussite Critique":
            em.set_image(url=random_choice(SUCCES_GIF))
        await channel.send(embed=em)
Beispiel #4
0
 async def cmd_getstats(self, *args, member, channel, guild, **_):
     if not args:
         target = member
     else:
         name = ' '.join(args)
         target = get_member(guild, name)
         if not target:
             raise NotFound(f"Member named \"{name}\" not found")
     pl = db.get_stat_for(target.id)
     await channel.send(str(pl))
Beispiel #5
0
 async def cmd_getstats(self, *args, member, channel, guild, force, **_):
     if not isinstance(channel, nextcord.DMChannel
                       ) and channel.id != 258920360907374593 and not force:
         raise Forbidden("Arrêtez de spam les mauvais chan")
     if not args:
         target = member
     else:
         name = ' '.join(args)
         target = get_member(guild, name)
         if not target:
             raise NotFound(f"Member named \"{name}\" not found")
     pl = db.get_stat_for(target.id)
     await channel.send(str(pl))
Beispiel #6
0
    async def cmd_ddraft(self, *args: str, channel, client, member, guild,
                         **_):
        """/ddraft {nb} {bans} {leader_per_draft} {pick_per_team} {ban_per_team} {timer}"""
        if not args:
            raise InvalidArgs("Command should take at least two parameter")
        if not args[1].isdigit():
            raise InvalidArgs(
                "2nd Argument must be a integer (exemple: ``/ddraft @iElden 8``)"
            )
        nb = int(args[1])
        drafts_lines = get_draft(nb, *args[2:4], client=client)
        draft = DynamicDraft(args, drafts_lines, member,
                             get_member(guild, args[0]))

        msg = await channel.send(embed=draft.to_embed())
        for i, _ in enumerate(draft.drafts):
            await msg.add_reaction(emoji.NB[i])

        while True:
            try:
                reaction, _ = await client.wait_for(
                    'reaction_add',
                    timeout=3,
                    check=lambda
                    reaction, user: user == draft.get_member_needed_for_action(
                    ) and reaction.message.id == msg.id)
            except asyncio.TimeoutError:
                if draft.timer > -5:
                    draft.update_timer(3)
                    asyncio.create_task(msg.edit(embed=draft.to_embed()))
                else:
                    draft.reset_timer()
                    draft.update(None)
                    await msg.edit(embed=draft.to_embed())
                continue
            try:
                n = emoji.NB.index(str(reaction))
            except:
                continue
            draft.reset_timer()
            rt = draft.update(n)
            await msg.edit(embed=draft.to_embed())
            if rt:
                break
Beispiel #7
0
    async def cmd_takedamage(self, *args : List[str], message, member, channel, guild, client, heal=False, **_):
        """
        Args:
            *args (str):
            member (discord.Member):
            channel (discord.Channel):
            guild (discord.Guild):
            client (discord.Client):
            **_:

        Returns:

        """
        if len(args) < 1:
            raise InvalidArgs("Usage: /takedamage [joueur] {domage}")
        if len(args) == 1:
            target = member
        else:
            membername = ' '.join(args[:-(len(args) - 1)])
            target = get_member(guild, membername) # type: discord.Member
            if not target:
                raise NotFound(f"Member named {membername} not found")
        expr = args[-1]
        roll_result = roll(expr)

        damage = roll_result.total
        if damage < 0:
            damage = 0

        elif heal:
            damage = -damage

        wsh = gc.open_by_key(CHAR_SHEET[str(target.id)]).sheet1
        cell_list = wsh.range('P3:P6')
        old_hp = int(cell_list[0].value)
        new_hp = old_hp - damage
        if new_hp > int(cell_list[1].value):
            new_hp = int(cell_list[1].value)
        if old_hp > 0 and new_hp < 0:
            new_hp = 0
        knock = cell_list[2].value == 'TRUE'
        injury = cell_list[3].value == 'TRUE'

        em = discord.Embed(colour=target.colour)
        if roll_result.dices:
            em.add_field(name="Lancé de dé", value=f"{member.mention} {roll_result.intro_sentence}\n{roll_result.format_results}")
        if damage > 0:
            em.add_field(name="Resultat", value=f"{target.mention} a pris **{damage}** point{'s' if damage > 1 else ''} de dégats.\n"
                         f"Il lui reste **{new_hp}** / {cell_list[1].value}", inline=False)
        else:
                em.add_field(name="Resultat", value=f"{target.mention} a gagné **{-damage}** point{'s' if damage > 1 else ''} de vie.\n"
                f"Il lui reste **{new_hp}** / {cell_list[1].value}", inline=False)
        em.set_author(name=target.name, icon_url=target.avatar_url)
        em.set_footer(text=message.content)
        msg = await channel.send(embed=em)

        img = await create_image(target.avatar_url_as(format="png", size=1024), new_hp, int(cell_list[1].value), injury, knock)

        trash_msg = await client.get_channel(POUBELLE_ID).send(file=discord.File(fp=img, filename="a.png")) #type: discord.Message
        em.set_image(url=trash_msg.attachments[0].url)
        await msg.edit(embed=em)

        cell_list[0].value = new_hp
        wsh.update_cell(3, 12, new_hp)