Last active
April 21, 2018 20:29
-
-
Save TobiasFeld22/a16594edc61bdf34d0bc470791c61cb9 to your computer and use it in GitHub Desktop.
engine to connect to the spark dashboard on v0.1+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint prefer-destructuring: 0*/ | |
var Spark = require("Spark") | |
const io = require("socket.io-client") | |
const Engine = Spark.engine("Spark-dashboard") | |
const version = "1" | |
Engine.code = (client) => { | |
if (!client.config.apiKey) { | |
return | |
} | |
client.socket = io("https://dashboard.discordspark.com/", { | |
query: { | |
token: client.config.apiKey, | |
bot_name: client.user.tag, | |
bot_id: client.user.id, | |
version, | |
} | |
}) | |
client.socket.on("connect", function() { | |
console.log("Successfully authenticated with the dashboard."); | |
setTimeout(userUpdate, 3600000) | |
userUpdate() | |
}).on("disconnect", function() { | |
console.log("disconnected from the dashboard."); | |
}) | |
process.on("uncaughtException", function(err) { | |
client.socket.emit("error_report", new Date(), err); | |
throw err | |
}); | |
function userUpdate() { | |
client.socket.emit("userUpdate", { | |
icon: client.user.displayAvatarURL, | |
bot_name: client.user.tag, | |
bot_id: client.user.id | |
}) | |
} | |
} | |
Engine.export(module) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment