GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Code Duplication    Length = 100-102 lines in 2 locations

axiol/plugins/moderation.py 2 locations

@@ 596-697 (lines=102) @@
593
                )
594
            )
595
596
    @commands.command(name="massrole")
597
    @has_command_permission()
598
    async def mass_role(
599
        self, ctx, role: discord.Role = None, role2: discord.Role = None
600
    ):
601
        if role is not None and role2 is not None:
602
            bot_msg = await ctx.send(
603
                embed=discord.Embed(
604
                    title="Confirmation",
605
                    description=(
606
                        f"Are you sure you want to update all members"
607
                        f" with the role {role.mention} with {role2.mention}?"
608
                    ),
609
                    color=var.C_BLUE
610
                ).add_field(
611
                    name=(
612
                        "Note that this action is irreversible "
613
                        "and cannot be stopped once started"
614
                    ),
615
                    value=(
616
                        f"{var.E_ACCEPT} to accept\n"
617
                        f"{var.E_ENABLE} to accept with live stats\n"
618
                        f"{var.E_DECLINE} to decline"
619
                    )
620
                )
621
            )
622
623
            await bot_msg.add_reaction(var.E_ACCEPT)
624
            await bot_msg.add_reaction(var.E_ENABLE)
625
            await bot_msg.add_reaction(var.E_DECLINE)
626
627
            def reaction_check(r, u):
628
                return u == ctx.author and r.message == bot_msg
629
630
            reaction, _ = await self.bot.wait_for(
631
                "reaction_add", check=reaction_check
632
            )
633
634
            updates = False
635
636
            try:
637
                await bot_msg.clear_reactions()
638
            except Exception:
639
                pass
640
641
            if str(reaction.emoji) == var.E_DECLINE:
642
                return await ctx.send("Cancelled mass role update")
643
644
            if str(reaction.emoji) == var.E_ENABLE:
645
                updates = True
646
647
            if (
648
                str(reaction.emoji) == var.E_ENABLE
649
                or str(reaction.emoji) == var.E_ACCEPT
650
            ):
651
652
                count = 0
653
654
                for member in [
655
                    member
656
                    for member in ctx.guild.members
657
                    if role in member.roles
658
                ]:
659
                    try:
660
                        await member.add_roles(role2)
661
                        count += 1
662
663
                        if updates:
664
                            await ctx.send(f"{member} updated")
665
666
                    except discord.Forbidden:
667
                        await ctx.send(
668
                            embed=discord.Embed(
669
                                description=(
670
                                    f"Error giving role to {member.mention}"
671
                                ),
672
                                color=var.C_ORANGE
673
                            )
674
                        )
675
676
                    await asyncio.sleep(1)
677
678
                await ctx.send(
679
                    f"Done, updated **{count}** members "
680
                    f"with the {role2.name} role"
681
                )
682
683
        else:
684
            await ctx.send(
685
                embed=discord.Embed(
686
                    title=f"🚫 Missing arguments",
687
                    description=(
688
                        "You need to define both Role 1 and Role 2\n`role1` "
689
                        "are the members having that role and `role2` is the"
690
                        " one to be given to them"
691
                    ),
692
                    color=var.C_RED
693
                ).add_field(
694
                    name="Format",
695
                    value=f"```{await get_prefix(ctx)}massrole <role1> <role2>```"
696
                ).set_footer(
697
                    text="For role, either ping or ID can be used"
698
                )
699
            )
700
@@ 701-800 (lines=100) @@
698
                )
699
            )
700
701
    @commands.command(name="massroleremove")
702
    @has_command_permission()
703
    async def mass_role_remove(
704
        self, ctx, role: discord.Role = None, role2: discord.Role = None
705
    ):
706
        if role is not None and role2 is not None:
707
            bot_msg = await ctx.send(
708
                embed=discord.Embed(
709
                    title="Confirmation",
710
                    description=(
711
                        f"Are you sure you want to update"
712
                        f" all members with the role {role.mention}"
713
                        f" by removing {role2.mention}?"
714
                    ),
715
                    color=var.C_BLUE
716
                ).add_field(
717
                    name=(
718
                        "Note that this action is irreversable"
719
                        " and cannot be stopped once started"
720
                    ),
721
                    value=(
722
                        f"{var.E_ACCEPT} to accept\n{var.E_ENABLE}"
723
                        f" to accept with live stats\n{var.E_DECLINE} to decline"
724
                    )
725
                )
726
            )
727
728
            await bot_msg.add_reaction(var.E_ACCEPT)
729
            await bot_msg.add_reaction(var.E_ENABLE)
730
            await bot_msg.add_reaction(var.E_DECLINE)
731
732
            def reaction_check(r, u):
733
                return u == ctx.author and r.message == bot_msg
734
735
            reaction, _ = await self.bot.wait_for(
736
                "reaction_add", check=reaction_check
737
            )
738
739
            updates = False
740
741
            try:
742
                await bot_msg.clear_reactions()
743
744
            except Exception:
745
                pass
746
747
            if str(reaction.emoji) == var.E_DECLINE:
748
                return await ctx.send("Cancelled mass role update")
749
750
            if str(reaction.emoji) == var.E_ENABLE:
751
                updates = True
752
753
            if str(reaction.emoji) == var.E_ENABLE or str(
754
                    reaction.emoji) == var.E_ACCEPT:
755
                count = 0
756
                for member in [
757
                    member
758
                    for member in ctx.guild.members
759
                    if role in member.roles
760
                ]:
761
                    try:
762
                        await member.remove_roles(role2)
763
                        count += 1
764
                        if updates:
765
                            await ctx.send(f"{member} updated")
766
767
                    except discord.Forbidden:
768
                        await ctx.send(
769
                            embed=discord.Embed(
770
                                description=(
771
                                    f"Error giving role to {member.mention}"
772
                                ),
773
                                color=var.C_ORANGE
774
                            )
775
                        )
776
                    await asyncio.sleep(1)
777
778
                await ctx.send(
779
                    f"Done,"
780
                    f" updated **{count}** members with the {role2.name} role"
781
                )
782
        else:
783
784
            await ctx.send(
785
                embed=discord.Embed(
786
                    title=f"🚫 Missing arguments",
787
                    description=(
788
                        "You need to define both Role 1 and Role 2\n"
789
                        "`role1` are the members having that role"
790
                        " and `role2` is the one to be removed from them"
791
                    ),
792
                    color=var.C_RED
793
                ).add_field(
794
                    name="Format",
795
                    value=(
796
                        f"```{await get_prefix(ctx)}massroleremove"
797
                        f" <role1> <role2>```"
798
                    )
799
                ).set_footer(
800
                    text="For role, either ping or ID can be used"
801
                )
802
            )
803