Beispiel #1
0
    async def token(self, ctx, *, name=None):
        """Shows a token for a monster or player. May not support all monsters."""

        if name is None:
            token_cmd = self.bot.get_command('playertoken')
            if token_cmd is None:
                return await self.bot.say("Error: SheetManager cog not loaded."
                                          )
            return await ctx.invoke(token_cmd)

        try:
            guild_id = ctx.message.server.id
            srd = self.settings.get(guild_id, {}).get("srd", False)
        except:
            srd = False
        monster = await select_monster_full(ctx, name, srd=srd)

        if not monster.srd and srd:
            e = EmbedWithAuthor(ctx)
            e.title = monster.name
            e.description = "Token not available."
            return await self.bot.say(embed=e)

        url = monster.get_image_url()

        if not monster.source == 'homebrew':
            embed = EmbedWithAuthor(ctx)
            embed.title = monster.name
            embed.description = f"{monster.size} monster."
            embed.set_image(url=url)
            embed.set_footer(text="This command may not support all monsters.")

            await self.bot.say(embed=embed)
        else:
            if not url:
                return await self.bot.send_message(
                    ctx.message.channel, "This monster has no image.")

            try:
                processed = await generate_token(url)
            except Exception as e:
                return await self.bot.send_message(
                    ctx.message.channel, f"Error generating token: {e}")

            await self.bot.send_file(
                ctx.message.channel,
                processed,
                content="I generated this token for you! If it seems "
                "wrong, you can make your own at "
                "<http://rolladvantage.com/tokenstamp/>!",
                filename="image.png")
Beispiel #2
0
    async def token(self, ctx, name=None, *args):
        """
        Shows a monster or your character's token.
        __Valid Arguments__
        -border <plain|none (player token only)> - Overrides the token border.
        """
        if name is None or name.startswith('-'):
            token_cmd = self.bot.get_command('playertoken')
            if token_cmd is None:
                return await ctx.send("Error: SheetManager cog not loaded.")
            if name:
                args = (name, *args)
            return await ctx.invoke(token_cmd, *args)

        # select monster
        choices = await get_monster_choices(ctx, filter_by_license=False)
        monster = await self._lookup_search3(ctx, {'monster': choices}, name)
        await Stats.increase_stat(ctx, "monsters_looked_up_life")

        # select border
        ddb_user = await self.bot.ddb.get_ddb_user(ctx, ctx.author.id)
        is_subscriber = ddb_user and ddb_user.is_subscriber
        token_args = argparse(args)

        if monster.homebrew:
            # homebrew: generate token
            if not monster.get_image_url():
                return await ctx.send("This monster has no image.")
            try:
                image = await img.generate_token(monster.get_image_url(),
                                                 is_subscriber, token_args)
            except Exception as e:
                return await ctx.send(f"Error generating token: {e}")
        else:
            # official monsters
            token_url = monster.get_token_url(is_subscriber)
            if token_args.last('border') == 'plain':
                token_url = monster.get_token_url(False)

            if not token_url:
                return await ctx.send("This monster has no image.")

            image = await img.fetch_monster_image(token_url)

        embed = EmbedWithAuthor(ctx)
        embed.title = monster.name
        embed.description = f"{monster.size} monster."

        file = discord.File(image, filename="image.png")
        embed.set_image(url="attachment://image.png")
        await ctx.send(embed=embed, file=file)
Beispiel #3
0
    async def monimage(self, ctx, *, name):
        """Shows a monster's image."""
        choices = await get_monster_choices(ctx, filter_by_license=False)
        monster = await self._lookup_search3(ctx, {'monster': choices}, name)
        await Stats.increase_stat(ctx, "monsters_looked_up_life")

        url = monster.get_image_url()
        embed = EmbedWithAuthor(ctx)
        embed.title = monster.name
        embed.description = f"{monster.size} monster."

        if not url:
            return await ctx.channel.send("This monster has no image.")

        embed.set_image(url=url)
        await ctx.send(embed=embed)
Beispiel #4
0
    async def token(self, ctx, *, name=None):
        """Shows a token for a monster or player. May not support all monsters."""

        if name is None:
            token_cmd = self.bot.get_command('playertoken')
            if token_cmd is None:
                return await ctx.send("Error: SheetManager cog not loaded.")
            return await ctx.invoke(token_cmd)

        guild_settings = await self.get_settings(ctx.guild)
        srd = guild_settings.get("srd", False)

        monster, metadata = await select_monster_full(ctx, name, srd=srd, return_metadata=True)

        metadata['srd'] = srd
        metadata['homebrew'] = monster.source == 'homebrew'
        await self.add_training_data("monster", name, monster.name, metadata=metadata)

        if not monster.srd and srd:
            e = EmbedWithAuthor(ctx)
            e.title = monster.name
            e.description = "Token not available."
            return await ctx.send(embed=e)

        url = monster.get_image_url()

        if not monster.source == 'homebrew':
            embed = EmbedWithAuthor(ctx)
            embed.title = monster.name
            embed.description = f"{monster.size} monster."
            embed.set_image(url=url)
            embed.set_footer(text="This command may not support all monsters.")

            await ctx.send(embed=embed)
        else:
            if not url:
                return await ctx.channel.send("This monster has no image.")

            try:
                processed = await generate_token(url)
            except Exception as e:
                return await ctx.channel.send(f"Error generating token: {e}")

            file = discord.File(processed, filename="image.png")
            await ctx.channel.send("I generated this token for you! If it seems  wrong, you can make your own at "
                                   "<http://rolladvantage.com/tokenstamp/>!", file=file)
Beispiel #5
0
    async def token(self, ctx, *, name=None):
        """Shows a token for a monster or player. May not support all monsters."""

        if name is None:
            token_cmd = self.bot.get_command('playertoken')
            if token_cmd is None:
                return await ctx.send("Error: SheetManager cog not loaded.")
            return await ctx.invoke(token_cmd)

        monster, metadata = await select_monster_full(ctx,
                                                      name,
                                                      return_metadata=True)

        metadata['homebrew'] = monster.source == 'homebrew'
        await self.add_training_data("monster",
                                     name,
                                     monster.name,
                                     metadata=metadata)

        url = monster.get_image_url()
        embed = EmbedWithAuthor(ctx)
        embed.title = monster.name
        embed.description = f"{monster.size} monster."

        if not monster.source == 'homebrew':
            embed.set_image(url=url)
            embed.set_footer(text="This command may not support all monsters.")

            await ctx.send(embed=embed)
        else:
            if not url:
                return await ctx.channel.send("This monster has no image.")

            try:
                processed = await generate_token(url)
            except Exception as e:
                return await ctx.channel.send(f"Error generating token: {e}")

            file = discord.File(processed, filename="image.png")
            embed.set_image(url="attachment://image.png")
            await ctx.send(file=file, embed=embed)
Beispiel #6
0
    async def token(self, ctx, *, name=None):
        """Shows a monster's image."""

        if name is None:
            token_cmd = self.bot.get_command('playertoken')
            if token_cmd is None:
                return await ctx.send("Error: SheetManager cog not loaded.")
            return await ctx.invoke(token_cmd)

        choices = await get_monster_choices(ctx, filter_by_license=False)
        monster = await self._lookup_search3(ctx, {'monster': choices}, name)
        await Stats.increase_stat(ctx, "monsters_looked_up_life")

        url = monster.get_image_url()
        embed = EmbedWithAuthor(ctx)
        embed.title = monster.name
        embed.description = f"{monster.size} monster."

        if not url:
            return await ctx.channel.send("This monster has no image.")

        embed.set_image(url=url)
        await ctx.send(embed=embed)