therealguy90 / foundrytodiscord

A FoundryVTT module that sends all FoundryVTT messages to a Discord webhook.
https://ko-fi.com/loki123
MIT License
15 stars 2 forks source link

Attack rolls broken using midi-qol BETA #26

Closed dcode closed 9 months ago

dcode commented 9 months ago

Thanks for your work on this plugin. I know maintaining open source isn't easy. I'm raising this to hopefully save you some time with the yet unreleased midi-qol plugin.

Describe the bug

I'm using the latest beta install of midi-qol and attack rolls aren't getting picked up by this plugin. I'm also using the DnD 3.0.3 game system. I'm using Foundry to Discord 1.9.0.

A clear and concise description of what the bug is. Before answering the questions on this template, are you on the latest release of this module?

To Reproduce Steps to reproduce the behavior:

  1. Using latest DnD game system (3.0.3), beta midi-qol, and latest foundry to discord plugin, make an attack.
  2. Attempt to manually send attack card to discord by clicking 3 dots and "send (main webhook)".
  3. Discord will not receive a webhook, check developer console on Foundry page to observe error.

Expected behavior I expected the rolls would get pushed to discord the same as when I roll initiative or a saving throw.

Screenshots This is the card I try to manually send, HTML below.

image

Additional context

Stack trace in console when I right-click on a roll and click Send (Main Webhook):

generic.mjs:214 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'texture')
    at generateDiscordAvatar (generic.mjs:214:26)
    at Module.getRequestParams (generic.mjs:102:20)
    at messageParserDnD5e (dnd5e.mjs:76:20)
    at async tryPOST (main.js:371:25)
    at async Object.callback (main.js:35:17)
generateDiscordAvatar @ generic.mjs:214
getRequestParams @ generic.mjs:102
messageParserDnD5e @ dnd5e.mjs:76
await in messageParserDnD5e (async)
#onClickItem @ foundry.js:64986
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2

list item in chat that I tried to send:

<li class="chat-message message flexcol" data-message-id="oJovTbV1prLWYxt4" style="position: relative;">
    <header class="message-header flexrow">
        <h4 class="message-sender"><div class="avatar"><img src="ddb-images/characters/104310930-Balrin-Drovos.jpeg" alt="Balrin Drovos"></div><span class="name-stacked"><span class="title">Balrin Drovos</span><span class="subtitle">dcode</span></span></h4>
        <span class="message-metadata">
            <time class="message-timestamp">9h ago</time>
        <a aria-label="Additional Controls" class="chat-control" data-context-menu=""><i class="fas fa-ellipsis-vertical fa-fw"></i></a></span>
    </header>
    <div class="message-content">
        <div class="dnd5e2 chat-card midi-chat-card item-card " data-actor-id="GB65yKqJPqTdf3a6" data-item-id="xZBLL4hpfgRcMfxG" data-actor-uuid="Actor.GB65yKqJPqTdf3a6" data-token-id="Scene.gNQA4XMJVt8Y3FLJ.Token.i66mTX3AXea492zV" data-token-uuid="Scene.gNQA4XMJVt8Y3FLJ.Token.i66mTX3AXea492zV" data-display-challenge="">
  <section class="card-header description collapsible">
    <header class="summary">
      <img class="gold-icon" src="icons/weapons/bows/longbow-leather-green.webp" alt="Longbow">
      <div class="name-stacked border">
        <span class="title">Longbow</span>
        <span class="subtitle">
          Martial Ranged
        </span>
      </div>
      <i class="fas fa-chevron-down fa-fw"></i>
    </header>
    <section class="details collapsible-content card-content" style="height: 0px;">
      <p>Proficiency with a longbow allows you to add your proficiency bonus to the attack roll for any attack you make with it.</p>
    </section>
  </section>
  <div class="card-buttons midi-buttons">
  </div>
  <div class="midi-results">
    <div class="flexrow 2">
      <div class="midi-qol-attack-roll"><div style="text-align:center">Attack</div><div class="midi-attack-roll midi-dice-roll dice-roll">
    <div class="dice-result">
        <div class="dice-formula">1d20 + 3 + 2</div>
        <div class="dice-tooltip" style="height: 0px;">
    <section class="tooltip-part">
        <div class="dice">
            <ol class="dice-rolls">
                <li class="roll die d20">17</li>
            </ol>
            <div class="total">
                <span class="label"></span>
                <span class="value">17</span>
            </div>
        </div>
    </section>
