Exemple #1
0
    async def kick(self, ctx, user: Member):
        if user in self.tournament.participants:
            await user.remove_roles(self.roles.participant)
            if user in self.tournament.winners:
                self.tournament.winners.remove(user)
            self.tournament.remove_participant(user)
            await ctx.send(
                f"{Emote.leave} {user.mention} was kicked from the tournament."
            )
            Log("Participant Kicked",
                description=
                f"{user.mention} was kicked from **{self.tournament.name}** by {ctx.author.mention}.",
                color=Color.dark_gold())

            embed = UpdatedEmbed(self.tournament)
            await self.tournament.msg.edit(embed=embed)
            await self.checklist.update_text(ctx, self.tournament)

        elif user in self.tournament.spectators:
            await user.remove_roles(self.roles.spectator)
            self.tournament.spectators.remove(user)
            await ctx.send(
                f"{ctx.author.mention} is no longer spectating the tournament."
            )
            Log("Spectator Kicked",
                description=
                f"{ctx.author.mention} was kicked from **{self.tournament.name}** by {ctx.author.mention}.",
                color=Color.dark_gold())

            embed = UpdatedEmbed(self.tournament)
            await self.tournament.msg.edit(embed=embed)

        else:
            raise commands.BadArgument("This user is not in a tournament!")
Exemple #2
0
    async def leave(self, ctx):
        if ctx.author in self.tournament.participants:
            await ctx.author.remove_roles(self.roles.participant)
            if ctx.author in self.tournament.winners:
                self.tournament.winners.remove(ctx.author)
            self.tournament.remove_participant(ctx.author)
            await ctx.send(
                f"{Emote.leave} {ctx.author.mention} left the tournament.")
            Log("Participant Left",
                description=
                f"{ctx.author.mention} left **{self.tournament.name}**.",
                color=Color.dark_gold())

            embed = UpdatedEmbed(self.tournament)
            await self.tournament.msg.edit(embed=embed)
            await self.checklist.update_text(ctx, self.tournament)

        elif ctx.author in self.tournament.spectators:
            await ctx.author.remove_roles(self.roles.spectator)
            self.tournament.spectators.remove(ctx.author)
            await ctx.send(
                f"{ctx.author.mention} is no longer spectating the tournament."
            )
            Log("Spectator Left",
                description=
                f"{ctx.author.mention} left **{self.tournament.name}**.",
                color=Color.dark_gold())

            embed = UpdatedEmbed(self.tournament)
            await self.tournament.msg.edit(embed=embed)

        else:
            raise commands.BadArgument("You are not in a tournament!")
Exemple #3
0
    async def add(self, ctx: commands.Context):
        try:
            setup = await self._get_input(
                ctx,
                "Enter joke setup",
                "Enter the question/setup to be done before answering/finishing the joke",
            )
            end = await self._get_input(
                ctx, "Enter joke end", "Enter the text to be used to finish the joke"
            )
        except asyncio.TimeoutError:
            return await ctx.send("You didn't answer")

        await UserModel.get_or_create(id=ctx.author.id)
        joke = await JokeModel.create(setup=setup, end=end, creator_id=ctx.author.id)

        msg = await self.joke_entries_channel.send(
            embed=Embed(
                title=f"Joke #{joke.id}",
                description="**Setup**: {0.setup}\n\n**End**: {0.end}\n\n**Server**: {1.name} (`{1.id}`)\n\n**Username**: {2} (`{2.id}`)\n\nJoke ID: {0.id}".format(
                    joke, ctx.guild, ctx.author
                ),
                color=Color.dark_gold(),
            )
        )
        await ctx.send("Your submission has been recorded!")

        await msg.add_reaction("\u2705")
        await msg.add_reaction("\u274e")
        await self.joke_entries_channel.send("<@&815237052639477792>", delete_after=1)
Exemple #4
0
def random():
    # type: () -> Color

    chilipepper = Color(0x9B1B30)
    tan = Color(0xBEAA3E)
    icedcoffee = Color(0xB18F6A)

    return choice([
        Color.teal(),
        Color.dark_teal(),
        Color.green(),
        Color.dark_green(),
        Color.blue(),
        Color.dark_blue(),
        Color.purple(),
        Color.dark_purple(),
        Color.magenta(),
        Color.dark_magenta(),
        Color.gold(),
        Color.dark_gold(),
        Color.orange(),
        Color.dark_orange(),
        Color.red(),
        Color.dark_red(),
        Color.lighter_grey(),
        Color.darker_grey(),
        Color.blurple(),
        tan,
        icedcoffee,
        chilipepper,
    ])
Exemple #5
0
def random():
    # type: () -> Color

    tan = Color(0xBEAA3E)

    return choice([
        Color.teal(),
        Color.dark_teal(),
        Color.green(),
        Color.dark_green(),
        Color.blue(),
        Color.dark_blue(),
        Color.purple(),
        Color.dark_purple(),
        Color.magenta(),
        Color.dark_magenta(),
        Color.gold(),
        Color.dark_gold(),
        Color.orange(),
        Color.dark_orange(),
        Color.red(),
        Color.dark_red(),
        Color.lighter_grey(),
        Color.darker_grey(),
        Color.blurple(),
        tan,
    ])
Exemple #6
0
def warning(message: str) -> Embed:
    """
    Constructs warning embed with fixed title 'Warning' and color gold.
    :param message: embed description
    :return: Embed object
    """
    return simple_embed(message, "Warning", Color.dark_gold())
Exemple #7
0
    async def add(self, ctx: commands.Context):
        """Submit a joke that can then get approved and part of the collection"""
        try:
            setup = await self._get_input(
                ctx,
                "Enter joke setup",
                "Enter the question/setup to be done before answering/finishing the joke",
            )
            end = await self._get_input(
                ctx, "Enter joke end",
                "Enter the text to be used to finish the joke")
        except asyncio.TimeoutError:
            return await ctx.send("You didn't answer")

        await UserModel.get_or_create(id=ctx.author.id)
        joke = await JokeModel.create(setup=setup,
                                      end=end,
                                      creator_id=ctx.author.id)

        msg = await self.joke_entries_channel.send(embed=Embed(
            title=f"Joke #{joke.id}",
            description=joke_format.format(joke, ctx.guild, ctx.author),
            color=Color.dark_gold(),
        ))
        await ctx.send("Your submission has been recorded!")

        await msg.add_reaction("\u2705")
        await msg.add_reaction("\u274e")
        await self.joke_entries_channel.send("<@&815237052639477792>",
                                             delete_after=1)
Exemple #8
0
 def get_spoiler_embed(self, title, user, text=None):
     description = text or f'React with {self.qm} to reveal the spoiler.'
     embed = Embed(title=title,
                   description=description,
                   color=Color.dark_gold())
     embed.set_author(name=user, icon_url=user.avatar_url_as(format='png'))
     return embed
Exemple #9
0
 def __init__(self, client):
     self.client = client
     self.client_color = Color.red()
     self.color_dict = {
         1: [Color.teal(), 'teal'],
         2: [Color.dark_teal(), 'dark_teal'],
         3: [Color.green(), 'green'],
         4: [Color.dark_green(), 'dark_green'],
         5: [Color.blue(), 'blue'],
         6: [Color.dark_blue(), 'dark_blue'],
         7: [Color.purple(), 'purple'],
         8: [Color.dark_purple(), 'dark_purple'],
         9: [Color.magenta(), 'magenta'],
         10: [Color.dark_magenta(), 'dark_magenta'],
         11: [Color.gold(), 'gold'],
         12: [Color.dark_gold(), 'dark_gold'],
         13: [Color.orange(), 'orange'],
         14: [Color.dark_orange(), 'dark_orange'],
         15: [Color.red(), 'red'],
         16: [Color.dark_red(), 'dark_red'],
         17: [Color.lighter_grey(), 'lighter_grey'],
         18: [Color.dark_grey(), 'grey'],
         19: [Color.light_grey(), 'light_grey'],
         20: [Color.darker_grey(), 'darker_grey']
     }
Exemple #10
0
def random():
    c = [
        Color.teal(),
        Color.dark_teal(),
        Color.green(),
        Color.dark_green(),
        Color.blue(),
        Color.dark_blue(),
        Color.purple(),
        Color.dark_purple(),
        Color.magenta(),
        Color.dark_magenta(),
        Color.gold(),
        Color.dark_gold(),
        Color.orange(),
        Color.dark_orange(),
        Color.red(),
        Color.dark_red(),
        Color.lighter_grey(),
        Color.darker_grey(),
        Color.blurple(),
        tan,
        icedcoffee,
        chilipepper
    ]
    return c[randint(0, len(c) - 1)]
