mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-10-09 13:55:52 +00:00
Upgrade to Telegraf 4.3
This commit is contained in:
@@ -13,41 +13,41 @@ const {
|
||||
} = require('../../stores/user');
|
||||
|
||||
/** @param { import('../../typings/context').ExtendedContext } ctx */
|
||||
const adminHandler = async ({ from, message, replyWithHTML }) => {
|
||||
if (!isMaster(from)) return null;
|
||||
const adminHandler = async (ctx) => {
|
||||
if (!isMaster(ctx.from)) return null;
|
||||
|
||||
const { targets } = parse(message);
|
||||
const { targets } = parse(ctx.message);
|
||||
|
||||
if (targets.length > 1) {
|
||||
return replyWithHTML(
|
||||
return ctx.replyWithHTML(
|
||||
'ℹ️ <b>Specify one user to promote.</b>',
|
||||
).then(scheduleDeletion());
|
||||
}
|
||||
|
||||
const userToAdmin = targets.length
|
||||
? await getUser(strip(targets[0]))
|
||||
: from;
|
||||
: ctx.from;
|
||||
|
||||
if (!userToAdmin) {
|
||||
return replyWithHTML(
|
||||
return ctx.replyWithHTML(
|
||||
'❓ <b>User unknown.</b>\n' +
|
||||
'Please forward their message, then try again.',
|
||||
).then(scheduleDeletion());
|
||||
}
|
||||
|
||||
if (userToAdmin.status === 'banned') {
|
||||
return replyWithHTML('ℹ️ <b>Can\'t admin banned user.</b>');
|
||||
return ctx.replyWithHTML('ℹ️ <b>Can\'t admin banned user.</b>');
|
||||
}
|
||||
|
||||
if (userToAdmin.status === 'admin') {
|
||||
return replyWithHTML(
|
||||
return ctx.replyWithHTML(
|
||||
html`⭐️ ${link(userToAdmin)} <b>is already admin.</b>`,
|
||||
);
|
||||
}
|
||||
|
||||
await admin(userToAdmin);
|
||||
|
||||
return replyWithHTML(html`⭐️ ${link(userToAdmin)} <b>is now admin.</b>`);
|
||||
return ctx.replyWithHTML(html`⭐️ ${link(userToAdmin)} <b>is now admin.</b>`);
|
||||
};
|
||||
|
||||
module.exports = adminHandler;
|
||||
|
Reference in New Issue
Block a user