Пример #1
0
    async def on_ready(self) -> None:
        if self.initial_call:
            self.initial_call = False

            # Log new connection
            self.log_channel = self.get_channel(config.log_channel)
            embed = Embed(
                title="Bot Connection",
                description="New connection initialized.",
                timestamp=datetime.utcnow(),
                color=Color.dark_teal(),
            )
            await self.log_channel.send(embed=embed)

            # Load all extensions
            for extension in self.extension_list:
                try:
                    self.load_extension(extension)
                    print(f"Cog {extension} loaded.")
                except Exception as e:
                    print(
                        f"Cog {extension} failed to load with {type(e)}: {e}")
        else:
            embed = Embed(
                title="Bot Connection",
                description="Connection re-initialized.",
                timestamp=datetime.utcnow(),
                color=Color.dark_teal(),
            )
            await self.log_channel.send(embed=embed)

        print("Bot is ready")
Пример #2
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,
    ])
Пример #3
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']
     }
Пример #4
0
    async def on_raw_reaction_add(self, payload):
        guild = self.bot.get_guild(payload.guild_id)
        log_channel = self.bot.get_log_channel(payload.guild_id)
        if int(payload.message_id) == get_guild_yoinker(payload.guild_id):

            # need permission to manage server
            if not payload.member.guild_permissions.manage_guild:
                return

            emoji = payload.emoji
            if emoji in guild.emojis:
                print("emoji already exists")
                return

            try:
                response = requests.get(emoji.url)
                await guild.create_custom_emoji(name=emoji.name,
                                                image=response.content)
            except HTTPException:
                if log_channel is not None:
                    await log_channel.send(
                        f"Problem adding emoji {emoji.name}.")
                    return

            embed = create_embed(f"Emoji added to {guild.name}!",
                                 f"{emoji.name}",
                                 image_url=emoji.url,
                                 color=Color.dark_teal())

            if log_channel is not None:
                await log_channel.send(embed=embed)
Пример #5
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,
    ])
Пример #6
0
    async def edit(self, ctx, modifier, *, value):
        i = ModifierCheck(modifier, self.tournament.modifiers)

        if i is False:
            raise commands.BadArgument(f"`{modifier}` is not active.")

        modifier = self.tournament.modifiers[i]
        if isinstance(modifier, str):
            raise commands.BadArgument(
                f"The value for `{modifier}` cannot be edited.")

        old_value = modifier['value']
        j = self.modifiers[ModifierCheck(modifier['name'], self.modifiers)]
        modifier['value'] = await ModifierUtils.convert_value(
            ctx, j['value'], value)

        if old_value == modifier['value']:
            await ctx.send("Nothing changed. Silly!")
            return

        await ctx.send(
            f"{Emote.check} The value for `{modifier['name']}` was changed to **{modifier['value']}**."
        )
        fields = [{
            'name': "Old Value",
            'value': old_value
        }, {
            'name': "New Value",
            'value': modifier['value']
        }]
        Log("Modifier Edited",
            description=
            f"{ctx.author.mention} changed the value of `{modifier['name']}` for **{self.tournament.name}**.",
            color=Color.dark_teal(),
            fields=fields)
Пример #7
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)]
Пример #8
0
 async def about(self, ctx):
     embed = Embed(
         title="About Stonks",
         description="Stonks is a bot created by manish#9999 using "
         "[discord.py](https://discordpy.readthedocs.io/en/latest/index.html). The source "
         "code can be found [here](https://github.com/iammanish17/Stonks)!",
         color=Color.dark_teal())
     embed.set_footer(text=f"Requested by {str(ctx.author)}",
                      icon_url=ctx.author.avatar_url)
     await ctx.channel.send(embed=embed)
Пример #9
0
    async def remove(self, ctx, modifier):
        i = ModifierCheck(modifier, self.tournament.modifiers)

        if i is False:
            raise commands.BadArgument(
                f"Modifier `{modifier}` is not active on this tournament.")

        old = self.tournament.modifiers[i]
        self.tournament.modifiers.pop(i)
        await ctx.send(f"{Emote.check} `{modifier}` has been removed.")
        fields = []
        if isinstance(old, dict):
            fields.append({'name': "Old Value", 'value': old['value']})
        Log("Modifier Removed",
            description=
            f"{ctx.author.mention} has removed `{modifier}` from **{self.tournament.name}**.",
            color=Color.dark_teal(),
            fields=fields)
Пример #10
0
 async def _image(self, ctx, *, query):
     image = Embed(color=Color.dark_teal())
     image.title = query.title()
     if len(query.split()) > 1:
         query = '+'.join(query.split())
     key = '17191614-063633dedf733f61470d1198b'
     base = f'https://pixabay.com/api/?key={key}&q={query}&lang=en&per_page=3'
     async with ClientSession() as session:
         url = await get(session, base)
     url = literal_eval(url)
     url = url['hits']
     url = choice(url)
     image.set_footer(text=url['tags'],
                      icon_url="https://i.ibb.co/Vqgtj2z/pix.png")
     image.set_image(url=url['largeImageURL'])
     image.set_author(name=url['user'],
                      icon_url=url['userImageURL'],
                      url=url['pageURL'])
     await ctx.send(embed=image)
