leave_org.lua 887 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --- Removes initiator from org
  2. -- @module leave_org
  3. local leave_org = {
  4. name = "Leave org",
  5. slug = "leave_org",
  6. desc = "Remove yourself from the current org"
  7. }
  8. leave_org.data = {
  9. }
  10. leave_org.config = {
  11. }
  12. --- Removes user from org
  13. -- @function leave_org:initiate
  14. -- @param result
  15. function leave_org:initiate(result)
  16. if self.org == modpol.instance then
  17. modpol.interactions.message(
  18. self.initiator,
  19. "You cannot leave the root org")
  20. else
  21. self.org:remove_member(self.initiator)
  22. modpol.interactions.message_org(
  23. self.initiator,self.org.id,
  24. self.initiator .. " has left org " .. self.org.name)
  25. modpol.interactions.message(
  26. self.initiator,
  27. "You have left org " .. self.org.name)
  28. end
  29. if result then result() end
  30. self.org:delete_process(self.id)
  31. end
  32. modpol.modules.leave_org = leave_org