<section class="tooltip-part constant">
      <div class="dice">
        <ol class="dice-rolls"></ol>
        <div class="total">
          <span class="value"><span class="sign">+</span>5</span>
        </div>
      </div>
    </section></div>

        <h4 class="dice-total">22</h4>
    </div>
</div><div class="end-midi-qol-attack-roll"></div>
      </div>
      <div class="midi-qol-damage-roll"><div style="text-align:center">(Piercing)</div>

<div class="end-midi-qol-damage-roll"></div>
      <div class="dice-roll midi-damage-roll">
    <div class="dice-result">
    <div class="dice-formula">1d8[piercing] + 3</div>
        <div class="dice-tooltip" style="height: 0px;">

            <section class="tooltip-part">
                <div class="dice">
                <ol class="dice-rolls">

                    <li class="roll die d8">3</li>

                    <li class="constant"><span class="sign">+</span>3</li>

                </ol>
                <div class="total">
                    <img src="systems/dnd5e/icons/svg/damage/piercing.svg" alt="Piercing">
                    <span class="label">Piercing</span>
                    <span class="value">6</span>
                </div>
                </div>
            </section>

        </div>
        <h4 class="dice-total">6</h4>
    </div>
    </div></div>
    </div>
    <div class="midi-qol-hits-display"><div class="midi-qol-single-hit-card">
  <div class="dnd5e2 evaluation">
  </div>
</div><div class="end-midi-qol-hits-display"></div>
    </div>
    <div class="midi-qol-other-damage-roll">
      <div class="end-midi-qol-other-damage-roll"></div>
    </div>
    <div class="midi-qol-bonus-damage-roll">
      <div class="end-midi-qol-bonus-bonus-roll"></div>
    </div>
    <div class="midi-qol-saves-display">
      <div class="end-midi-qol-saves-display"></div>
    </div>

  </div>

  <ul class="card-footer pills unlist">
    <li class="pill pill-sm">
      <span class="label">1 Action</span>
    </li>
    <li class="pill pill-sm">
      <span class="label">150 / 600 ft</span>
    </li>
    <li class="pill pill-sm">
      <span class="label">Equipped</span>
    </li>
    <li class="pill pill-sm">
      <span class="label">Proficient</span>
    </li>
  </ul>

  <div class="effects-tray collapsible collapsed">
    <label class="roboto-upper">
      <i class="fas fa-bolt"></i>
      <span>Effects</span>
      <i class="fas fa-caret-down"></i>
    </label>
    <ul class="effects collapsible-content unlist" style="height: 0px;"></ul>
  </div>
</div>
    </div>
</li>
therealguy90 commented 9 months ago

Hello, can you try manually cloning the repo and installing the module? I've been holding off on releasing to wait for the next release of midi, but some of the chat cards have already been fixed in the most recent commit. I'm also working on finding any other chat cards that might be broken with the next release.

therealguy90 commented 9 months ago

Also, I noticed the issue you opened in DDB Game Log. I think that's a bug due to DnD 3.x.x and Foundry to Discord not picking up the title correctly. It's a quick fix if you can provide me the formatting for it.

dcode commented 9 months ago

okay, using the latest module.json to import from GitHub, I can manually push the events to discord, but they're not quite right.

image

vs chat log with

image
dcode commented 9 months ago

the gamelog elements for attack and damage, respectivly:

Attack

