Пример #1
0
    async def get_embed_raffle(self, bot):
        """
    Returns an embed message corresponding to the raffle message
    --
    input:
      bot: interactions.Client
    """
        desc = f"Today's raffle is special! Click the button below to participate, and it's completely free! {self.reward} {Constants.PIFLOUZ_EMOJI} are at stake! The first winner will earn 50%, the second one wille get 30% and the third winner wille get 20%!"

        fields = []

        if "birthday_raffle_participation" in db.keys() and len(
                db["birthday_raffle_participation"]) > 0:
            participation = list(db["birthday_raffle_participation"])
            val = "\n".join(f"• <@{user_id}>" for user_id in participation)

            fields.append(
                EmbedField(name="Current participants",
                           value=val,
                           inline=False))
            fields.append(
                EmbedField(
                    name="Total prize",
                    value=
                    f"The three winners will earn 50%, 30% and 20% of the total jackpot of {self.reward} {Constants.PIFLOUZ_EMOJI}!",
                    inline=False))

        embed = Embed(
            title="Birthday Special Raffle!",
            description=desc,
            color=Color.random().value,
            thumbnail=EmbedImageStruct(url=Constants.PIBOU4BIRTHDAY_URL)._json,
            fields=fields)

        return embed
Пример #2
0
    async def send_wordle_embed(self, ctx, wordle, guesses, header_str):
        """
    Generates the wordle image, host it on imgur and send the it as an interaction response
    --
    input:
      ctx: interactions.CommandContext
      wordle: wordle.Wordle
      guesses: List[str]
      header_str: str
    """
        img_path = "wordle_tmp.png"
        wordle.generate_image(guesses, img_path)
        link = utils.upload_image_to_imgur(img_path)
        os.remove(img_path)

        color = Color.gold()
        if len(guesses) > 0 and guesses[-1] == wordle.solution:
            color = Color.dark_green()
        elif len(guesses
                 ) == wordle.nb_trials and guesses[-1] != wordle.solution:
            color = Color.dark_red()

        embed = Embed(title="Wordle",
                      description=header_str,
                      color=color.value,
                      image=EmbedImageStruct(url=link)._json)
        await ctx.send(embeds=embed, ephemeral=True)
Пример #3
0
def get_embed_piflouz(bot):
    """
  Creates an embed message containing the explanation for the piflouz game and the balance
  --
  input:
    bot: interactions.Client
  --
  output:
    embed: interactions.Embed
  """
    last_begin_time = datetime.datetime.fromtimestamp(db["last_begin_time"])
    end_time = last_begin_time + relativedelta(months=3)
    desc = f"This is the piflouz mining message, click every {Constants.REACT_TIME_INTERVAL} seconds to gain more {Constants.PIFLOUZ_EMOJI}.\n\n\
You just need to click on the {Constants.PIFLOUZ_EMOJI} button below or use the `/get` command.\n\
If you waited long enough ({utils.seconds_to_formatted_string(Constants.REACT_TIME_INTERVAL)}), you will earn some {Constants.PIFLOUZ_EMOJI}! The amount depends on the current event, your powerups, your mining combo and your accuracy to use `/get`.\n\n\
This season will end on <t:{int(end_time.timestamp())}>.\nYour goal is to earn, donate and flex with as much piflouz as possible. You will earn rewards based on the amount of piflouz you earn and your different rankings."

    fields = []

    # Rankings
    if "piflouz_bank" in db.keys():
        d_piflouz = dict(db["piflouz_bank"])
        d_piflex = [(user_id, len(discovered))
                    for user_id, discovered in db["discovered_piflex"].items()]
        d_donations = [(user_id, val)
                       for user_id, val in db["donation_balance"].items()
                       if val > 0]

        ranking_balance = get_ranking_str(list(d_piflouz.items()))
        ranking_piflex = get_ranking_str(d_piflex)
        ranking_donations = get_ranking_str(d_donations)

        if ranking_balance != "":
            fields.append(
                EmbedField(name="Balance", value=ranking_balance, inline=True))
        if ranking_piflex != "":
            fields.append(
                EmbedField(name="Piflex Discovery",
                           value=ranking_piflex,
                           inline=True))
        if ranking_donations != "":
            fields.append(
                EmbedField(name="Donations",
                           value=ranking_donations,
                           inline=False))

    embed = Embed(title=f"Come get some {Constants.PIFLOUZ_EMOJI}!",
                  description=desc,
                  thumbnail=EmbedImageStruct(url=Constants.PIFLOUZ_URL)._json,
                  fields=fields,
                  color=Color.gold().value)

    return embed
