'use strict';
// DB
const { listCommands } = require('../../stores/command');
const commandReference = `\
Master commands:
/admin
- Makes the user admin.
/unadmin
- Demotes the user from admin list.
/leave
- Makes the bot leave the group cleanly.
Admin commands:
/warn <reason>
- Warns the user.
/unwarn
- Removes the last warn from the user.
/nowarns
- Clears warns for the user.
/ban <reason>
- Bans the user from groups.
/unban
- Removes the user from ban list.
/user
- Shows user's status and warns.
Commands for everyone:
/staff
- Shows a list of admins.
/link
- Show the current group's link.
/groups
- Show a list of groups which the bot is admin in.
/report
- Reports the replied-to message to admins.
`;
const actions = `\n
/addcommand
- to create custom commands.
/removecommand <name>
- to remove a custom command.`;
const commandReferenceHandler = async ({ chat, replyWithHTML }) => {
if (chat.type !== 'private') return null;
const customCommands = await listCommands();
const customCommandsText = customCommands.length
? '\nCustom commands:\n' +
customCommands
.filter(command => command.isActive)
.sort((a, b) => a.role.toLowerCase() < b.role.toLowerCase())
.map(command =>
`[${command.role.toLowerCase()}] ` +
`!${command.name}
`)
.join('\n')
: '';
return replyWithHTML(commandReference + customCommandsText + actions);
};
module.exports = commandReferenceHandler;