join_org_consent.lua 876 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --- Join org (consent)
  2. -- A simple module that calls a consent process on an org to add a member.
  3. -- Depends on the Consent module.
  4. local join_org_consent = {
  5. name = "Join this org",
  6. slug = "join_org_consent",
  7. desc = "Adds member with consent of all members."
  8. }
  9. join_org_consent.data = {
  10. }
  11. join_org_consent.config = {
  12. }
  13. function join_org_consent:initiate(result)
  14. self.org:call_module(
  15. "consent",
  16. self.initiator,
  17. {
  18. prompt = "Allow " .. self.initiator .. " to join?",
  19. votes_required = #self.org.members
  20. },
  21. function ()
  22. self:complete()
  23. end
  24. )
  25. if result then result() end
  26. end
  27. function join_org_consent:complete()
  28. self.org:add_member(self.initiator)
  29. print("Added " .. self.initiator .. " to the org.")
  30. end
  31. modpol.modules.join_org_consent = join_org_consent