Automatically Invite Players From Queue

– Automatically Invite
if UnitInParty(“player”) then
if UnitIsGroupLeader(“player”) == true then
local groupSize = GetNumSubgroupMembers()
if groupSize < 3 then
local applicants = C_LFGList.GetApplicants();
if applicants == nil then
return
end
print(applicants)
local applicantData = C_LFGList.GetApplicantInfo(1)
local id = applicantData.applicantID
local name, _, _, _, _, _, _, _, _ = C_LFGList.GetApplicantMemberInfo(id,1)
print(applicantData.applicationStatus)
if applicantData.applicationStatus == “applied” then
InviteUnit(name)
RefreshLFGList()
end
end
end
end

I need assistance with the code above. I want to automatically invite players to my party. However, I get a repeating error that applicationData is nil. I tried to put checks in place so if there is no one in the queue it won’t try to get the applicant info but it doesn’t work. Applicants when not in LFG applicants is nil. When I am in LFG applicants is a long hexadecimal string which seems to change per character.

This code does work, but errors are constantly repeated.

Any assistance would be great!

C_LFGList.GetApplicants() returns a table of applicantIDs

    local applicants = C_LFGList.GetApplicants();
   if applicants and #applicants > 0
...
1 Like

Ahh, I tried doing applicants > 0 but that didn’t work. Let me give that a go! Thank you!

EDIT: Is # a wildcard?

… is just you telling me to continue my code right? Is that passing along arguments?

EDIT: It worked! Thank you! Now I just need to see how to check if the player has a pending invite so it stops trying to invite them over and over xD

#table returns the number of elements in the table

if applicants and #applicants > 0
	for i=1, #applicants do
		print("Applicant:", i, "ID:", applicants[i])
	end
end

Ahh okay, thank you!

Do you happen to know if there is an API to see if the player has a pending group invitation? As it is now, my chat gets spammed over and over until the player accepts the invite. I was thinking of using a Boolean but I don’t think there is an event to reset it.

I tried also removing the player from the queue then inviting them, but even if they’re marked as “Cancelled” it still tries to invite them.

You do an
InviteUnit(name)

If you store the name in a table after sending an invite, you can check to see if the name exists in the table before doing an inviting and if it does, don’t process the “re” invite.

I don’t know your code so that’s one possible approach. You will need to figure out if/how you want to remove a name from the “save” table once an invite has been accepted etc.

any chance this work? if so what is total code and where do i use it ? weak aura ?