2024-07-13 22:15:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								const  {  SlashCommandBuilder ,  EmbedBuilder  }  =  require ( 'discord.js' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  {  getAllChangelog ,  checkGameStorageId ,  getUserFromId  }  =  require ( '../../databaseHelperFunctions.js' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								module . exports  =  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									data :  new  SlashCommandBuilder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									. setName ( 'globalchangelog' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									. setDescription ( 'Show all recent activity' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									async  execute ( interaction )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										await  interaction . deferReply ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  changelogEntries  =  await  getAllChangelog ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  desc  =  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 22:22:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( let  i  =  0 ;  i  <  changelogEntries . length ;  i ++ )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  game  =  await  checkGameStorageId ( changelogEntries [ i ] . gameId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  user  =  await  getUserFromId ( changelogEntries [ i ] . userId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 22:15:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 22:22:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( changelogEntries [ i ] . newStatus  ==  'planning' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                desc  =  desc . concat ( ` :pencil: * ${ user . username } * planned ** ${ game . name } ** *( ${ changelogEntries [ i ] . createdAt . toLocaleDateString ( 'en-GB' ,  {  year :  'numeric' ,  month :  '2-digit' ,  day :  '2-digit'  } ).replace(/ \/ /g, '/')})* \n ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  if  ( changelogEntries [ i ] . newStatus  ==  'playing' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                desc  =  desc . concat ( ` :video_game: * ${ user . username } * started playing ** ${ game . name } ** *( ${ changelogEntries [ i ] . createdAt . toLocaleDateString ( 'en-GB' ,  {  year :  'numeric' ,  month :  '2-digit' ,  day :  '2-digit'  } ).replace(/ \/ /g, '/')})* \n ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  if  ( changelogEntries [ i ] . newStatus  ==  'beat' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                desc  =  desc . concat ( ` :white_check_mark: * ${ user . username } * beat ** ${ game . name } ** *( ${ changelogEntries [ i ] . createdAt . toLocaleDateString ( 'en-GB' ,  {  year :  'numeric' ,  month :  '2-digit' ,  day :  '2-digit'  } ).replace(/ \/ /g, '/')})* \n ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  if  ( ! changelogEntries [ i ] . newStatus )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                desc  =  desc . concat ( ` :x: * ${ user . username } * deleted ** ${ game . name } ** from ** ${ changelogEntries [ i ] . oldStatus } ** *( ${ changelogEntries [ i ] . createdAt . toLocaleDateString ( 'en-GB' ,  {  year :  'numeric' ,  month :  '2-digit' ,  day :  '2-digit'  } ).replace(/ \/ /g, '/')})* \n ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 22:15:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  embed  =  new  EmbedBuilder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        . setColor ( 0x6441a5 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        . setThumbnail ( interaction . client . user . avatarURL ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        . setTitle ( 'Global Changelog' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        . setDescription ( desc ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        . setFooter ( {  text :  'The Ochulus • 100 Games Challenge' ,  iconURL :  interaction . client . user . avatarURL ( )  } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        . setTimestamp ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  interaction . editReply ( {  embeds :  [ embed ]  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;