<li class="chat-message message flexcol visible ddb-game-log-message tohit ddb-game-log-fixHeader" data-message-id="FshQidNeN6oMknNT" data-entity-type="character"><div class="ddb-game-log-avatar-wrapper"><div class="avatar" style="background-image: url(https://is1-ssl.mzstatic.com/image/thumb/Purple114/v4/3c/23/7b/3c237b58-1c61-b5d7-edb7-5737b49858f8/AppIcon-0-0-1x_U007emarketing-0-0-0-5-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/1024x1024bb.png);"></div><header class="message-header flexrow">
        <h4 class="message-sender"><div class="avatar"><img src="ddb-images/characters/104310930-Balrin-Drovos.jpeg" alt="Balrin Drovos"></div><span class="name-stacked"><span class="title">Balrin Drovos</span><span class="subtitle">Gamemaster</span></span></h4>
        <span class="message-metadata">
            <time class="message-timestamp">4m ago</time>

        <a aria-label="Additional Controls" class="chat-control" data-context-menu=""><i class="fas fa-ellipsis-vertical fa-fw"></i></a></span>

        <span class="flavor-text"><span class="action" data-ddb-game-log-click-handler="open_card">Longbow:</span> <span class="rolltype to hit">To hit</span> <span class="rollkind "></span></span>
    </header></div>

    <div class="message-content">
<div class="ddb-game-log-chat-card">
    <hr>
    <header class="ddb-card-header flexrow">
        <img src="icons/weapons/bows/longbow-leather-green.webp" title="Longbow">
        <h3 class="ddb-item-name">Longbow</h3>
    </header>
    <div class="ddb-card-content">
        <p>Proficiency with a longbow allows you to add your proficiency bonus to the attack roll for any attack you make with it.</p>
        <a class="ddb-sheet-link" data-ddb-game-log-entry-id="GB65yKqJPqTdf3a6..xZBLL4hpfgRcMfxG" data-ddb-game-log-entry-type="items" data-ddb-game-log-open-sheet=""><i class="fas fa-link"></i> Open compendium entry</a>
        <a class="ddb-ddb-link" href="https://www.dndbeyond.com/equipment/longbow" target="_blank"><i class="fas fa-external-link-alt"></i> Open on D&amp;D Beyond</a>    
    </div>
</div>

        <div class="dice-roll">
    <div class="dice-result">
        <div class="dice-formula">1d20 + 5</div>
        <div class="dice-tooltip" style="height: 0px;">
    <section class="tooltip-part">
        <div class="dice">
            <ol class="dice-rolls">
                <li class="roll die d20">15</li>
            </ol>
            <div class="total">
                <span class="label"></span>
                <span class="value">15</span>
            </div>
        </div>
    </section>
<section class="tooltip-part constant">
      <div class="dice">
        <ol class="dice-rolls"></ol>
        <div class="total">
          <span class="value"><span class="sign">+</span>5</span>
        </div>
      </div>
    </section></div>

        <h4 class="dice-total">20</h4>
    </div>
</div>

    </div>
</li>

Damage

<li class="chat-message message flexcol visible ddb-game-log-message damage ddb-game-log-fixHeader ddb-game-log-open-card" data-message-id="JoUXRzxZHMyRhJSq" data-entity-type="character"><div class="ddb-game-log-avatar-wrapper"><div class="avatar" style="background-image: url(https://is1-ssl.mzstatic.com/image/thumb/Purple114/v4/3c/23/7b/3c237b58-1c61-b5d7-edb7-5737b49858f8/AppIcon-0-0-1x_U007emarketing-0-0-0-5-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/1024x1024bb.png);"></div><header class="message-header flexrow">
        <h4 class="message-sender"><div class="avatar"><img src="ddb-images/characters/104310930-Balrin-Drovos.jpeg" alt="Balrin Drovos"></div><span class="name-stacked"><span class="title">Balrin Drovos</span><span class="subtitle">Gamemaster</span></span></h4>
        <span class="message-metadata">
            <time class="message-timestamp">Now</time>

        <a aria-label="Additional Controls" class="chat-control" data-context-menu=""><i class="fas fa-ellipsis-vertical fa-fw"></i></a></span>

        <span class="flavor-text"><span class="action" data-ddb-game-log-click-handler="open_card">Longbow:</span> <span class="rolltype damage">Damage</span> <span class="rollkind "></span></span>
    </header></div>

    <div class="message-content">
