@@ -6,7 +6,6 @@ import { GenerateCommand } from './handlers/GenerateCommands';
66import { GeneralCommands } from './commands/genearl/GeneralCommands' ;
77import { UserCommands } from './commands/user/UserCommands' ;
88import { AdminCommands } from './commands/admin/AdminCommands' ;
9- import * as http from 'http' ;
109import { SaveUserData } from '../decorators/Database' ;
1110import { MessageValidator } from '../decorators/Context' ;
1211import { BotReply } from '../utils/chat/BotReply' ;
@@ -31,6 +30,13 @@ export class CopBot {
3130
3231 // Start the bot
3332 async start ( ) : Promise < void > {
33+ const startBot = async ( ) => {
34+ await this . _bot . start ( {
35+ onStart : ( botInfo ) => {
36+ console . log ( `Bot started in long-polling mode! Username: ${ botInfo . username } ` ) ;
37+ } ,
38+ } ) ;
39+ } ;
3440 const isProduction = Config . environment === 'production' ;
3541 const webhookURL = `${ Config . web_hook } /bot/${ Config . token } ` ;
3642 console . log ( `Environment: ${ Config . environment } ` ) ;
@@ -39,6 +45,7 @@ export class CopBot {
3945 if ( isProduction ) {
4046 console . log ( 'Setting webhook...' ) ;
4147 try {
48+ await startBot ( ) ;
4249 console . log ( 'Setting up webhook...' ) ;
4350 const _webhookService = new WebHookService ( this . _bot ) ;
4451 await _webhookService . setupWebHook ( ) ;
@@ -52,11 +59,7 @@ export class CopBot {
5259 console . log ( 'Running in long-polling mode...' ) ;
5360 try {
5461 await this . _bot . api . deleteWebhook ( ) ;
55- await this . _bot . start ( {
56- onStart : ( botInfo ) => {
57- console . log ( `Bot started in long-polling mode! Username: ${ botInfo . username } ` ) ;
58- } ,
59- } ) ;
62+ await startBot ( ) ;
6063 } catch ( err ) {
6164 console . error ( 'Error in long-polling mode:' , err ) ;
6265 process . exit ( 1 ) ;
0 commit comments