@ -11,13 +11,13 @@ module.exports = { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    meta :  {   
					 
					 
					 
					    meta :  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        category :  'Misc' ,   
					 
					 
					 
					        category :  'Misc' ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        description :  "Create and edit automatic responses, which lets the bot say stuff when you say something in your server!" ,   
					 
					 
					 
					        description :  "Create and edit automatic responses, which lets the bot say stuff when you say something in your server!" ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        syntax :  '`ar <add|edit|delete|settings>`' ,   
					 
					 
					 
					        syntax :  '`ar <add|edit|delete|settings|list >`' ,   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					        extra :  null   
					 
					 
					 
					        extra :  null   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    } ,   
					 
					 
					 
					    } ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    help :  new  Discord . MessageEmbed ( )   
					 
					 
					 
					    help :  new  Discord . MessageEmbed ( )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        . setTitle ( "Help -> Auto Responses" )   
					 
					 
					 
					        . setTitle ( "Help -> Auto Responses" )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        . setDescription ( "Create and edit automatic responses, which lets the bot say stuff when you say something in your server!" )   
					 
					 
					 
					        . setDescription ( "Create and edit automatic responses, which lets the bot say stuff when you say something in your server!" )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        . addField ( "Syntax" ,  "`ar <add|edit|delete|settings>`" )   
					 
					 
					 
					        . addField ( "Syntax" ,  "`ar <add|edit|delete|settings|list >`" )   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					        . addField ( "Notice" ,  "This command is server-only, and requires you to be an administrator or have the staff role." ) ,   
					 
					 
					 
					        . addField ( "Notice" ,  "This command is server-only, and requires you to be an administrator or have the staff role." ) ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    async  execute ( message ,  msg ,  args ,  cmd ,  prefix ,  mention ,  client )  {   
					 
					 
					 
					    async  execute ( message ,  msg ,  args ,  cmd ,  prefix ,  mention ,  client )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        if  ( ! message . guild )  { return  message . channel . send ( "You must be in a server in order to use this command." ) ; }   
					 
					 
					 
					        if  ( ! message . guild )  { return  message . channel . send ( "You must be in a server in order to use this command." ) ; }   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -25,12 +25,22 @@ module.exports = { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        const  tg  =  await  GuildData . findOne ( { gid :  message . guild . id } ) ;   
					 
					 
					 
					        const  tg  =  await  GuildData . findOne ( { gid :  message . guild . id } ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        if  ( [ 'a' ,  'add' ,  'e' ,  'edit' ,  'delete' ,  'd' ] . includes ( args [ 0 ] . toLowerCase ( ) )  &&  ( ( ! tg  ||  ! tg . staffrole  ||  ! tg . staffrole . length  ||  ! message . member . roles . cache . has ( tg . staffrole ) )  &&  ! message . member . permissions . has ( "ADMINISTRATOR" ) ) )  { return  message . channel . send ( "You must have the staff role or be an administrator in this server in order to edit AR settings." ) ; }   
					 
					 
					 
					        if  ( [ 'a' ,  'add' ,  'e' ,  'edit' ,  'delete' ,  'd' ] . includes ( args [ 0 ] . toLowerCase ( ) )  &&  ( ( ! tg  ||  ! tg . staffrole  ||  ! tg . staffrole . length  ||  ! message . member . roles . cache . has ( tg . staffrole ) )  &&  ! message . member . permissions . has ( "ADMINISTRATOR" ) ) )  { return  message . channel . send ( "You must have the staff role or be an administrator in this server in order to edit AR settings." ) ; }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        function  view ARs( tar )  {   
					 
					 
					 
					        function  sort ARs( tar )  {   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					            let  t  =  tar . triggers ;   
					 
					 
					 
					            let  t  =  tar . triggers ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            let  ar  =  tar . ars ;   
					 
					 
					 
					            let  ar  =  tar . ars ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            let  f  =  [ ] ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            let  s  =  '' ;   
					 
					 
					 
					            let  s  =  '' ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            for  ( let  i = 0 ; i < t . length ; i ++ )  { let  tt = t [ i ] ; f . push ( tt ) ; s += ` \` ${ i + 1 } . \`   ${ tt } \n ->  ${ ar [ tt ] } \n \n ` ; }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            return  [ s ,  f ] ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            for  ( let  i = 0 ; i < t . length ; i ++ )  { s += ` ` ; }   
					 
					 
					 
					        function  viewARs ( string )  {   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            return  new  Discord . MessageEmbed ( )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                . setTitle ( "Auto-Responses in this Server" )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                . setDescription ( string )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                . setColor ( 'c375f0' )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                . setFooter ( "Natsuki" ,  client . user . avatarURL ( ) )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                . setTimestamp ( ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        }   
					 
					 
					 
					        }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        if  ( [ 'a' ,  'add' ] . includes ( args [ 0 ] . toLowerCase ( ) ) )  {   
					 
					 
					 
					        if  ( [ 'a' ,  'add' ] . includes ( args [ 0 ] . toLowerCase ( ) ) )  {   
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -58,7 +68,22 @@ module.exports = { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            let  tar  =  await  AR . findOne ( { gid :  message . guild . id } ) ;   
					 
					 
					 
					            let  tar  =  await  AR . findOne ( { gid :  message . guild . id } ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  ( ! tar  ||  ! tar . triggers . length )  { return  message . channel . send ( "It's not like this server has any ARs for me to delete in the first place!" ) ; }   
					 
					 
					 
					            if  ( ! tar  ||  ! tar . triggers . length )  { return  message . channel . send ( "It's not like this server has any ARs for me to delete in the first place!" ) ; }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					            let  sar  =  sortARs ( tar ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            await  message . channel . send ( viewARs ( sar [ 0 ] ) . addField ( "Deletion" ,  "Please say the **number** of the AR you wish to delete." ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            let  collected   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            try  { collected  =  await  message . channel . awaitMessages ( m  =>  m . author . id  ===  message . author . id ,  { errors :  [ 'time' ] ,  time :  60000 ,  max :  1 } ) ; }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            catch  { return  message . channel . send ( "This question has timed out. Please try again!" ) ; }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            collected  =  collected . first ( ) . content . trim ( ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            if  ( isNaN ( Number ( collected ) ) )  { return  message . channel . send ( "You didn't reply with a number!" ) ; }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            let  id  =  Number ( collected ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            if  ( id  <  1  ||  id  >  tar . triggers . length )  { return  message . channel . send ( "Your number was either below 1 or doesn't have a trigger to match it." ) ; }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            try  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                tar . triggers . forEach ( t  =>  { if  ( t  ===  sar [ 1 ] [ id - 1 ] )  { delete  sar [ 1 ] [ id - 1 ] ;  delete  tar . ars [ sar [ 1 ] [ id - 1 ] ] } } ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                tar . triggers  =  sar [ 1 ] ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                tar . save ( ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                client . misc . cache . ar . set ( message . guild . id ,  tar . triggers ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                return  message . channel . send ( "I didn't like saying that anyway." ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					            }  catch  { return  message . channel . send ( "There seemed to have been a problem deleting that AR. Contact my devs if the problem persists." ) ; }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        }   
					 
					 
					 
					        }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        return  message . channel . send ( ` That's not a valid argument! Try  \` ${ prefix } help ar \` ` ) ;   
					 
					 
					 
					        return  message . channel . send ( ` That's not a valid argument! Try  \` ${ prefix } help ar \` ` ) ;