@ -6,20 +6,17 @@ const client = new Discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION']
import fetch from 'node-fetch' ;
import * as fs from 'fs' ;
/ * c o n s t D i s c o r d = r e q u i r e ( ' d i s c o r d . j s ' ) ;
const client = new Discord . Client ( { partials : [ 'MESSAGE' , 'CHANNEL' , 'REACTION' ] } ) ;
const fetch = require ( 'node-fetch' ) ;
const fs = require ( 'fs' ) ; * /
var hits = 0 ;
if ( fs . existsSync ( 'numhits.txt' ) ) {
fs . readFile ( 'numhits.txt' , 'utf8' , function ( err , data ) {
fs . readFile ( 'numhits.txt' , 'utf8' , function ( err , data ) {
hits = data ;
if ( err ) {
console . log ( err ) ;
}
} ) ;
} else {
fs . writeFile ( 'numhits.txt' , hits , ( error ) => { if ( error ) { console . log ( error ) ; } } ) ;
}
@ -71,7 +68,7 @@ client.on('message', async message => {
fs . appendFile ( 'round.html' , htmlContent , ( error ) => { if ( error ) { console . log ( error ) ; } } ) ;
} ) ;
}
generatingMsg . delete ( { timeout : 1000 } ) ;
generatingMsg . delete ( { timeout : 1000 } ) ;
setTimeout ( function ( ) { person . send ( new Discord . MessageEmbed ( ) . setTitle ( "Here's your round!" ) . attachFiles ( "round.html" ) ) ; } , 1000 ) ;
hits ++ ;
}
@ -104,7 +101,7 @@ client.on('message', async message => {
fs . appendFile ( 'round.html' , htmlContent , ( error ) => { if ( error ) { console . log ( error ) ; } } ) ;
} ) ;
}
generatingMsg . delete ( { timeout : 1000 } ) ;
generatingMsg . delete ( { timeout : 1000 } ) ;
setTimeout ( function ( ) { message . channel . send ( new Discord . MessageEmbed ( ) . setTitle ( "Here's your round!" ) . attachFiles ( "round.html" ) ) ; } , 1000 ) ;
hits ++ ;
}
@ -138,7 +135,7 @@ client.on('message', async message => {
fs . appendFile ( 'index.html' , htmlContent , ( error ) => { if ( error ) { console . log ( error ) ; } } ) ;
} ) ;
}
generatingMsg . delete ( { timeout : 1000 } ) ;
generatingMsg . delete ( { timeout : 1000 } ) ;
var output = execSync ( "curl --request POST --url http://localhost:3136/convert/html --header 'Content-Type: multipart/form-data' --form files=@index.html -o round.pdf" , { encoding : 'utf-8' } ) ;
//console.log(output);
setTimeout ( function ( ) { person . send ( new Discord . MessageEmbed ( ) . setTitle ( "Here's your round!" ) . attachFiles ( "round.pdf" ) ) ; } , 1000 ) ;
@ -174,7 +171,7 @@ client.on('message', async message => {
fs . appendFile ( 'index.html' , htmlContent , ( error ) => { if ( error ) { console . log ( error ) ; } } ) ;
} ) ;
}
generatingMsg . delete ( { timeout : 1000 } ) ;
generatingMsg . delete ( { timeout : 1000 } ) ;
var output = execSync ( "curl --request POST --url http://localhost:3136/convert/html --header 'Content-Type: multipart/form-data' --form files=@index.html -o round.pdf" , { encoding : 'utf-8' } ) ;
//console.log(output);
message . channel . send ( new Discord . MessageEmbed ( ) . setTitle ( "Here's your round!" ) . attachFiles ( "round.pdf" ) ) ;
@ -189,24 +186,24 @@ client.on('message', async message => {
const collector = message . channel . createMessageCollector ( filter , { time : 1500000 } ) ;
collector . on ( 'collect' , m => {
if ( m . content . toLowerCase ( ) === "do be scoring a 4" ) {
m . delete ( { timeout : 1000 } ) ;
m . delete ( { timeout : 1000 } ) ;
scoreA += 4 ;
scoreboard . channel . send ( ` Here's the score: \n Team A: ${ scoreA } \n Team B: ${ scoreB } ` ) ;
} else if ( m . content . toLowerCase ( ) === "do be scoring a 10" ) {
m . delete ( { timeout : 1000 } ) ;
m . delete ( { timeout : 1000 } ) ;
scoreA += 10 ;
scoreboard . channel . send ( ` Here's the score: \n Team A: ${ scoreA } \n Team B: ${ scoreB } ` ) ;
} else if ( m . content . toLowerCase ( ) === "do be scoring b 4" ) {
m . delete ( { timeout : 1000 } ) ;
m . delete ( { timeout : 1000 } ) ;
scoreB += 4 ;
scoreboard . channel . send ( ` Here's the score: \n Team A: ${ scoreA } \n Team B: ${ scoreB } ` ) ;
} else if ( m . content . toLowerCase ( ) === "do be scoring b 10" ) {
m . delete ( { timeout : 1000 } ) ;
m . delete ( { timeout : 1000 } ) ;
scoreB += 10 ;
scoreboard . channel . send ( ` Here's the score: \n Team A: ${ scoreA } \n Team B: ${ scoreB } ` ) ;
} else if ( m . content === "do be scoring stop" ) {
m . delete ( { timeout : 1000 } ) ;
scoreboard . delete ( { timeout : 1000 } ) ;
m . delete ( { timeout : 1000 } ) ;
scoreboard . delete ( { timeout : 1000 } ) ;
m . channel . send ( ` **FINAL SCORE:** \n Team A: ${ scoreA } \n Team B: ${ scoreB } ` ) ;
collector . stop ( ) ;
}
@ -231,7 +228,7 @@ client.on('message', async message => {
// console.log(data.people[i]);
// astros += `${data.people[i]}\n`;
//}
message . channel . send ( new Discord . MessageEmbed ( ) . setTitle ( "The current location of the ISS!" ) . setImage ( ` https://api.mapbox.com/styles/v1/mapbox/light-v10/static/pin-s-l +000( ${ data . iss_position . longitude } , ${ data . iss_position . latitude } )/-87.0186,20,1/1000x1000?access_token=pk.eyJ1IjoiYWRhd2Vzb21lZ3V5IiwiYSI6ImNrbGpuaWdrYzJ0bGYydXBja2xsNmd2YTcifQ.Ude0UFOf9lFcQ-3BANWY5A ` ) . setURL ( 'https://spotthestation.nasa.gov/tracking_map.cfm' ) / * . addFields (
message . channel . send ( new Discord . MessageEmbed ( ) . setTitle ( "The current location of the ISS!" ) . setImage ( ` https://api.mapbox.com/styles/v1/mapbox/light-v10/static/pin-s+000( ${ data . iss_position . longitude } , ${ data . iss_position . latitude } )/-87.0186,20,1/1000x1000?access_token=pk.eyJ1IjoiYWRhd2Vzb21lZ3V5IiwiYSI6ImNrbGpuaWdrYzJ0bGYydXBja2xsNmd2YTcifQ.Ude0UFOf9lFcQ-3BANWY5A ` ) . setURL ( 'https://spotthestation.nasa.gov/tracking_map.cfm' ) / * . addFields (
{ name : 'Current inhabitants' , value : ` ${ astros } ` }
) * / ) ;
} ) ;