I’m not exactly sure if this is the kind of thing that you can get help with here, if not just let me know where to go! Trying to make a small addon that will check if someone who joined a raid is also on my friend’s list, and if so, change their friend note to the character they were playing and the date/time. I get a lot of people on my friend’s list from weekend pug fun runs that I host, and I’d like to know if somebody added me and then hasn’t come back in 2 months or more so I can remove them.
I gotta say I have a lot of respect for anyone who writes addons, doing programming without a proper debugger is the pits. That said, I’m happy doing debugging with comments and prints, but I seem to be missing whatever is necessary to get this to fire at all.
Thanks for any help!
local frame = CreateFrame("FRAME"); --create a frame for all of this
frame:RegisterEvent("RAID_ROSTER_UPDATE"); --can't seem to find good documentation on events, I want this to fire when someone new joins the
frame:RegisterEvent("GROUP_ROSTER_UPDATE"); --trying anything I can, planned to narrow things down
frame:RegisterEvent("GROUP_FORMED");
frame:RegisterEvent("INSTANCE_GROUP_SIZE_CHANGED");
frame:RegisterEvent("GROUP_JOINED");
frame:SetScript("OnEvent", rosterUpdate); --when RAID_ROSTER_UPDATE happens, fire the below function if i understand correctly (doubtful)
local function rosterUpdate(self, event, ...) --not quite sure what the dots are for, seems to be any given event has multiple arguments that come with it
print("The event is registering and calling the function");
local members = GetNumGroupMembers(); --get how many people are in the raid
print(members); --testing
C_FriendList.ShowFriends(); --update my friend info
local numOnline = C_FriendList.GetNumOnlineFriends(); --get how many friends are online
print(numOnline); --testing
for i = 1, members do --for each raid member, get their character name from their position on the roster
local characterNameInRaid = GetRaidRosterInfo(i);
print(characterNameInRaid); --testing
for j = 1, numOnline do -- for each friend online inside the members on line loop,
local friendInfo = C_FriendList.GetFriendInfoByIndex(j)
--get that friends info which returns in a struct so we can access character name by friendlist info
--saw alternate versions of functions specifically relating to BNet so not sure if C_FriendList.name returns *character* names, but can debug that later
print(friendInfo.name); --testing
if characterNameInRaid == friendInfo.name then --test the character in the raid vs the character on my friends list, and if they match
found = C_FriendList.SetFriendNotesByIndex(j, characterNameInRaid .. " - " .. C_DateAndTime.GetCurrentCalendarTime());
--update the friend note with the character they played and the date we were in the same group
print(found); --testing
end
end
end
end