Determine if current member is a workspace guest in the board's organization

I don’t want to show my Power-Up’s board-button to members of the board that are workspace guests. This is only relevant on paid plans. Of course, I would love to do this without hitting the Trello API.

I don’t see how to retrieve it in t.getContext(), or t.board('all'), or t.member('all'). Help me out?

This is how I see if the user is an “observer” or not on the board:

/// <reference path="trello.d.js" />
/** @type {TrelloPowerUp} */
const tpu = window.TrelloPowerUp;
tpu.initialize({ 
  'board-buttons': 
    /**
     * Returns the board button
     * @param {TrelloObject} t 
     * @returns {TrelloBoardButtonOption[]}
     */
    async (t) => {
      /** @type {TrelloMemberObject} */
      const member = await t.member("id");
      /** @type {TrelloBoard} */
      const board = await t.board("memberships");
      /** @type {TrelloMembership} */
      const membership = board.memberships.find(o=>o.idMember === member.id);
      if(!membership || membership.memberType === "observer") {
        t.alert({
          message: "Sorry you are only a guest on this board!",
          duration: 1,
        });
        return []; // no board button for you
      }
      /** @type {TrelloBoardButtonOption} */
      const button = {
        text: "hello",
        icon: `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAF2SURBVDhPtZMxT8JQEMfb0pI2xMbA0JWyNXQEJLHO7VrmfgAHTfgMLMTo0FknDU0TNze+gCbOSmSBwU2hgxMlAevd8wV95GG6+Euu73/v/e/aXlPhX8myrIBBUy4iXRmCIDicTqeeqqoHmKdp+lir1YaDweCeGHZx1u/vHTnOpWEYqSiKGWyRQI17juNc9cFDzNvEUay2ms1bkJtCXjTBE0WRCprFc70TTdO4Rb8DPa7rnoL+odfr6bZtP4HkFm0HeJ+xBrQg4WU+n7eSJLFR5wH8dfC3UJMGy+WyDJNGmQvwC4vFooyaNFAUZVUo/Pm5GdBbLBZXqEkD2Bjpuv6BOg/olSRpRNNv2u32NSzcoW0HeG9gJZAnQOx6/cKsVmc03YlZNWfgPacpi+/7rmma7yC5d8azDnhAb2AmNx6PJ77fGWqaqsmyvF8qleB19c9KpfJqWdZdo9E4juP4gdoJ3J8J6Xa7BgzXQr1er1/CMHwjBwyC8AW6vpgYpmCzMQAAAABJRU5ErkJggg==`, // for card front badges only
        condition: "always",
        callback: (tt) => {
          tt.alert({
            message: "You are all paid up!",
            duration: 1,
          })
        }
      };
      // return the button
      return [button];
    }
});
1 Like

Amazing. That worked perfectly.