Exemplo n.º 1
0
    async def ddb(self, ctx):
        """Displays information about your D&D Beyond account link."""
        ddb_user = await self.bot.ddb.get_ddb_user(ctx, ctx.author.id)
        embed = embeds.EmbedWithAuthor(ctx)

        if ddb_user is None:
            embed.title = "No D&D Beyond account connected."
            embed.description = \
                "It looks like you don't have your Discord account connected to your D&D Beyond account!\n" \
                "Linking your account means that you'll be able to use everything you own on " \
                "D&D Beyond in Avrae for free - you can link your accounts " \
                "[here](https://www.dndbeyond.com/account)."
            embed.set_footer(text="Already linked your account? It may take up to 15 minutes for Avrae to recognize "
                                  "the link.")
            return await ctx.send(embed=embed)

        embed.title = f"Hello, {ddb_user.username}!"
        embed.url = "https://www.dndbeyond.com/account"
        default_desc = f"Thanks for linking your account! We'll reach out to you when the purchases you've made " \
                       f"on D&D Beyond are available in Avrae."

        desc = await self.bot.ldclient.variation("command.ddb.desc", ddb_user.to_ld_dict(), default_desc)
        embed.description = desc

        if ddb_user.is_staff:
            embed.set_footer(
                text="Official D&D Beyond Staff",
                icon_url="https://media-waterdeep.cursecdn.com/avatars/thumbnails/104/378/32/32/636511944060210307.png")
        elif ddb_user.is_insider:
            embed.set_footer(text="Thanks for being a D&D Beyond Insider.")

        await ctx.send(embed=embed)
Exemplo n.º 2
0
    async def campaign(self, ctx, campaign_link=None):
        """
        Links a D&D Beyond campaign to this channel, displaying rolls made on players' character sheets in real time.

        You must be the DM of the campaign to link it to a channel.

        Not seeing a player's rolls? Link their D&D Beyond and Discord accounts [here](https://www.dndbeyond.com/account), and check with the `!ddb` command!
        """
        if campaign_link is None:
            return await self.campaign_list(ctx)

        link_match = re.match(
            r'(?:https?://)?(?:www\.)?dndbeyond\.com/campaigns/(\d+)(?:$|/)',
            campaign_link)
        if link_match is None:
            return await ctx.send("This is not a D&D Beyond campaign link.")
        campaign_id = link_match.group(1)

        # is there already an existing link?
        try:
            existing_link = await CampaignLink.from_id(self.bot.mdb,
                                                       campaign_id)
        except NoCampaignLink:
            existing_link = None

        if existing_link is not None and existing_link.channel_id == ctx.channel.id:
            return await ctx.send(
                "This campaign is already linked to this channel.")
        elif existing_link is not None:
            result = await confirm(
                ctx,
                "This campaign is already linked to another channel. Link it to this one instead?"
            )
            if not result:
                return await ctx.send("Ok, canceling.")
            await existing_link.delete(ctx.bot.mdb)

        # do link (and dm check)
        await ctx.trigger_typing()
        result = await self.bot.glclient.create_campaign_link(ctx, campaign_id)
        embed = embeds.EmbedWithAuthor(ctx)
        embed.title = f"Linked {result.campaign_name}!"
        embed.description = (
            f"Linked {result.campaign_name} to this channel! Your players' rolls from D&D Beyond "
            f"will show up here, and checks, saves, and attacks made by characters in your campaign "
            f"here will appear in D&D Beyond!")
        embed.add_field(
            name="Not Seeing Rolls?",
            value=
            f"Not seeing one or more of your players' rolls? Make sure their [D&D Beyond "
            f"and Discord accounts are linked](https://www.dndbeyond.com/account) and their "
            f"[characters are imported](https://avrae.readthedocs.io/en/stable/cheatsheets/get_started.html#step-2-add-a-character)! "
            f"You can check your players' link status with `{ctx.prefix}ddb`.")
        await ctx.send(embed=embed)