Пример #4
0
async def get_embed_otter():
    """
  Returns an embed corresponding to a random otter image
  --
  output:
    embed: interactions.Embed
  """
    url = await socials.get_otter_image()
    embed = Embed(
        title="Otter image of the day!",
        color=Color.from_rgb(101, 67, 33).value,  # brown
        image=EmbedImageStruct(url=url)._json)
    return embed
Пример #5
0
def get_embed_twitch_notif():
    """
  Returns an embed message on which to react to get the role to get notified when pibou421 goes live on Twitch
  --
  output:
    embed: interactions.Embed
  """
    embed = Embed(
        title="Twitch notification role",
        description="React to get/remove the Twitch notifications role",
        color=Color.purple().value,
        thumbnail=EmbedImageStruct(
            url=Constants.PIBOU_TWITCH_THUMBNAIL_URL)._json)
    return embed
Пример #6
0
 def get_end_embed(self):
     """
 Returns the embed shown at the end of the event
 --
 output:
   embed: interactions.Embed
 """
     nb_cakes = db["baked_cakes"]["total"]
     embed = Embed(
         title="The baking is over!",
         thumbnail=EmbedImageStruct(url=Constants.PIBOU4BIRTHDAY_URL)._json,
         description=
         f"Congratulations, you managed to bake {nb_cakes}. Pibot will invest the earned {nb_cakes * self.reward_per_cake} {Constants.PIFLOUZ_EMOJI} in the next event! 👀",
         color=Color.from_rgb(255, 255, 255).value  # white
     )
     return embed
Пример #7
0
    def get_embed(self):
        """
    Returns an embed to announce the event
    --
    output:
      embed: interactions.Embed
    """
        desc = f"Use `/wordle guess [word]` to try to find the word of the day and earn {self.reward}{Constants.PIFLOUZ_EMOJI}!\nYou can also check your progress with `/wordle status`"

        embed = Embed(
            title="New Wordle!",
            description=desc,
            color=Color.random().value,
            thumbnail=EmbedImageStruct(url=Constants.PIBOU4STONKS_URL)._json,
            fields=[])
        return embed
Пример #8
0
    def get_start_embed(self):
        """
    Returns the embed shown at the start of the event
    --
    output:
      embed: interactions.Embed
    """
        nb_backed_cakes = db["baked_cakes"]["total"]

        embed = Embed(
            title="Happy birthday Pibot!",
            thumbnail=EmbedImageStruct(url=Constants.PIBOU4BIRTHDAY_URL)._json,
            description=
            f"Today is Pibot's 1 year anniversary!\nYour goal is to bake as much birthday cake as possible! To do so, deliveries will appear randomly through the day, bringing cake resources. You can collect these resources, but be quick, or the delivery person will get impatient and leave. You can use the `/role get Birthday Notifications` command to get notified when the delivery arrives.\n Each cake requires {', '.join(f'{nb} {e}' for e, nb in self.ingredients_per_cake.items())} to be baked. Pibot will earn {self.reward_per_cake} per cake, and get very happy!\n You can check your progress and inventory using the `/birthday` command.\n\nCakes baked so far: {nb_backed_cakes}",
            color=Color.from_rgb(255, 255, 255).value,  # white
        )
        return embed