<div class="ddb-game-log-chat-card">
    <hr>
    <header class="ddb-card-header flexrow">
        <img src="icons/weapons/bows/longbow-leather-green.webp" title="Longbow">
        <h3 class="ddb-item-name">Longbow</h3>
    </header>
    <div class="ddb-card-content">
        <p>Proficiency with a longbow allows you to add your proficiency bonus to the attack roll for any attack you make with it.</p>
        <a class="ddb-sheet-link" data-ddb-game-log-entry-id="GB65yKqJPqTdf3a6..xZBLL4hpfgRcMfxG" data-ddb-game-log-entry-type="items" data-ddb-game-log-open-sheet=""><i class="fas fa-link"></i> Open compendium entry</a>
        <a class="ddb-ddb-link" href="https://www.dndbeyond.com/equipment/longbow" target="_blank"><i class="fas fa-external-link-alt"></i> Open on D&amp;D Beyond</a>    
    </div>
</div>

        <div class="dice-roll">
    <div class="dice-result">
        <div class="dice-formula">1d8 + 3</div>
        <div class="dice-tooltip" style="height: 0px;">
    <section class="tooltip-part">
        <div class="dice">
            <ol class="dice-rolls">
                <li class="roll die d8 min">1</li>
            </ol>
            <div class="total">
                <span class="label"></span>
                <span class="value">1</span>
            </div>
        </div>
    </section>
<section class="tooltip-part constant">
      <div class="dice">
        <ol class="dice-rolls"></ol>
        <div class="total">
          <span class="value"><span class="sign">+</span>3</span>
        </div>
      </div>
    </section></div>

        <h4 class="dice-total">4</h4>
    </div>
</div>

    </div>
</li>
dcode commented 9 months ago

Oh, here's the element for the Midi-QOL merged card I screenshotted above

<li class="chat-message message flexcol " data-message-id="ac11HWGxkNe4vRde">
    <header class="message-header flexrow">
        <h4 class="message-sender"><div class="avatar"><img src="ddb-images/characters/104310930-Balrin-Drovos.jpeg" alt="Balrin Drovos"></div><span class="name-stacked"><span class="title">Balrin Drovos</span><span class="subtitle">dcode</span></span></h4>
        <span class="message-metadata">
            <time class="message-timestamp">10m ago</time>

        <a aria-label="Additional Controls" class="chat-control" data-context-menu=""><i class="fas fa-ellipsis-vertical fa-fw"></i></a></span>

    </header>
    <div class="message-content">
        <div class="dnd5e2 chat-card midi-chat-card item-card " data-actor-id="GB65yKqJPqTdf3a6" data-item-id="xZBLL4hpfgRcMfxG" data-actor-uuid="Actor.GB65yKqJPqTdf3a6" data-token-id="Scene.gNQA4XMJVt8Y3FLJ.Token.eufIWPQ5yTpQiHf6" data-token-uuid="Scene.gNQA4XMJVt8Y3FLJ.Token.eufIWPQ5yTpQiHf6" data-display-challenge="">

  <section class="card-header description collapsible">

    <header class="summary">
      <img class="gold-icon" src="icons/weapons/bows/longbow-leather-green.webp" alt="Longbow">
      <div class="name-stacked border">
        <span class="title">Longbow</span>
        <span class="subtitle">
          Martial Ranged
        </span>
      </div>
      <i class="fas fa-chevron-down fa-fw"></i>
    </header>
    <section class="details collapsible-content card-content" style="height: 46px;">
      <p>Proficiency with a longbow allows you to add your proficiency bonus to the attack roll for any attack you make with it.</p>
    </section>
  </section>

  <div class="card-buttons midi-buttons">

  </div>
  <div class="midi-results">
    <div class="flexrow 2">
      <div class="midi-qol-attack-roll"><div style="text-align:center">Attack</div><div class="midi-attack-roll midi-dice-roll dice-roll">
    <div class="dice-result">
        <div class="dice-formula">1d20 + 3 + 2</div>
        <div class="dice-tooltip" style="height: 0px;">
    <section class="tooltip-part">
        <div class="dice">
            <ol class="dice-rolls">
                <li class="roll die d20">8</li>
            </ol>
            <div class="total">
                <span class="label"></span>
                <span class="value">8</span>
            </div>
        </div>
    </section>
<section class="tooltip-part constant">
      <div class="dice">
        <ol class="dice-rolls"></ol>
        <div class="total">
          <span class="value"><span class="sign">+</span>5</span>
        </div>
      </div>
    </section></div>

        <h4 class="dice-total">13</h4>
    </div>
