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

50 lines
1.8 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');
const { scheduleDeletion } = require('../../utils/tg');
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-11-25 14:59:41 +03:30
<code>/leave &lt;name|id&gt;</code> - Makes the bot leave the group cleanly.
2018-04-17 17:19:27 +02:00
<code>/hidegroup</code> - Hide the group from <code>/groups</code> list.
<code>/showgroup</code> - Show the group it in <code>/groups</code> list.
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-11-25 14:59:41 +03:30
<code>/addcommand &lt;name&gt;</code> - to create a custom command.
<code>/removecommand &lt;name&gt;</code> - to remove a custom command.
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
`;
const commandReferenceHandler = async ({ replyWithHTML }) => {
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)
.then(scheduleDeletion);
2017-09-28 15:46:49 +03:30
};
2017-09-27 22:17:07 +02:00
module.exports = commandReferenceHandler;