mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-24 10:58:19 +00:00
25 lines
624 B
JavaScript
25 lines
624 B
JavaScript
|
'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;
|