Beispiel #1
0
    async def tome(self, ctx, *, name=None):
        """Commands to manage homebrew spells.
        When called without an argument, lists the current tome and its description.
        When called with a name, switches to a different tome."""
        user_tomes = await self.bot.mdb.tomes.count_documents(
            Tome.view_query(str(ctx.author.id)))

        if not user_tomes:
            return await ctx.send(
                "You have no tomes. You can make one at <https://avrae.io/dashboard/homebrew/spells>!"
            )

        if name is None:
            tome = await Tome.from_ctx(ctx)
        else:
            try:
                tome = await select_tome(ctx, name)
            except NoActiveBrew:
                return await ctx.send(
                    "You have no tomes. You can make one at <https://avrae.io/dashboard/homebrew/spells>!"
                )
            except NoSelectionElements:
                return await ctx.send("Tome not found.")
            await tome.set_active(ctx)
        embed = HomebrewEmbedWithAuthor(ctx)
        embed.title = tome.name
        embed.description = tome.desc
        if tome.image:
            embed.set_thumbnail(url=tome.image)
        spellnames = "\n".join(i.name for i in tome.spells)
        if len(spellnames) < 1020:
            embed.add_field(name="Spells", value=spellnames)
        else:
            embed.add_field(name="Spells", value=f"{len(tome.spells)} spells.")
        await ctx.send(embed=embed)
Beispiel #2
0
    async def pack(self, ctx, *, name=None):
        """Commands to manage homebrew items.
        When called without an argument, lists the current pack and its description.
        When called with a name, switches to a different pack."""
        user_packs = await self.bot.mdb.packs.count_documents(
            Pack.view_query(str(ctx.author.id)))

        if not user_packs:
            return await ctx.send(
                "You have no packs. You can make one at <https://avrae.io/dashboard/homebrew/items>!"
            )

        if name is None:
            pack = await Pack.from_ctx(ctx)
        else:
            try:
                pack = await select_pack(ctx, name)
            except NoActiveBrew:
                return await ctx.send(
                    "You have no packs. You can make one at <https://avrae.io/dashboard/homebrew/items>!"
                )
            except NoSelectionElements:
                return await ctx.send("Pack not found.")
            await pack.set_active(ctx)
        embed = HomebrewEmbedWithAuthor(ctx)
        embed.title = pack.name
        embed.description = pack.desc
        if pack.image:
            embed.set_thumbnail(url=pack.image)
        itemnames = "\n".join(i['name'] for i in pack.items)
        if len(itemnames) < 1020:
            embed.add_field(name="Items", value=itemnames)
        else:
            embed.add_field(name="Items", value=f"{len(pack.items)} items.")
        await ctx.send(embed=embed)