2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-24 10:58:19 +00:00

25 lines
624 B
JavaScript
Raw Normal View History

2017-10-04 20:55:50 +03:30
'use strict';
// DB
const { isAdmin } = require('../../stores/user');
const { addCommand } = require('../../stores/command');
// Bot
const { replyOptions } = require('../../bot/options');
const addCommandHandler = async ({ chat, message, reply }) => {
const user = message.from;
if (chat.type !== 'private') {
return null;
}
if (!await isAdmin(user)) {
return reply(' <b>Sorry, only admins access this command.</b>',
replyOptions);
}
await addCommand({ id: user.id });
return reply('Enter a name for the command.\n\nFor example: <b>rules</b>',
replyOptions);
};
module.exports = addCommandHandler;