Exemple #11
0
    async def choose(self, ctx, *args):
        """
        Make a random choice from given items
        """

        # Bamboozeled with nothing to choose from
        if len(args) == 0:
            embed_msg = Embed(
                title="Much bamboozel, such confuse",
                description=
                "Stoopid hooman, you have to give me something to choose from!",
                color=Color.dark_gold())

            embed_msg.set_image(url=self.bamboozel)

            await ctx.send(embed=embed_msg)

        # Many choice, such decision
        elif len(args) == 1:
            await ctx.send(f"Such a hard choice, I choose '{args[0]}'")

        # Take a random pick
        else:
            await ctx.send(
                f"{len(args)} items given to choose from...\nHmmm...")
            await sleep(2)

            embed_msg = Embed(title=f"I choose '{choice(args)}'!",
                              color=Color.random())

            embed_msg.set_image(url=self.i_choose_you)

            await ctx.send(embed=embed_msg)
Exemple #12
0
    def search(self, query):
        feats = list(
            filter(
                lambda x: str(query).lower() in x.get("name", "").lower(), self.cache
            )
        )

        if len(feats) == 1 or query.lower() in list(
            map(lambda x: x["name"].lower(), feats)
        ):
            # Only a single feat was found, so return all the details about it
            feat = (
                feats[0]
                if len(feats) == 1
                else list(
                    filter(lambda x: x["name"].lower() == str(query).lower(), feats)
                )[0]
            )
            feat["featType"] = FeatTypes[feat["featType"]]

            res = Embed(title=f"{feat['name']}", color=feat["featType"].value)
            res.add_field(
                name="Type", value=feat["featType"].name.capitalize(), inline=False
            )
            res.add_field(
                name="Description",
                value=html2text(feat["description"]).strip(),
                inline=False,
            )
            res.add_field(
                name="Requirements",
                value="\n".join(feat["requirements"])
                if feat["requirements"]
                else "None",
                inline=False,
            )
            res.add_field(name="Prerequisite", value=feat["requiredFeat"], inline=False)
        elif len(feats) >= 1:
            # User is searching based on a query, so return a list of feats based on that name
            res = Embed(title=f'Features Matching "{query}":', color=Color.dark_gold())
            feat_map = {
                feat_name: []
                for feat_name in list(map(lambda x: x["featType"].capitalize(), feats))
            }
            for feat in list(
                map(
                    lambda x: {"name": x["name"], "type": x["featType"].capitalize()},
                    feats,
                )
            ):
                feat_map[feat["type"]].append(feat["name"])

            for type, names in feat_map.items():
                res.add_field(name=type, value="\n".join(names), inline=False)
        else:
            res = Embed(title=f'Feat not found: "{query}"', color=Color.red())

        return res
Exemple #13
0
 async def chuck(self, ctx):
     ad = Embed(color=Color.dark_gold())
     base = "https://api.chucknorris.io/jokes/random"
     async with ClientSession() as session:
         data = await get(session, base)
     data = literal_eval(data)
     ad.set_author(name="Chuck Norris",
                   icon_url="https://i.ibb.co/swZqcK7/norris.gif",
                   url=data['url'])
     ad.description = data['value']
     return await ctx.send(embed=ad)
Exemple #14
0
 async def advice(self, ctx):
     ad = Embed(color=Color.dark_gold())
     ad.title = "Your advice is.."
     base = "https://api.adviceslip.com/advice"
     async with ClientSession() as session:
         data = await get(session, base)
     data = literal_eval(data)
     data = data['slip']
     ad.description = data['advice']
     ad.set_footer(text=f"No: {data['id']}",
                   icon_url="https://i.ibb.co/9g27ggN/advice.png")
     return await ctx.send(embed=ad)
Exemple #15
0
 async def page(self, ctx, *, search):
     result = self.wiki.page(search)
     if not result.exists():
         return await ctx.send(embed=Embed(
             title="Page not found ⛔",
             description=f"No page was found under the name `{search}`",
             color=Color.blurple()))
     wiki = Embed(color=Color.dark_gold())
     wiki.title = result.title
     wiki.url = result.fullurl
     wiki.description = f'{result.text[0:500]}...'
     wiki.set_footer(
         text="Powered by Wikipedia",
         icon_url="https://i.ibb.co/jyX08CD/wikipedia-PNG39.png")
     wiki.timestamp = ctx.message.created_at
     return await ctx.send(embed=wiki)