Пример #11
0
    async def add(self, ctx, modifier, *, value=None):
        i = ModifierCheck(modifier, self.modifiers)

        if i is False:
            raise commands.BadArgument(f"Unknown modifier `{modifier}`.")

        if value is None and modifier not in self.modifiers:
            raise commands.errors.MissingRequiredArgument(
                Parameter('value', Parameter.KEYWORD_ONLY))

        if ModifierCheck(modifier, self.tournament.modifiers) is not False:
            raise commands.BadArgument(
                f"`{modifier}` has already been added to the tournament.")

        modifier = self.modifiers[i]
        fields = []

        if isinstance(modifier, dict):  # Value Settable Modifier
            modifier = modifier.copy()
            modifier['value'] = await ModifierUtils.convert_value(
                ctx, modifier['value'], value)
            fields.append({'name': "New Value", 'value': modifier['value']})
            await ctx.send(
                f"{Emote.check} `{modifier['name']}` was set to **{value}**.")
        else:
            await ctx.send(
                f"{Emote.check} `{modifier}` is now active for this tournament."
            )

        self.tournament.modifiers.append(modifier)
        if isinstance(modifier, dict):
            modifier = modifier['name']
        Log("Modifier Added",
            description=
            f"{ctx.author.mention} added the modifier `{modifier}` to **{self.tournament.name}**.",
            color=Color.dark_teal(),
            fields=fields)
Пример #12
0
    async def hangman(self, ctx: Context) -> None:
        def display_hangman(tries: int) -> str:
            stages = [
                # final state: head, torso, both arms, and both legs
                r"""```
--------
|      |
|      O
|     \|/
|      |
|     / \
-
                    ```""",
                # head, torso, both arms, and one leg
                r"""```
--------
|      |
|      O
|     \|/
|      |
|     /
-
                    ```""",
                # head, torso, and both arms
                r"""```
--------
|      |
|      O
|     \|/
|      |
|
-
                    ```""",
                # head, torso, and one arm
                r"""```
--------
|      |
|      O
|     \|
|      |
|
-
                    ```""",
                # head and torso
                r"""```
--------
|      |
|      O
|      |
|      |
|
-
                    ```""",
                # head
                r"""```
--------
|      |
|      O
|
|
|
-
                    ```""",
                # initial empty state
                r"""```
--------
|      |
|
|
|
|
-
                    ```""",
            ]
            return stages[tries]

        def check(message: Message) -> bool:
            return message.author == ctx.author and message.channel == ctx.channel

        word = random.choice(word_list).upper()
        word_completion = "#" * len(word)
        guessed = False
        guessed_letters = []
        guessed_words = []
        tries = 6

        await ctx.send(
            embed=Embed(title="Let's play Hangman!", color=Color.dark_green()))
        embed = Embed(title="Hangman Status", color=Color.dark_teal())
        embed.add_field(name="**❯❯ Hang Status**",
                        value=display_hangman(tries),
                        inline=False)
        embed.add_field(name="**❯❯ Word Completion Status**",
                        value=f"**{word_completion}**",
                        inline=False)
        embed.set_footer(text="Powered By HotWired.")
        await ctx.send(embed=embed)

        while not guessed and tries > 0:
            await ctx.send(
                embed=Embed(description="Please guess a letter or word: ",
                            color=Color.gold()))
            input = await self.bot.wait_for("message", check=check)
            guess = input.content.upper()

            if len(guess) == 1 and guess.isalpha():
                if guess in guessed_letters:
                    await ctx.send(embed=Embed(
                        description=f"You already guessed the letter {guess}",
                        color=Color.red()))
                elif guess not in word:
                    await ctx.send(
                        embed=Embed(description=f"{guess} is not in the word.",
                                    color=Color.dark_magenta()))
                    tries -= 1
                    guessed_letters.append(guess)
                else:
                    await ctx.send(embed=Embed(
                        description=f"Good job, {guess} is in the word!",
                        color=Color.dark_green()))
                    guessed_letters.append(guess)
                    word_as_list = list(word_completion)
                    indices = [
                        i for i, letter in enumerate(word) if letter == guess
                    ]

                    for index in indices:
                        word_as_list[index] = guess
                    word_completion = "".join(word_as_list)
                    if "#" not in word_completion:
                        guessed = True

            elif len(guess) == len(word) and guess.isalpha():
                if guess in guessed_words:
                    await ctx.send(embed=Embed(
                        description=f"You already guessed the word {guess}",
                        color=Color.red()))
                elif guess != word:
                    await ctx.send(
                        embed=Embed(description=f"{guess} is not the word.",
                                    color=Color.dark_orange()))
                    tries -= 1
                    guessed_words.append(guess)
                else:
                    guessed = True
                    word_completion = word
            else:
                await ctx.send(embed=Embed(description="Not a valid guess.",
                                           color=Color.blurple()))

            embed = Embed(title="Hangman Status", color=Color.dark_teal())
            embed.add_field(name="**❯❯ Hang Status**",
                            value=display_hangman(tries),
                            inline=False)
            embed.add_field(name="**❯❯ Word Completion Status**",
                            value=f"**{word_completion}**",
                            inline=False)
            embed.set_footer(text="Powered By HotWired.")
            await ctx.send(embed=embed)

        if guessed:
            await ctx.send(embed=Embed(
                description=
                "Congrats, you guessed the word! You win! :partying_face: ",
                color=Color.dark_green()))
        else:
            await ctx.send(embed=Embed(
                description=
                f"Sorry, you ran out of tries. The word was {word}. Maybe next time! :frowning: ",
                color=Color.red()))