Feedback Wanted: Joining a Meeting From Fantastical Menu Bar

Looking for feedback from this group to see if I can clean this up or make it better. I have a working AppleScript to click the Fantastical Helper menu bar item and check if there's a meeting to join and click that menu item.

There's a couple of things I noticed that I'm curious if anyone has experience with

  • In Bartender 4's AppleScript library, there is list menu bar items but it seems to return a string instead of a list. Am I missing something or is that correct? I'd like to avoid the delimiter stuff if possible
  • I'm using Bartender 4's AS library to activate the menu bar item because using System events to click and get subsequent menu items has a 3-5 second delay between each call. Someone had a suggestion here, but that feels more hacky
set fantasticalMMID to ""

-- Using Bartender instead of System Events because there's a
-- weird 3-5 second delay between clicking and getting UI elements
tell application "Bartender 4"
	set menuItemsString to (list menu bar items)
	set ASTID to AppleScript's text item delimiters
	set AppleScript's text item delimiters to ASCII character 10
	set menuItems to every text item of menuItemsString
	set AppleScript's text item delimiters to ASTID
	repeat with menuItem in menuItems
		if menuItem contains "Fantastical" then
			set fantasticalMMID to menuItem
		end if
	end repeat
	if fantasticalMMID is not "" then
		activate fantasticalMMID
	end if
end tell

tell application "System Events"
	tell application process "Fantastical Helper"
		tell menu bar 2
			tell menu bar item 1
				if (menu items) is not {} then
					set joinButton to (get menu items of menu 1 whose name contains "Join")
					if joinButton is not {} then
						click item 1 of joinButton
					end if
					click -- Dismisses the Fantastical Helper
				end if
			end tell
		end tell
	end tell
end tell