Exemple #16
0
    async def on_guild_update(self, before: Guild, after: Guild) -> None:
        description = "Guild configuration has changed."

        last_log = await last_audit_log_with_fail_embed(
            after,
            actions=[AuditLogAction.guild_update],
            send_callback=partial(self.send_log, after))

        if last_log:
            description += f"\n**Updated by:** {last_log.user.mention}"

        embed = Embed(title="Guild updated",
                      description=description,
                      color=Color.dark_gold())
        embed = add_change_field(embed, before, after)

        embed.timestamp = datetime.datetime.now()

        await self.send_log(after, embed=embed)
Exemple #17
0
    async def on_guild_role_update(self, before: Role, after: Role) -> None:
        description = f"**Role:** {after.mention}"

        last_log = await last_audit_log_with_fail_embed(
            after.guild,
            actions=[AuditLogAction.role_update],
            send_callback=partial(self.send_log, after.guild))

        embed = Embed(title="Role updated",
                      description=description,
                      color=Color.dark_gold())

        if last_log:
            description += f"\n**Updated by:** {last_log.user.mention}"

        if before.permissions != after.permissions:
            embed = add_permissions_field(embed, before.permissions,
                                          after.permissions)
        else:
            embed = add_change_field(embed, before, after)

        embed.timestamp = datetime.datetime.now()

        await self.send_log(after.guild, embed=embed)
Exemple #18
0
 async def build_profile_embed(self, karma_member: KarmaMember,
                               guild) -> discord.Embed:
     channel_cursor = self.karma_service.aggregate_member_by_channels(
         karma_member)
     embed: discord.Embed = discord.Embed(colour=Color.dark_gold())
     embed.description = 'Karma Profile with breakdown of top {} channels'.format(
         profile()['channels'])
     total_karma: int = 0
     channel_list = list(channel_cursor)
     if len(channel_list) > 0:
         embed.add_field(name='0', value='0', inline=False)
         index = 0
         for document in channel_list:
             total_karma += document['karma']
             channel = guild.get_channel(int(document['_id']['channel_id']))
             if (index % 3) == 0 and index != 0:
                 embed.add_field(name="**{}**".format(channel.name),
                                 value=document['karma'],
                                 inline=False)
             else:
                 embed.add_field(name="**{}**".format(channel.name),
                                 value=document['karma'],
                                 inline=True)
         if len(channel_list) % 3 != 0:
             embed.add_field(name='\u200b', value='\u200b')
         embed.set_field_at(index=0,
                            name="**total**",
                            value=str(total_karma),
                            inline=False)
         return embed
     else:
         # small embed since no karma etc.
         embed.add_field(name="**total**",
                         value=str(total_karma),
                         inline=False)
         return embed
Exemple #19
0
    def search_talents_and_feats(self, class_name, query):
        # Check if cache is populated for this class
        if not self.class_list[class_name].get("feats", None):
            self.refresh_class_details(class_name)

        talents = list(
            filter(
                lambda x: str(query).lower() in x.get("name", "").lower(),
                self.class_list[class_name]["feats"],
            ))

        if len(talents) == 1 or query.lower() in list(
                map(lambda x: x["name"].lower(), talents)):
            # Only a single talent found, so return all details about it
            talent = (talents[0] if len(talents) == 1 else list(
                filter(lambda x: x["name"].lower() == str(query).lower(),
                       talents))[0])

            res = Embed(
                title=
                f"{talent['name']} -- Level {talent['level']} {class_name.capitalize()} {talent['talentType'].capitalize()}",
                color=ClassColors(class_name.upper()).value,
            )
            res.add_field(name="Cast Type",
                          value=talent["castTime"],
                          inline=True)
            res.add_field(name="Duration",
                          value=talent["duration"],
                          inline=True)
            res.add_field(
                name="Description",
                value=html2text(talent["description"]).strip(),
                inline=False,
            )
            res.add_field(
                name="Requirements",
                value="\n".join(talent["requirements"])
                if talent["requirements"] else "None",
                inline=False,
            )
            res.add_field(name="Prerequisite",
                          value=talent["requiredFeat"],
                          inline=False)
        elif len(talents) >= 1:
            # User is searching based on a query, so return a list of talents
            res = Embed(title=f'Features Matching "{query}":',
                        color=Color.dark_gold())
            talent_map = {
                feat_name: []
                for feat_name in list(
                    map(lambda x: x["talentType"].capitalize(), talents))
            }
            for talent in list(
                    map(
                        lambda x: {
                            "name": x["name"],
                            "type": x["talentType"].capitalize()
                        },
                        talents,
                    )):
                talent_map[talent["type"]].append(talent["name"])

            for type, names in talent_map.items():
                res.add_field(name=type, value="\n".join(names), inline=False)

        else:
            res = Embed(
                title=
                f'Feature/ talent not found for class {class_name.capitalize()}: "{query}"',
                color=Color.red(),
            )

        return res
