so i made a macro to recruit in my guild an add a link
/run local club = ClubFinderGetCurrentClubListingInfo(C_Club.GetGuildClubId()); SendChatMessage(""..GetClubFinderLink(club.clubFinderGUID, club.name).." Is expanding we are a casual guild Welcoming all levels and playstyles pls use link to apply","CHANNEL",nil,2)
it works well and i made one that also posts to general but i was wonder if there was a way i can make a AIO that if trade channel exists post there if not post general?
i tried this:
/run local club = ClubFinderGetCurrentClubListingInfo(C_Club.GetGuildClubId()); index = GetChannelName("Trade"); if (index~=nil) then SendChatMessage("Test"..GetClubFinderLink(club.clubFinderGUID, club.name).."Message","CHANNEL",nil, 1) else SendChatMessage("Test"..GetClubFinderLink(club.clubFinderGUID, club.name).."Message","CHANNEL",nil, 2)
but i cant seem to get it to post anything to move on to the next part lol btw im familure with javascript not lua so this is new lol
Better off using a binary operator for the channel selection. Also, when posting code on the forums wrap it in ` x3 on new lines so your quotes don’t get smart quoted etc.
GetChannelName() returns 0 not nil when not found.
untested
/run local c,i = ClubFinderGetCurrentClubListingInfo(C_Club.GetGuildClubId()),GetChannelName("Trade") SendChatMessage("Test"...GetClubFinderLink(c.clubFinderGUID, c.name)..."Message","CHANNEL",nil, (i > 0 and i or 1))
http://lua-users.org/wiki/TernaryOperator
https://wowwiki.fandom.com/wiki/API_GetChannelName
ok so i run:
/run local c,i = ClubFinderGetCurrentClubListingInfo(C_Club.GetGuildClubId()),GetChannelName("Trade") SendChatMessage(""...GetClubFinderLink(club.clubFinderGUID, club.name)..." Is expanding we are a casual guild Welcoming all levels and playstyles pls use link to apply","CHANNEL",nil, (i > 0 and i or 1))
but it dosent return a message at all tested in both in SW and Elywnn
Replace all instances of club. with c. or, replace local c with local club
1 Like
nope didnt work i feel like it has more to do with the end (i > 0 and i or 1) its supposed to return a 1 or a 2 here depending on the channel so im not understanding how this part is supposed to do that since c,i = is just declaring a variable
basically i need if trade exists post there if not post to general
You have an issue with size, the original macro is 260+ characters long.
If you can reduce the text to fit or maybe move the text part into a global then start with:
/run local club=ClubFinderGetCurrentClubListingInfo(C_Club.GetGuildClubId()) SendChatMessage(""..GetClubFinderLink(club.clubFinderGUID, club.name).." Is expanding we are a casual guild Welcoming all levels and playstyles pls use link to apply","CHANNEL",nil, GetChannelName(2)>0 and 2 or 1)
the ClubFinderGetCurrentClubListingInfo() function won’t exist and will cause an error if you haven’t opened the Communities frame before trying to use it.
Edit: The GetChannelName function works slightly different to other functions that allow you to pass in a name OR an id. Mostly they resolve what was passed in to what they need and return the same thing.
GetChannelName with a name passed in GetChannelName("Trade") will return as the first parameter the channel number associated with the name regardless of its status.
GetChannelName with a channel number passed in GetChannelName(2) will return as the first parameter the current “active” status of the channel (the channel number if it’s active or 0 if it’s not).
1 Like
Character limit isnt an issue im using macro toolbox to extend the limit
Then the above macro should work. It just replaces the fixed channel number in your original macro with GetChannelName(2)>0 and 2 or 1
Which should send the message to Trade if it is “active” otherwise send it to General.
2 Likes
alrighty i got a chance to try it out and works great! thanks for the help 