leave_org.lua 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. --- leave_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. --- (Required): initiate function
  13. -- Modules have access to the following instance variables:
  14. -- @param result (optional) Callback if this module is embedded in other modules
  15. -- @function initiate
  16. function leave_org:initiate(result)
  17. if self.org == modpol.instance then
  18. modpol.interactions.message(
  19. self.initiator,
  20. "You cannot leave the root org")
  21. else
  22. self.org:remove_member(self.initiator)
  23. modpol.interactions.message_org(
  24. self.initiator,self.org.id,
  25. self.initiator .. " has left org " .. self.org.name)
  26. modpol.interactions.message(
  27. self.initiator,
  28. "You have left org " .. self.org.name)
  29. end
  30. if result then result() end
  31. self.org:delete_process(self.id)
  32. end
  33. --- (Required) Add to module table
  34. modpol.modules.leave_org = leave_org