Exemple #20
0
def ranking_em(ranking: str):
    return Embed(title=':trophy: Ranking', color=Color.dark_gold()).add_field(
        name='\u200b',
        value=ranking).set_footer(text=now().strftime('%Y-%m-%d %H:%M'))
from collections import defaultdict

from discord import Color

from util.config import karma_delete_emoji

zero_width_space: str = "\u200b"
revoke_message = ("If you {}, didn't intend to give karma to this person," +
                  " react to the" + karma_delete_emoji +
                  "of your original thanks message")
leaderboard_usage = ("{}leaderboard\n{}leaderboard <#channel_mention>"
                     "\n{}leaderboard (global) (days) \n"
                     "{}leaderboard "
                     "<#channel_mention> (days)")
embed_max_columns = 3  # 3 because discord embeds can have three fields in a line
embed_color = Color.dark_gold()
bold_field = "**{}**"
cog_map = defaultdict()  # cog name to cog class
aura_permissions = ["everyone", "moderator", "admin", "owner"]
hidden_config = ["token", "owner", "prefix", "database", "logging"]


# version dict
def version():
    return dict(aura_version="1.17.3",
                python_version="3.8.2",
                discord_version="1.6.0")


# return the discord tag of the author of this bot
def author_discord():
Exemple #22
0
    async def tictac(self, ctx):
        board = [[0] * 3 for _ in range(3)]
        game = Embed(color=Color.green())
        game.timestamp = ctx.message.created_at
        game.set_author(name="TicTacToe ❌ ⭕",
                        icon_url="https://i.ibb.co/bP3wRgY/download.png")
        members = set()
        game.set_footer(text=f"React with ✅ to join game")
        msg = await ctx.send(embed=game)
        await msg.add_reaction('✅')

        def check(r, u):
            return u != self.bot.user and r.emoji == "✅"

        while True:
            try:
                await self.bot.wait_for(event="reaction_add",
                                        timeout=15,
                                        check=check)
            except TimeoutError:
                break
        msg = await ctx.channel.fetch_message(id=msg.id)
        for reaction in msg.reactions:
            async for user in reaction.users():
                members.add(user)
        members.remove(self.bot.user)
        members = list(members)[:2]
        play = True
        while play:
            gwon = False
            player_cycle = cycle(members)
            gboard(board, just_display=True)
            while not gwon:
                current_player = next(player_cycle)
                played = False
                while not played:
                    game.description = view_board(board)
                    game.set_footer(text=f"{current_player}'s turn")
                    await ctx.send(embed=game)

                    def hcheck(m):
                        return m.author != self.bot.user and m.author == current_player

                    try:
                        msg = await self.bot.wait_for('message',
                                                      timeout=20.0,
                                                      check=hcheck)
                    except TimeoutError:
                        return
                    rc = list(msg.content)
                    rc = [int(i) - 1 for i in rc]
                    print(rc)
                    mem = list(members)
                    m2e = {mem[0]: "❌", mem[1]: "⭕"}
                    played = gboard(board,
                                    player=m2e[current_player],
                                    row=rc[0],
                                    column=rc[1])

                if win(board):
                    game.description = view_board(board)
                    await ctx.send(embed=game)
                    return await ctx.send(embed=Embed(
                        title="🎇 Game Over 🎆!",
                        description=f"Player {current_player} has won!",
                        color=Color.dark_gold(),
                        timestamp=ctx.message.created_at))
Exemple #23
0
def AdminEmbed(title: str, desc: str) -> Embed:
    return BaseEmbed(
        title=":exclamation:\t{0}".format(title),
        description="{0}".format(desc),
        color=Color.dark_gold(),
    )