File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
33// Bot
4- const bot = require ( '../../bot' ) ;
54const { replyOptions } = require ( '../../bot/options' ) ;
65
76const { admin } = require ( '../../stores/user' ) ;
@@ -10,14 +9,23 @@ const { masterID } = require('../../config.json');
109
1110const addedToGroupHandler = async ( ctx , next ) => {
1211 const msg = ctx . message ;
12+ const { telegram } = ctx ;
1313
1414 const wasAdded = msg . new_chat_members . some ( user =>
1515 user . username === ctx . me ) ;
1616 if ( wasAdded && ctx . from . id === masterID ) {
1717 await admin ( ctx . from ) ;
1818 if ( ! await managesGroup ( ctx . chat ) ) {
19- const link = await bot . telegram . exportChatInviteLink ( ctx . chat . id ) ;
20- ctx . chat . link = link ? link : '' ;
19+ try {
20+ const link = await telegram . exportChatInviteLink ( ctx . chat . id ) ;
21+ ctx . chat . link = link ? link : '' ;
22+ } catch ( err ) {
23+ await ctx . replyWithHTML (
24+ '⚠️ <b>Please re-add me with admin permissions.</b>' +
25+ '\n\n' +
26+ `<code>${ err } </code>` ) ;
27+ return telegram . leaveChat ( ctx . chat . id ) ;
28+ }
2129 await addGroup ( ctx . chat ) ;
2230 }
2331 ctx . reply ( '🛠 <b>Ok, I\'ll help you manage this group from now.</b>' ,
You can’t perform that action at this time.
0 commit comments