Exemple #1
0
    async def findanime(self, ctx):
        """Find a random anime picture."""
        subreddit = await self.reddit.hot("animereactionimages")
        posts = subreddit.posts
        submission = choice([post for post in posts if not post.is18])

        e = embedDefault(
            ctx,
            author_pos="bottom",
            title=f"{subreddit} - {submission.title}",
            colour=discord.Colour(0xFF4500),
        )
        e.set_author(
            name="Reddit",
            icon_url="https://www.redditstatic.com/desktop2x/" +
            "img/favicon/android-icon-192x192.png",
        )
        e.add_field(name="Score", value=submission.score)
        e.add_field(name="Comments", value=submission.commentCount)

        if submission.url:
            if not submission.isVideo:
                e.set_image(url=submission.url)
            else:
                await ctx.send(embed=e)
                await ctx.send(submission.url)
                return

        await ctx.send(embed=e)
Exemple #2
0
    async def permissions(self, ctx, anyRoleMember: Union[discord.Member,
                                                          discord.Role]):
        """Get member/role's permission."""
        def format_text(text: str):
            return "`{}`".format(text.replace("_", " ").title())

        if isinstance(anyRoleMember, discord.Member):
            perms = {p[0]: p[1] for p in anyRoleMember.guild_permissions}
        if isinstance(anyRoleMember, discord.Role):
            perms = {p[0]: p[1] for p in anyRoleMember.permissions}

        if perms["administrator"]:
            perms = {"administrator": True}

        e = embedDefault(
            ctx,
            title="{}'s Permissions".format(anyRoleMember.name),
            colour=discord.Colour.rounded(),
        )
        if isinstance(anyRoleMember, discord.Member):
            e.set_thumbnail(url=anyRoleMember.avatar_url)
        e.add_field(
            name="Permissions",
            value=", ".join(
                [format_text(perm) for perm in perms if perms[perm]]),
        )
        return await ctx.send(embed=e)
Exemple #3
0
 async def weather_zip(self, ctx, _zip):
     """Show weather report from a zip code."""
     try:
         weatherData = await self.openweather.get_from_zip(_zip)
     except CityNotFound as err:
         e = embedError(err)
         return await ctx.reply(embed=e)
     e = embedDefault(
         ctx,
         title="{}, {}".format(weatherData.city, weatherData.country),
         description="Feels like {}°C, {}".format(
             weatherData.tempFeels.celcius, weatherData.weatherDetail),
         color=discord.Colour(0xEA6D4A),
     )
     e.set_author(
         name="OpenWeather",
         icon_url=
         "https://openweathermap.org/themes/openweathermap/assets/vendor/owm/img/icons/logo_60x60.png",
     )
     e.add_field(name="Temperature",
                 value="{}°C".format(weatherData.temp.celcius))
     e.add_field(name="Humidity", value=weatherData.humidity)
     e.add_field(name="Wind", value=str(weatherData.wind))
     e.set_thumbnail(url=weatherData.iconUrl)
     await ctx.send(embed=e)
Exemple #4
0
    async def barter(self, ctx, gold: int = 64):
        """Barter with Minecraft's Piglin. (Based on JE 1.16.1, before nerf)"""
        # limit gold amount up to 2240 (Minecraft inventory limit)
        if gold > 2240:
            gold = 2240
        if gold <= 0:
            gold = 1

        trade = Piglin(gold)

        items = {}
        for item in trade.items:
            try:
                items[item.name][1] += item.quantity
            except KeyError:
                items[item.name] = [item.id, item.quantity]

        def emoji(name: str):
            return {
                "enchanted-book": "<:enchantedbook:807261766065192971>",
                "iron-boots": "<:ironboots:807261701363597322>",
                "iron-nugget": "<:ironnugget:807261807601385473>",
                "splash-potion-fire-res":
                "<:splashpotionfireres:807261948017377300>",
                "potion-fire-res": "<:potionfireres:807262044478504967>",
                "quartz": "<:quartz:807262092032999484>",
                "glowstone-dust": "<:glowstonedust:807262151826735105>",
                "magma-cream": "<:magmacream:807262199684005918>",
                "ender-pearl": "<:enderpearl:807261299817709608>",
                "string": "<:string:807262264381014086>",
                "fire-charge": "<:firecharge:807262322522718219>",
                "gravel": "<:gravel3D:807535983448948766>",
                "leather": "<:leather:807262494619860993>",
                "nether-brick": "<:netherbricks3D:807536302365999114>",
                "obsidian": "<:obsidian3D:807536509837770762>",
                "cry-obsidian": "<:cryobsidian3D:807536510152474644>",
                "soul-sand": "<:soulsand3D:807536744253227049>",
            }.get(name, "<:missingtexture:807536928361545729>")

        e = embedDefault(
            ctx,
            author_pos="top",
            title="Bartering with {} gold{}".format(gold,
                                                    "s" if gold > 1 else ""),
            description="You got:\n\n{}".format("\n".join([
                "{} → {}".format(emoji(v[0]), v[1]) for v in items.values()
            ])),
            colour=discord.Colour.gold(),
        )
        await ctx.send(embed=e)