Пример #9
0
    def get_embed(self):
        """
    Returns an embed to announce the event
    --
    output:
      embed: interactions.Embed
    """
        descriptions = [p.get_event_str() for p in self.powerups]
        content = "\n".join(descriptions)
        field = EmbedField(name="The following powerups are active:",
                           value=content)

        embed = Embed(
            title="Event of the day",
            color=Color.random().value,
            thumbnail=EmbedImageStruct(url=Constants.PIBOU4STONKS_URL)._json,
            fields=[field])
        return embed
Пример #10
0
def get_embed_store_ui():
    """
  Returns an embed message corresponding to the store message
  --
  output:
    embed: interactions.Embed
  """
    fields = []
    for emoji, powerup in Constants.POWERUPS_STORE.items():
        fields.append(
            EmbedField(name=emoji, value=powerup.get_store_str(), inline=True))

    embed = Embed(title="Piflouz shop",
                  description="Here you can buy useful upgrades!",
                  color=Color.dark_magenta().value,
                  fields=fields)

    return embed
Пример #11
0
    async def get_embed_raffle(self, bot):
        """
    Returns an embed message corresponding to the raffle message
    --
    input:
      bot: interactions.Client
    """
        desc = f"Here is the new raffle! Use `/raffle n` to buy `n` 🎟️!\n\
    They cost {self.ticket_price} {Constants.PIFLOUZ_EMOJI} each\n\
    The user with the winning ticket will earn {100 - self.tax_ratio}% of the total money spent by everyone!"

        fields = []

        if "raffle_participation" in db.keys() and len(
                db["raffle_participation"]) > 0:
            participation = db["raffle_participation"]

            async def get_str(key_val):
                user_id, nb_tickets = key_val
                return f"<@{user_id}> - {nb_tickets}\n"

            tasks = [get_str(key_val) for key_val in participation.items()]
            res = await asyncio.gather(*tasks)
            val = "".join(res)

            total_prize = self.get_raffle_total_prize()

            fields.append(
                EmbedField(name="Current 🎟️ bought", value=val, inline=False))
            fields.append(
                EmbedField(
                    name="Total prize",
                    value=
                    f"The winner will earn {total_prize} {Constants.PIFLOUZ_EMOJI}!",
                    inline=False))

        embed = Embed(
            title="New Raffle!",
            description=desc,
            color=Color.random().value,
            thumbnail=EmbedImageStruct(url=Constants.PIBOU4STONKS_URL)._json,
            fields=fields)

        return embed
Пример #12
0
async def get_embed_end_season(bot):
    """
  Returns an embed announcing the end of a season
  --
  output:
    embed: interactions.Embed
  """
    channel = await bot.get_channel(db["out_channel"])
    msg = await channel.get_message(db["piflouz_message_id"])
    url = f"https://discord.com/channels/{channel.guild_id}/{channel.id}/{msg.id}"
    print(url)

    embed = Embed(
        title="The season is over!",
        description=
        f"The last season has ended! Use the `/seasonresults` to see what you earned. Congratulations to every participant!\nThe final rankings are available [here]({url})",
        color=Color.purple().value,
        thumbnail=EmbedImageStruct(
            url=Constants.TURBO_PIFLOUZ_ANIMATED_URL)._json)

    return embed
Пример #13
0
def get_embed_piflex(user):
    """
  Returns an embed message corresponding to the piflex message
  --
  input:
    user: user -> the user requesting the piflex
  --
  output:
    embed: interactions.Embed
    index: int -> index of the image/gif
  """
    index = random.randrange(0, len(Constants.PIFLEX_IMAGES_URL))
    image_url = Constants.PIFLEX_IMAGES_URL[index]

    embed = Embed(
        title="PIFLEX",
        description=
        f"Look how much piflouz {user.mention} has. So much piflouz that they are flexing on you poor peasants! They are so cool and rich that they can just take a bath in piflouz. You mad?",
        color=Color.gold().value,
        thumbnail=EmbedImageStruct(url=Constants.PIBOU4STONKS_URL)._json,
        image=EmbedImageStruct(url=image_url)._json)

    print(f"Piflex with {image_url}")
    return embed, index
