Exemple #1
0
class EventColors(Enum):
    ban = Colour.dark_red()
    unban = Colour.teal()
    kick = Colour.red()
    join = Colour.dark_green()
    leave = Colour.blue()
    delete = Colour.magenta()
    bulk_delete = Colour.dark_magenta()
    edit = Colour.gold()
    name_change = Colour.purple()
    nickname_change = Colour.blurple()
    role_added = Colour.dark_teal()
    role_removed = Colour.orange()
    verified = Colour.light_grey()
Exemple #2
0
    active = 0
    won = 1
    draw = 2
    forfeit = 3
    timeout = 4


class MsgLevel(Enum):
    info = 0
    warning = 1
    error = 2


MSG_ICON = [Emoji.info, Emoji.warning, Emoji.error]

MSG_COLOR = [Colour.blue(), Colour.orange(), Colour.red()]

AWBW_ROLES = {
    "os": 424524133670453250,  # Orange Star Commander
    "bm": 424524139999789058,  # Blue Moon Commander
    "ge": 424524144353476629,  # Green Earth Commander
    "yc": 424524148958560266,  # Yellow Comet Commander
    "bh": 424524153387876353,  # Black Hole Commander
    "rf": 424541540740890624,  # Red Fire Commander
    "gs": 424541543810990089,  # Grey Sky Commander
    "bd": 424541547757961216,  # Brown Desert Commander
    "ab": 424541550853488640,  # Amber Blaze Commander
    "js": 424541553898291200,  # Jade Sun Commander
    "ci": 424541559766122518,  # Cobalt Ice Commander
    "pc": 424541563520024576,  # Pink Cosmos Commander
    "tg": 424541566934319104,  # Teal Galaxy Commander
Exemple #3
0
    async def roles(self, ctx: commands.Context, *args):

        receivers = {}
        embed = discord.Embed()
        embed_sender = discord.Embed()
        roles = ctx.message

        await ctx.message.delete()

        def check_exit(msg: discord.Message):
            return msg.author.id is ctx.author.id and msg.content == "exit"

        def check_role(msg: discord.Message):
            return msg.author.id is ctx.author.id and (
                msg.content.strip().startswith("<@&")
                and msg.content.strip().endswith(">")) or (msg.content
                                                           == "exit")

        def check_emoji(payload: discord.RawReactionActionEvent):
            return payload.member.id is ctx.author.id and payload.message_id == sender.id

        embed_sender.add_field(name="Tapez `exit`",
                               value="Pour annuler la commande")
        embed_sender.set_author(name=ctx.author.display_name,
                                icon_url=ctx.author.avatar_url)

        embed_sender.colour = Colour.orange()
        embed_sender.title = ":anger: Rôles :anger:"
        embed_sender.timestamp = datetime.utcnow()
        embed_sender.description = "__**Veuillez entrer des rôles (20 max) séparés d'un espace entre chaque**__ *(Ex: @admin @nitro @helper ...)*"
        sender = await ctx.send(embed=embed_sender)

        try:
            roles = await self.client.wait_for("message",
                                               check=check_role,
                                               timeout=120.0)
        except asyncio.TimeoutError:
            embed_sender.colour = Colour.red()
            embed_sender.title = ":x: Temps expiré :x:"
            embed_sender.timestamp = datetime.utcnow()
            embed_sender.description = "Vous avez mis plus de 120 secondes pour me répondre. Commande annulée"
            embed_sender.clear_fields()
            return await sender.edit(embed=embed_sender)
        else:
            if roles.content.strip().lower() == "exit":
                return await ctx.send("Commande annulée")
            await roles.delete()

        if len(roles.role_mentions) > 20:
            warning = await ctx.send(
                ":warning: **Trop de rôles indiqués** *(seuls les 20 premiers on été pris en compte)* :warning:"
            )

        roles.role_mentions.sort(reverse=True)

        for role in roles.role_mentions:
            if roles.role_mentions.index(role) >= 20:
                roles.role_mentions.pop(roles.role_mentions.index(role))

            embed_sender.colour = Colour.green()
            embed_sender.title = f":white_check_mark: {role.name} :white_check_mark:"
            embed_sender.description = f"Ajoutez une réaction à ce message pour le rôle **{role.name}**"
            embed_sender.clear_fields()
            embed_sender.add_field(name="Rôle", value=role.mention)
            embed_sender.timestamp = datetime.utcnow()
            embed_sender.set_footer(
                text=
                f"{roles.role_mentions.index(role)}/{len(roles.role_mentions[:20])}"
            )
            await sender.edit(embed=embed_sender)

            done, pending = await asyncio.wait(
                [
                    self.client.wait_for("message", check=check_exit),
                    self.client.wait_for("raw_reaction_add", check=check_emoji)
                ],
                return_when=asyncio.FIRST_COMPLETED)

            try:
                stuff = done.pop().result()
                if isinstance(stuff,
                              discord.Message) and stuff.content == "exit":
                    return await ctx.send("Commande annulée")
                else:
                    receivers[role] = stuff
            except:
                return ctx.send("Une erreur s'est produite")
            for future in done:
                future.exception()
            for future in pending:
                future.cancel()
        try:
            await warning.delete()
        except:
            pass
        await sender.delete()

        embed.title = " ".join(args) or "Attribution des Rôles"
        embed.description = "Cliquez sur l'une des réactions à ce message pour obtenir le rôle associé."
        embed.colour = discord.Colour(126)
        embed.set_author(name=ctx.message.guild.name)
        embed.set_thumbnail(url=ctx.guild.icon_url)
        embed.timestamp = datetime.now(timezone.utc)

        for key, value in receivers.items():
            embed.add_field(name=value.emoji, value=key.mention, inline=True)

        message = await ctx.send(embed=embed)
        await message.pin(reason="Roles Attribution")

        await ctx.channel.purge(limit=1)

        for emoji in receivers.values():
            await message.add_reaction(emoji.emoji)