Event: "group:membership:change"
This event fires when one of the following conditions is met:
- A group member was added to a group
- A group member was removed from a group
- A group member left a group
- A user was opted into a role that is part of this group
- A user was opted out of a role that is part of this group
Properties
Property | Type | Description |
---|---|---|
actor | User | The user who performed the action, or the role affected |
action | string | One of: ADD , REMOVE , JOIN , LEAVE , OPT_IN , or OPT_OUT |
group | Group | The group the operation was performed on |
members | Array< User> | The group members affected (added/removed) |
Examples
client.on('group:membership:change', function (event) {switch (event.action) {case 'ADD':case 'REMOVE':console.log(event.actor.displayName,event.action === 'ADD' ? 'added' : 'removed',event.members.map(function (m) { return m.displayName }).join(', ')event.action === 'ADD' ? 'to' : 'from','the group', event.group.displayName,'at', event.createdAt);break;case 'JOIN':case 'LEAVE':console.log(event.actor.displayName,event.action === 'JOIN' ? 'joined' : 'left','the group', event.group.displayName,'at', event.createdAt);break;case 'OPT_IN':case 'OPT_OUT':console.log(event.members[0].displayName,event.action === 'OPT_IN'? 'is now on duty as': 'is no longer on duty as',event.actor.displayName,'in the group', event.group.displayName,'at', event.createdAt);break;}});