2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-25 11:27:20 +00:00

49 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-09-27 22:17:07 +02:00
'use strict';
2017-10-04 20:55:50 +03:30
// DB
const { listCommands } = require('../../stores/command');
2017-09-27 22:17:07 +02:00
const commandReference = `\
<b>Master commands</b>:
2017-09-29 00:02:58 +03:30
<code>/admin</code> - Makes the user admin.
<code>/unadmin</code> - Demotes the user from admin list.
2017-09-28 22:59:35 +02:00
<code>/leave</code> - Makes the bot leave the group cleanly.
2017-09-27 22:17:07 +02:00
<b>Admin commands</b>:
2017-09-29 00:02:58 +03:30
<code>/warn &lt;reason&gt;</code> - Warns the user.
<code>/unwarn</code> - Removes the last warn from the user.
<code>/nowarns</code> - Clears warns for the user.
<code>/ban &lt;reason&gt;</code> - Bans the user from groups.
<code>/unban</code> - Removes the user from ban list.
2017-11-02 16:55:36 +01:00
<code>/user</code> - Shows user's status and warns.
2017-09-27 22:17:07 +02:00
<b>Commands for everyone</b>:
2017-09-29 00:02:58 +03:30
<code>/staff</code> - Shows a list of admins.
2017-10-02 12:09:44 +03:30
<code>/link</code> - Show the current group's link.
2017-09-29 00:02:58 +03:30
<code>/groups</code> - Show a list of groups which the bot is admin in.
<code>/report</code> - Reports the replied-to message to admins.
2017-09-27 22:17:07 +02:00
`;
2017-10-04 20:55:50 +03:30
const actions = `\n
2017-11-02 16:55:36 +01:00
<code>/addcommand</code> - to create custom commands.
<code>/removecommand &lt;name&gt;</code> - to remove a custom command.`;
2017-10-04 20:55:50 +03:30
const commandReferenceHandler = async ({ chat, replyWithHTML }) => {
if (chat.type !== 'private') return null;
2017-10-04 20:55:50 +03:30
const customCommands = await listCommands();
const customCommandsText = customCommands.length
? '\n<b>Custom commands:</b>\n' +
customCommands
.filter(command => command.isActive)
.sort((a, b) => a.role.toLowerCase() < b.role.toLowerCase())
.map(command =>
`[${command.role.toLowerCase()}] ` +
`<code>!${command.name}</code>`)
2017-10-04 20:55:50 +03:30
.join('\n')
: '';
return replyWithHTML(commandReference + customCommandsText + actions);
2017-09-28 15:46:49 +03:30
};
2017-09-27 22:17:07 +02:00
module.exports = commandReferenceHandler;