1- import  Discord  from  'discord.js' ; 
1+ import  Discord ,   {   GatewayIntentBits   }  from  'discord.js' ; 
22import  MonitoRSS  from  'monitorss' ; 
33import  type  {  ClientConfig  }  from  'monitorss' ; 
44import  Cache  from  'node-cache' ; 
55
66import  {  handleCommand  }  from  './commands' ; 
77import  {  KARMA_REGEX  }  from  './commands/karma' ; 
8- import  {  getConfig  }  from  './config' ; 
9- import  {  createHttpServer  }  from  './http-server' ; 
10- import  {  InvalidUsageError  }  from  './types' ; 
11- import  {  getWeekNumber ,  wrapErr  }  from  './utils' ; 
12- import  {  getStatsCollection ,  initDb  }  from  './db' ; 
138import  {  messageToReflinks  }  from  './commands/reflink' ; 
9+ import  {  getConfig  }  from  './config' ; 
1410import  {  updateKarmaRoles  }  from  './cron/roles/karma' ; 
1511import  {  updateStatsRoles  }  from  './cron/roles/stats' ; 
12+ import  {  getStatsCollection ,  initDb  }  from  './db' ; 
13+ import  {  createHttpServer  }  from  './http-server' ; 
1614import  {  thx  }  from  './thx' ; 
15+ import  {  InvalidUsageError  }  from  './types' ; 
16+ import  {  getWeekNumber ,  wrapErr  }  from  './utils' ; 
1717
1818const  MESSAGE_COLLECTOR_CACHE_S  =  60  *  60 ; 
1919const  messageCollectorCache  =  new  Cache ( {  stdTTL : MESSAGE_COLLECTOR_CACHE_S  } ) ; 
2020
21- const  client  =  new  Discord . Client ( ) ; 
21+ const  client  =  new  Discord . Client ( { 
22+   intents : [ 
23+     GatewayIntentBits . Guilds , 
24+     GatewayIntentBits . GuildMessages , 
25+     GatewayIntentBits . MessageContent , 
26+     GatewayIntentBits . GuildMembers , 
27+   ] , 
28+ } ) ; 
2229
2330const  settings : {  readonly  setPresence : boolean ;  readonly  config : ClientConfig  }  =  { 
2431  setPresence : true , 
@@ -77,7 +84,7 @@ function isCommand(msg: Discord.Message) {
7784// const ROLE_MUTED_NAME = 'muted' as const; 
7885// const MAX_MENTIONS_PER_MESSAGE = 10; 
7986
80- client . on ( 'message ' ,  async  ( msg )  =>  { 
87+ client . on ( 'messageCreate ' ,  async  ( msg )  =>  { 
8188  if  ( msg . author . bot )  { 
8289    return ; 
8390  } 
@@ -92,14 +99,15 @@ client.on('message', async (msg) => {
9299  // } 
93100
94101  if  ( msg . content  ===  `(╯°□°)╯︵ ┻━┻` )  { 
95-     return  msg . channel . send ( `┬─┬ノ( ◕◡◕ ノ)` ) ; 
102+     await  msg . channel . send ( `┬─┬ノ( ◕◡◕ ノ)` ) ; 
103+     return ; 
96104  } 
97105
98106  if  ( isCommand ( msg ) )  { 
99107    try  { 
100-       const  collector  =  msg . channel . createMessageCollector ( 
101-         ( m : Discord . Message )  =>  m . author . id  ===  client . user ?. id , 
102-       ) ; 
108+       const  collector  =  msg . channel . createMessageCollector ( { 
109+         filter :  ( m : Discord . Message )  =>  m . author . id  ===  client . user ?. id , 
110+       } ) ; 
103111      await  handleCommand ( msg ) ; 
104112      const  ids  =  collector . collected . map ( ( m )  =>  m . id ) ; 
105113      messageCollectorCache . set ( msg . id ,  ids ) ; 
@@ -111,16 +119,15 @@ client.on('message', async (msg) => {
111119        console . error ( err ) ; 
112120        void  msg . reply ( 'przepraszam, ale coś poszło nie tak…' ) ; 
113121      } 
114-     }  finally  { 
115-       return  msg . channel . stopTyping ( true ) ; 
116122    } 
117123  } 
118124
119125  void  updateMessagesCount ( msg . member ?. id ,  msg . member ?. displayName ) . catch ( console . error ) ; 
120126
121127  const  maybeReflinks  =  messageToReflinks ( msg . content ) ; 
122128  if  ( maybeReflinks . length  >  0 )  { 
123-     return  msg . reply ( maybeReflinks ) ; 
129+     await  msg . reply ( maybeReflinks . join ( '\n' ) ) ; 
130+     return ; 
124131  } 
125132
126133  await  thx ( msg ) ; 
@@ -156,7 +163,7 @@ async function updateMessagesCount(
156163} 
157164
158165function  revertCommand ( msg : Discord . Message )  { 
159-   if  ( ! messageCollectorCache . has ( msg . id )  ||  msg . channel . type  ===  'dm' )  { 
166+   if  ( ! messageCollectorCache . has ( msg . id )  ||  msg . channel . type  ===  Discord . ChannelType . DM )  { 
160167    return  undefined ; 
161168  } 
162169  // eslint-disable-next-line functional/prefer-readonly-type 
0 commit comments