2021-03-01 00:54:01 +00:00
const fetch = require ( 'node-fetch' ) ;
const prettifyMiliseconds = require ( 'pretty-ms' ) ;
const { createPaginationEmbed } = require ( 'eris-pagination' ) ;
module . exports = class {
constructor ( name , category ) {
this . name = name ,
this . category = category ,
this . enabled = true ,
this . devOnly = false ,
this . aliases = [ 'splatoonmodes' ] ,
this . userPerms = [ ] ,
this . botPerms = [ ] ,
2021-03-01 22:35:35 +00:00
this . cooldown = 30000 ,
2021-03-01 00:54:01 +00:00
this . help = {
description : 'Get current and upcoming maps and modes for regular, ranked and league battles.' ,
arguments : '' ,
details : '' ,
examples : ''
} ;
}
run ( client , message , args , data ) { //eslint-disable-line no-unused-vars
message . channel . sendTyping ( ) ;
fetch ( 'https://splatoon2.ink/data/schedules.json' , { headers : { 'User-Agent' : client . config . userAgent } } )
. then ( res => res . json ( ) )
. then ( json => {
const embeds = [
new client . RichEmbed ( )
. setTitle ( 'Current Splatoon 2 Maps' )
2021-03-04 01:46:21 +00:00
. setColour ( client . functions . displayHexColour ( message . channel . guild ) )
2021-03-01 00:54:01 +00:00
. addField ( '<:turf_war:814651383911153692> Turf War' , ` ${ json . regular [ 0 ] . stage _a . name } \n ${ json . regular [ 0 ] . stage _b . name } ` , true )
. addField ( ` <:ranked:814651402479468544> Ranked: ${ json . gachi [ 0 ] . rule . name } ` , ` ${ json . gachi [ 0 ] . stage _a . name } \n ${ json . gachi [ 0 ] . stage _b . name } ` , true )
. addField ( ` <:league:814651415409590363> League: ${ json . league [ 0 ] . rule . name } ` , ` ${ json . league [ 0 ] . stage _a . name } \n ${ json . league [ 0 ] . stage _b . name } ` , true )
. setFooter ( ` Maps changing in ${ prettifyMiliseconds ( json . league [ 0 ] . end _time * 1000 - Date . now ( ) , { secondsDecimalDigits : 0 } )} | Data provided by splatoon2.ink ` )
] ;
for ( let i = 1 ; i < json . regular . length ; i ++ ) {
const embed = new client . RichEmbed ( )
. setTitle ( 'Upcoming Splatoon 2 Maps' )
2021-03-04 01:46:21 +00:00
. setColour ( client . functions . displayHexColour ( message . channel . guild ) )
2021-03-01 00:54:01 +00:00
. addField ( '<:turf_war:814651383911153692> Turf War' , ` ${ json . regular [ i ] . stage _a . name } \n ${ json . regular [ i ] . stage _b . name } ` , true )
. addField ( ` <:ranked:814651402479468544> Ranked: ${ json . gachi [ i ] . rule . name } ` , ` ${ json . gachi [ i ] . stage _a . name } \n ${ json . gachi [ i ] . stage _b . name } ` , true )
. addField ( ` <:league:814651415409590363> League: ${ json . league [ i ] . rule . name } ` , ` ${ json . league [ i ] . stage _a . name } \n ${ json . league [ i ] . stage _b . name } ` , true )
. setFooter ( ` Available in ${ prettifyMiliseconds ( json . league [ i ] . start _time * 1000 - Date . now ( ) , { secondsDecimalDigits : 0 } )} | Data provided by splatoon2.ink ` ) ;
embeds . push ( embed ) ;
}
createPaginationEmbed ( message , embeds ) ;
} )
. catch ( err => {
2021-07-15 02:26:42 +00:00
message . channel . createMessage ( ` ${ client . config . emojis . botError } An error has occurred: ${ err } ` ) ;
2021-03-01 00:54:01 +00:00
} ) ;
}
} ;