The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Rocket.Chat/packages/rocketchat-slashcommands-leave/leave.js

31 lines
802 B

/*
* Leave is a named function that will replace /leave commands
* @param {Object} message - The message object
*/
function Leave(command, params, item) {
if (command !== 'leave' && command !== 'part') {
return;
}
try {
Meteor.call('leaveRoom', item.rid);
} catch ({error}) {
RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', {
_id: Random.id(),
rid: item.rid,
ts: new Date,
msg: TAPi18n.__(error, null, Meteor.user().language)
});
}
}
if (Meteor.isClient) {
RocketChat.slashCommands.add('leave', undefined, {
description: 'Leave_the_current_channel'
});
RocketChat.slashCommands.add('part', undefined, {
description: 'Leave_the_current_channel'
});
} else {
RocketChat.slashCommands.add('leave', Leave);
RocketChat.slashCommands.add('part', Leave);
}