RedReign / FoundryVTT-BetterRolls5e

A module for modifying certain sheet functions on Foundry VTT Character sheets for D&D 5th Edition.
GNU General Public License v3.0
37 stars 67 forks source link

message.data.speaker.token in preCreateChatMessage is getting mangled to '[object Object]' #295

Closed cs96and closed 3 years ago

cs96and commented 3 years ago

Foundry: 0.8.8 Better Rolls: 1.5.5 Dnd5e: 1.3.6

When Better Rolls is enabled, message.data.speaker.token in preCreateChatMessage() is getting mangled to '[object Object]' when a roll is made from a sheet.

image

When Better Rolls is disabled, token is correctly set to the ID of the token that caused the roll. I think the problem is on line 826 of custom-roll.js...

        // Create the chat message
        const chatData = {
            user: game.user.id,
            content: await this.render(),
            speaker: {
                actor: actor?.id,
                token: actor?.token,  // <---- SHOULD HAVE  ?.id  on the end here
                alias: actor?.token?.name || actor?.name
            },
            flags: this._getFlags(),
            type: CONST.CHAT_MESSAGE_TYPES.ROLL,
            ...Utils.getWhisperData(rollMode),

            // If not blank, D&D will try to modify the card...
            roll: new Roll("0").roll()
        };
CarlosFdez commented 3 years ago

You're 100% right. Shame I saw this only recently. Its an easy fix.

cs96and commented 3 years ago

I think it used to work fine in 0.7.x, but something changed in 0.8.x

CarlosFdez commented 3 years ago

In 0.8 I had to change some things due to the new document model but actor.token.id doesn't work either. For whatever reason actor.token is blank. However ChatMessage.getSpeaker({ actor, item }) worked just fine. I just did the fix and it'll work on the next upate, I just need to work on your other MR first, and see if there's anything missing I should slip in as well.

p4535992 commented 3 years ago

I think this issue is been solved no ?

CarlosFdez commented 3 years ago

Ah, yeah I believe so, I just didn't close the issue. I was more or less waiting for confirmation. Thanks for the heads up.