-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommunity2Raid.lua
More file actions
74 lines (56 loc) · 2.13 KB
/
Community2Raid.lua
File metadata and controls
74 lines (56 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
SLASH_COMMUNITY2RAID1 = '/invitetoraid'
DEFAULT_CHAT_FRAME:AddMessage('[|cFF8B008BCommunity2Raid|r] Mass invite Community to Raid: /invitetoraid <CommunityName>', 1,1,0)
maxTime = 0
membersInChannels = {}
----------------------------
-- Invite Players
----------------------------
local function InviteToRaid()
for _,memberID in pairs(membersInChannels) do
memberInfo = C_Club.GetMemberInfo(communityID, memberID)
if memberInfo.presence == Enum.ClubMemberPresence.Online then
C_PartyInfo.InviteUnit(memberInfo.name)
end
end
end
---------------------------------------------------------------------
-- Check if someone accepted invitation, so I can to convert to raid
---------------------------------------------------------------------
local function checkParty()
if maxTime > 60 then --Invitation attempts end in 1 minute
return
end
numMembers = GetNumSubgroupMembers()
if numMembers > 0 then
C_PartyInfo.ConvertToRaid()
InviteToRaid() --Second invitation wave
else
maxTime = maxTime + 1
C_Timer.After(1, checkParty) --Check all again in 1 second
end
end
------------------------------------
-- Find Members of the Community
------------------------------------
local function InviteCommunity(input)
communityName = input:match("%s*(.*)") --RegExp: space+<Community Name>
communities = C_Club.GetSubscribedClubs()
communityID = nil
for _,community in pairs(communities) do
if (community.name == communityName and community.clubType == Enum.ClubType.Character) then
communityID = community.clubId
end
end
if communityID == nil then
DEFAULT_CHAT_FRAME:AddMessage('[Community2Raid] Bad community name, please retry.', 1,1,0)
return
end
membersInChannels = C_Club.GetClubMembers(communityID)
--Only 4 invitations can be sent if you are not in raid mode
--If no invitation is accepted in 1 minute, a new /invitetoraid would
--need to be done
InviteToRaid() --First invitation wave
maxTime = 0
checkParty()
end
SlashCmdList["COMMUNITY2RAID"] = InviteCommunity