From aa46000abf53683d3fa6f21682cd869737499f95 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sun, 5 Jan 2025 23:32:46 +0100 Subject: [PATCH] Implement joingroup and leavegroup for commander --- Modules/Commander.lua | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/Modules/Commander.lua b/Modules/Commander.lua index eeecd09..54138f6 100644 --- a/Modules/Commander.lua +++ b/Modules/Commander.lua @@ -146,6 +146,25 @@ function shared.Commander.Init() end local function HelpRu() return helpMessages.ru end local function HelpEn() return helpMessages.en end + local groupInviteFrame = CreateFrame("Frame") + groupInviteFrame:SetScript("OnEvent", function(self, event, ...) + AcceptGroup() + groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") + C_Timer.NewTimer(0.1, function() + _G["StaticPopup1Button1"]:Click() + end, 1) + end) + local function JoinGroup() + groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST") + C_Timer.NewTimer(10, function() + groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") + end, 1) + return { "+" } + end + local function LeaveGroup() + LeaveParty() + return {} + end ---@class Command ---@field keywordRe string @@ -153,11 +172,13 @@ function shared.Commander.Init() ---@field callback fun(...: any): string[] local commands = { - { keywordRe = "^who", commanderOnly = false, callback = WhoPartitionedStinkies }, - { keywordRe = "^howmany", commanderOnly = false, callback = CountPartitionedStinkies }, - { keywordRe = "^classes", commanderOnly = false, callback = CountClassPartitionedStinkies }, - { keywordRe = "^help", commanderOnly = false, callback = HelpRu }, - { keywordRe = "^helpen", commanderOnly = false, callback = HelpEn }, + { keywordRe = "^who", commanderOnly = false, callback = WhoPartitionedStinkies }, + { keywordRe = "^howmany", commanderOnly = false, callback = CountPartitionedStinkies }, + { keywordRe = "^classes", commanderOnly = false, callback = CountClassPartitionedStinkies }, + { keywordRe = "^help", commanderOnly = false, callback = HelpRu }, + { keywordRe = "^helpen", commanderOnly = false, callback = HelpEn }, + { keywordRe = "^joingroup", commanderOnly = true, callback = JoinGroup }, + { keywordRe = "^leavegroup", commanderOnly = true, callback = LeaveGroup }, } local commanderChannelFrame = CreateFrame("Frame")