コード例 #1
0
    async def work(self, ctx):
        isSuccessful = random.choice([True, False, True, False, True, False])
        amount = int(random.randint(15, 50) * random.uniform(0.95, 2.95))

        embed = libneko.Embed(
            title=
            f"Work {'Successful <:le:808638475229986876>' if isSuccessful else 'Failed <:nogis:808638474646978560>'}"
        )

        if isSuccessful:
            embed.color = random.choice(
                [Color.green(), Color.blue(),
                 Color.blurple()])
            embed.add_field(name="Outcome:",
                            value=random.choice(
                                workOutcome[isSuccessful]).format(
                                    ctx.author, amount))
            await self.bot.eco.edit_money(ctx.author.id, amount, "wallet",
                                          "add")
        else:
            embed.color = random.choice(
                [Color.red(), Color.orange(), 0xffff00])
            embed.add_field(name="Outcome:",
                            value=random.choice(
                                workOutcome[isSuccessful]).format(ctx.author))
        embed.set_footer(icon_url=str(ctx.author.avatar_url),
                         text=f"Invoked by {ctx.author}")

        try:
            await ctx.send(f"{ctx.author.mention}", embed=embed)
        except discord.errors.Forbidden:
            await ctx.send(
                f"{ctx.author.mention}, I am unable to send the requested data! Please grant the bot the \"Embed Links\" permission or ask an admin / moderator to do so."
            )
コード例 #2
0
ファイル: colors.py プロジェクト: cephox/bettermod
class Colors:
    red = Color.red()
    orange = Color.orange()

    default = Color(0x006e7a)
    log_channel = Color(0x6203fc)

    permission = Color(0x2f9c00)

    error = Color(0xff0000)
    warning = Color(0xffd500)

    @staticmethod
    def member(member: Member):
        return member.color