Exemplo n.º 3
0
    async def ddb(self, ctx):
        """Displays information about your D&D Beyond account link."""
        ddb_user = await self.bot.ddb.get_ddb_user(ctx, ctx.author.id)
        embed = embeds.EmbedWithAuthor(ctx)

        if ddb_user is None:
            embed.title = "No D&D Beyond account connected."
            embed.description = \
                "It looks like you don't have your Discord account connected to your D&D Beyond account!\n" \
                "Linking your account means that you'll be able to use everything you own on " \
                "D&D Beyond in Avrae for free - you can link your accounts " \
                "[here](https://www.dndbeyond.com/account)."
            embed.add_field(
                name="Having trouble?",
                value=
                (f"On occasion, the first time you link your Discord and D&D Beyond accounts, "
                 f"Discord may use a temporary account that differs from your actual account. "
                 f"If your accounts appear linked, but this command says they are not, compare "
                 f"the numbers at the end of your Discord username to the numbers displayed in "
                 f"the [D&D Beyond Account Settings](https://www.dndbeyond.com/account). For "
                 f"this account, `{ctx.author!s}`, they should be `{ctx.author.discriminator}`. "
                 f"If they do not match, unlink the account, and try again."))

            embed.set_footer(
                text=
                "Already linked your account? It may take up to 15 minutes for Avrae to recognize "
                "the link.")
            return await ctx.send(embed=embed)

        embed.title = f"Hello, {ddb_user.username}!"
        embed.url = "https://www.dndbeyond.com/account"
        default_desc = f"Thanks for linking your account! We'll reach out to you when the purchases you've made " \
                       f"on D&D Beyond are available in Avrae."

        desc = await self.bot.ldclient.variation("command.ddb.desc",
                                                 ddb_user.to_ld_dict(),
                                                 default_desc)
        embed.description = desc

        if ddb_user.is_staff:
            embed.set_footer(
                text="Official D&D Beyond Staff",
                icon_url=
                "https://media-waterdeep.cursecdn.com/avatars/thumbnails/104/378/32/32/636511944060210307.png"
            )
        elif ddb_user.is_insider:
            embed.set_footer(text="Thanks for being a D&D Beyond Insider.")

        await ctx.send(embed=embed)
Exemplo n.º 4
0
    async def embed(self, ctx, *, args):
        """Creates and prints an Embed.
        __Valid Arguments__
        -title <title>
        -desc <description text>
        -thumb <image url>
        -image <image url>
        -footer <footer text>
        -f "<Field Title>|<Field Text>[|inline]"
            (e.g. "Donuts|I have 15 donuts|inline" for an inline field, or "Donuts|I have 15 donuts" for one with its own line.)
        -color <hex color>
        -t <timeout (0..600)>
        """
        try:
            await ctx.message.delete()
        except:
            pass

        embed = embeds.EmbedWithAuthor(ctx)
        args = argparse(args)
        embed.title = args.last('title')
        embed.description = args.last('desc')
        embed.set_thumbnail(url=args.last('thumb', '') if 'http' in
                            str(args.last('thumb')) else '')
        embed.set_image(url=args.last('image', '') if 'http' in
                        str(args.last('image')) else '')
        embed.set_footer(text=args.last('footer', ''))
        try:
            embed.colour = int(args.last('color', "0").strip('#'), base=16)
        except:
            pass

        embeds.add_fields_from_args(embed, args.get('f'))

        timeout = 0
        if 't' in args:
            try:
                timeout = min(max(args.last('t', type_=int), 0), 600)
            except:
                pass

        if timeout:
            await ctx.send(embed=embed, delete_after=timeout)
        else:
            await ctx.send(embed=embed)
Exemplo n.º 5
0
 async def campaign_list(self, ctx):
     """Lists all campaigns connected to this channel."""
     existing_links = await CampaignLink.get_channel_links(ctx)
     if not existing_links:
         return await ctx.send(
             f"This channel is not linked to any D&D Beyond campaigns. "
             f"Use `{ctx.prefix}campaign https://www.dndbeyond.com/campaigns/...` to have "
             f"your and your players' rolls show up here in real time!")
     embed = embeds.EmbedWithAuthor(ctx)
     embed.title = "D&D Beyond Campaign Links"
     embed.description = (
         f"This channel is linked to {len(existing_links)} "
         f"{'campaign' if len(existing_links) == 1 else 'campaigns'}:\n"
         f"{', '.join(cl.campaign_name for cl in existing_links)}")
     embed.add_field(
         name="Not Seeing Rolls?",
         value=
         f"Not seeing one or more of your players' rolls? Make sure their [D&D Beyond "
         f"and Discord accounts are linked](https://www.dndbeyond.com/account) and their "
         f"[characters are imported](https://avrae.readthedocs.io/en/stable/cheatsheets/get_started.html#step-2-add-a-character)! "
         f"You can check your players' link status with `{ctx.prefix}ddb`.")
     await ctx.send(embed=embed)