Can I use a macro to leave a group?

If I join a pick-up group, I generally try to see the dungeon or raid through to the end, but sometimes circumstances make that impossible. Maybe my guild is convening for a raid, or maybe I haven't paid as much attention to the clock as I should have, so I need to hearth out and list my items on the AH before quitting for the day.

In circumstances like these, it'd be handy to have a button that simultaneously announces that I'm leaving, apologizes, and explains that I have to go do something else before dropping me from the group and activating my hearthstone (which I can then choose to either permit to complete the cast, or move to interrupt as needed).

The explanation/apology part is easy; I just include two lines prefaced with /p as normal. Is there a command to leave the party, though? I tried this:

/p I'm so sorry, but my wife needs me to leave, so I'm going to have to stop here.
/p Thanks again for grouping with me.
/leaveparty
/leave

Neither /leaveparty nor /leave accomplished anything, though. Any ideas what I should do instead? How about for activating my hearthstone?


Solution 1:

The primary command to remove your character from a party (or group), if your character is in a party.

Ways to Leave Party:

Right-click your portrait and select "Leave Party".

Create a Macro or Type the command:

/script C_PartyInfo.LeaveParty()

Changed in Shadowlands Prepatch 9.0.1 from /script LeaveParty()

Choosing to leave party with only a leader as the other member effectively disbands the party.

Solution 2:

You can try either of these ones (they are case sensitive):

/run LeaveParty()

/script LeaveParty();

Hope that helps.