</div><div class="end-midi-qol-attack-roll"></div>
      </div>
      <div class="midi-qol-damage-roll"><div style="text-align:center">(Piercing)</div>

<div class="end-midi-qol-damage-roll"></div>
      <div class="dice-roll midi-damage-roll">
    <div class="dice-result">
    <div class="dice-formula">1d8[piercing] + 3</div>
        <div class="dice-tooltip" style="height: 0px;">

            <section class="tooltip-part">
                <div class="dice">
                <ol class="dice-rolls">

                    <li class="roll die d8">5</li>

                    <li class="constant"><span class="sign">+</span>3</li>

                </ol>
                <div class="total">
                    <img src="systems/dnd5e/icons/svg/damage/piercing.svg" alt="Piercing">
                    <span class="label">Piercing</span>
                    <span class="value">8</span>
                </div>
                </div>
            </section>

        </div>
        <h4 class="dice-total">8</h4>
    </div>
    </div></div>
    </div>
    <div class="midi-qol-hits-display"><div class="midi-qol-single-hit-card">
  <div class="dnd5e2 evaluation">
    <div>
      <div class="target hit" style="height:38px;align-content:center">
        <img src="ddb-images/other/npc-token-Owlbear.jpeg" height="30" style="max-height:95%;aspect-ratio:1;width:unset;border-width:2px">
        <div class="name-stacked">
          <span class="midi-qol-target-name title" id="6qiaRT7DxGMEirzy" data-uuid="Scene.gNQA4XMJVt8Y3FLJ.Token.6qiaRT7DxGMEirzy">
            <div class="midi-qol-gmTokenName">
            Owlbear
            </div>

            <i class="fas fa-check"></i>
          </span>
        </div>
        <div class="midi-qol-npc-ac">
          <span>
          <i class="fas fa-shield-halved"></i>
          <span style="font-weight:bold">13</span>
          </span>
        </div>
      </div>
    </div>
  </div>
</div><div class="end-midi-qol-hits-display"></div>
    </div>
    <div class="midi-qol-other-damage-roll">
      <div class="end-midi-qol-other-damage-roll"></div>
    </div>
    <div class="midi-qol-bonus-damage-roll">
      <div class="end-midi-qol-bonus-bonus-roll"></div>
    </div>
    <div class="midi-qol-saves-display">
      <div class="end-midi-qol-saves-display"></div>
    </div>

  </div>

  <ul class="card-footer pills unlist">
    <li class="pill pill-sm">
      <span class="label">1 Action</span>
    </li>
    <li class="pill pill-sm">
      <span class="label">150 / 600 ft</span>
    </li>
    <li class="pill pill-sm">
      <span class="label">Equipped</span>
    </li>
    <li class="pill pill-sm">
      <span class="label">Proficient</span>
    </li>
  </ul>

  <div class="effects-tray collapsible collapsed">
    <label class="roboto-upper">
      <i class="fas fa-bolt"></i>
      <span>Effects</span>
      <i class="fas fa-caret-down"></i>
    </label>
    <ul class="effects collapsible-content unlist" style="height: 0px;"></ul>
  </div>
</div>
    </div>
</li>
therealguy90 commented 9 months ago

Thanks, I'll start work on these. midi has changed a lot of the chat card formatting, so I expect this to be a lot of work, now that I look at it.

therealguy90 commented 9 months ago

Here's a sample of what it should look like after I'm done. I've changed the discord embed format to match closer to the new midi cards. image

dcode commented 9 months ago

That looks awesome

therealguy90 commented 9 months ago

Can you provide me with the ChatMessage object from DDB Game Log?

therealguy90 commented 9 months ago

foundrytodiscord.zip

Here, if you want to give this a go.

dcode commented 9 months ago

Alright, this looks really good. Thanks for the quick turn around!

This is the attack roll from the VTT char sheet and chat from my PC.

image

Here's the equivalent rolling from D&D Beyond via Gamelog

image

And skill checks. First is from DDB app, second from 5e char sheet.

image
therealguy90 commented 9 months ago

Great, I'll release it as soon as midi finalizes the chat card formats for 11.4.x. I'll keep this issue open for now for everyone else looking for a temporary fix.