Exemple #5
0
    async def meme(self, ctx):
        """Get memes from subreddit r/memes."""
        self.bot.c.execute("SELECT meme_ch FROM servers WHERE id=?",
                           (str(ctx.guild.id), ))
        meme_channel = self.bot.get_channel(int(self.bot.c.fetchone()[0] or 0))
        if not meme_channel:
            meme_channel = ctx.channel

        if ctx.channel != meme_channel:
            return await ctx.send(
                f"Please do this command in {meme_channel.mention}")

        memeSubreddits = ["memes", "funny"]
        subreddit = await self.reddit.hot(choice(memeSubreddits))
        posts = subreddit.posts
        submission = choice([post for post in posts if not post.is18])

        e = embedDefault(
            ctx,
            author_pos="bottom",
            title=f"{subreddit} - {submission.title}",
            colour=discord.Colour(0xFF4500),
        )
        e.set_author(
            name="Reddit",
            icon_url="https://www.redditstatic.com/desktop2x/" +
            "img/favicon/android-icon-192x192.png",
        )
        e.add_field(name="Score", value=submission.score)
        e.add_field(name="Comments", value=submission.commentCount)

        if submission.url:
            if not submission.isVideo:
                e.set_image(url=submission.url)
            else:
                await meme_channel.send(embed=e)
                await meme_channel.send(submission.url)
                return

        await ctx.send(embed=e)
Exemple #6
0
    async def findseed(self, ctx):
        """Test your luck in Minecraft but visual."""
        if ctx.guild.id in self.bot.norules:
            ctx.command.reset_cooldown(ctx)

        emojis = {
            "{air}": "<:empty:754550188269633556>",
            "{frame}": "<:portal:754550231017979995>",
            "{eye}": "<:eye:754550267382333441>",
            "{end_portal}": "<:endPortal:800191496598978560>",
            "{lava}": "<a:lavaAnimated:800215203614031892>",
        }

        eyes = [
            "{eye}" if randint(1, 10) == 1 else "{frame}" for i in range(12)
        ]
        eye_count = sum([1 for i in eyes if i == "{eye}"])

        # rig stuff
        # rig is capped at 12 no matter what
        rigged = {518154918276628490: 12}
        if ctx.author.id in rigged:
            rig = rigged[ctx.author.id]
            # cap rig
            if rig >= 12:
                eye_count, rig = (12, ) * 2
                eyes = ["{eye}"] * 12
            elif rig <= 0:
                eye_count, rig = (0, ) * 2
                eyes = ["{frame}"] * 12
            # rig loop
            while eye_count != rig:
                for i in range(len(eyes)):
                    if eye_count == rig:
                        break
                    if (eyes[i] == "{frame}" and randint(1, 10) == 1
                            and (eye_count < rig and eye_count != rig)):
                        eyes[i] = "{eye}"
                        eye_count += 1
                    elif eyes[i] == "{eye}" and (eye_count > rig
                                                 and eye_count != rig):
                        eyes[i] = "{frame}"
                        eye_count -= 1

        # "render" portal
        sel_eye = 0
        portalframe = ""
        for row in range(5):
            for col in range(5):
                if ((col == 0 or col == 4) and
                    (row != 0 and row != 4)) or ((row == 0 or row == 4) and
                                                 (col > 0 and col < 4)):
                    sel_eye += 1
                    portalframe += eyes[sel_eye - 1]
                elif (col != 0 or col != 4) and (col > 0 and col < 4):
                    portalframe += "{end_portal}" if eye_count >= 12 else "{lava}"
                else:
                    portalframe += "{air}"
            portalframe += "\n"

        # replace placeholder with portal frame emoji
        for placeholder in emojis.keys():
            portalframe = portalframe.replace(placeholder, emojis[placeholder])

        e = embedDefault(
            ctx,
            author_pos="top",
            title="findseed",
            description=
            f"Your seed is a **{eye_count}** eye: \n\n{portalframe}",
            color=discord.Colour(0x38665E),
        )
        await ctx.send(embed=e)