Пример #14
0
def get_embed_help_message():
    """
  Returns the embed message with help for every command
  --
  output:
    embed: interactions.Embed -> the embeded message
  """
    embed = Embed(
        title="Need help?",
        color=Color.red().value,
        thumbnail=EmbedImageStruct(url=Constants.PIBOU4LOVE_URL)._json,
        fields=[
            EmbedField(name="`/help`", value="Show this message", inline=True),
            EmbedField(name="`/hello`", value="Say hi!", inline=True),
            EmbedField(name="`/is-live streamer_name`",
                       value="Check if a certain streamer is live!",
                       inline=True),
            EmbedField(name="`/setup-channel [twitch|main]`",
                       value="Change the channel where I send messages",
                       inline=True),
            EmbedField(
                name="`/joke`",
                value=
                "To laugh your ass off (or not, manage your expectations)",
                inline=True),
            EmbedField(name="`/donate @user amount`",
                       value="Be generous to others",
                       inline=True),
            EmbedField(
                name="`/balance [@user]`",
                value=f"Check how many {Constants.PIFLOUZ_EMOJI} the user has",
                inline=True),
            EmbedField(
                name="`/cooldown`",
                value="When your addiction is stronger than your sense of time",
                inline=True),
            EmbedField(name="`/get`", value="For the lazy ones", inline=True),
            EmbedField(
                name="`/piflex`",
                value=
                f"When you have too many {Constants.PIFLOUZ_EMOJI}\n ⚠️ Costs {Constants.PIFLEX_COST} {Constants.PIFLOUZ_EMOJI}",
                inline=True),
            EmbedField(
                name="`/buy-rank-piflex`",
                value=
                f"Flex with a custom rank\n ⚠️ Costs {Constants.PIFLEXER_COST} {Constants.PIFLOUZ_EMOJI}, lasts for {utils.seconds_to_formatted_string(Constants.PIFLEXROLE_DURATION)}",
                inline=True),
            EmbedField(name="`$tarpin`",
                       value="What could that be? Can be used in any channel",
                       inline=True),
            EmbedField(
                name="`/pilord`",
                value="See how much you need to farm to flex with your rank",
                inline=True),
            EmbedField(
                name="`/raffle n`",
                value=
                "Buy raffle tickets to test your luck ⚠️ Only works during a raffle event ",
                inline=True),
            EmbedField(name="`/store`", value="Buy fun upgrades", inline=True),
            EmbedField(name="`/powerups`",
                       value="See how powerful you are",
                       inline=True),
            EmbedField(name="`/giveaway n`",
                       value="Drop a pibox with your own money",
                       inline=True),
            EmbedField(
                name="`duel [accept|deny|challenge|cancel|play|status]`",
                value="Earn piflouz by winning challenges against others",
                inline=True),
            EmbedField(name="`/ranking`",
                       value="Check how worthy you are",
                       inline=True),
            EmbedField(name="`/role [get|remove]`",
                       value="Get a specific notification role",
                       inline=True),
            EmbedField(name="`/season-result`",
                       value="Check how good you were last season",
                       inline=True),
            EmbedField(
                name="`/achievements list`",
                value="Check what you need to do to get some achievements",
                inline=True),
            EmbedField(
                name="`/wordle guess`",
                value=
                "Try to solve today's wordle ⚠️ Only works during raffle events",
                inline=True),
            EmbedField(
                name="`/wordle status`",
                value=
                "Check how your wordle is going ⚠️ Only works during raffle events",
                inline=True),
            EmbedField(
                name="`/birthday`",
                value=
                "Check how your baking skills are going ⚠️ Only works during birthday events",
                inline=True),
            EmbedField(
                name="Things I do in the background",
                value=
                f"- I will send a message everytime the greatest streamers go live on Twitch\n\
- I can give you {Constants.PIFLOUZ_EMOJI} if you click on the button below the piflouz message\n\
- I spawn random gifts from time to time. Be the first to react to earn more {Constants.PIFLOUZ_EMOJI}\n\
- I update the roles\n\
- I create events every day\n\
- I send a cute otter picture everyday",
                inline=False),
        ])

    return embed