2017-10-04 20:55:50 +03:30
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
// DB
|
|
|
|
|
const { addCommand } = require('../../stores/command');
|
|
|
|
|
|
|
|
|
|
// Bot
|
|
|
|
|
const { replyOptions } = require('../../bot/options');
|
|
|
|
|
|
2017-10-06 16:34:23 +03:30
|
|
|
|
const addCommandHandler = async ({ chat, reply, state }) => {
|
|
|
|
|
const { isAdmin, user } = state;
|
2017-10-04 20:55:50 +03:30
|
|
|
|
if (chat.type !== 'private') {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2017-10-06 16:34:23 +03:30
|
|
|
|
if (!isAdmin) {
|
2017-10-04 20:55:50 +03:30
|
|
|
|
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;
|