diff --git a/.gitignore b/.gitignore index 20de4d5..390a1c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules package-lock.json -config.json \ No newline at end of file +config.json +.prettierrc diff --git a/src/InterActivePlayMessage.js b/src/InterActivePlayMessage.js index 8e739d3..b26f3ee 100644 --- a/src/InterActivePlayMessage.js +++ b/src/InterActivePlayMessage.js @@ -3,7 +3,7 @@ const CONFIG = require("../config.json"); const { secondsToHms, ticksToSeconds } = require("./util"); const log = require("loglevel"); -function getProgressString(percent) { +const getProgressString = (percent) => { // the min with of the discord window allows for this many chars const NUMBER_OF_CHARS = 12; let string = ""; @@ -15,20 +15,21 @@ function getProgressString(percent) { } } return string; -} +}; + /** * * @param {String} string * @returns {String} */ // TODO do this with something like wcwidth -function getMaxWidthString(string) { +function getMaxWidthString = (string) => { const NUMBER_OF_CHARS = 12; if (string.length > NUMBER_OF_CHARS) { return string.slice(0, NUMBER_OF_CHARS - 3) + "..."; } return string; -} +}; class InterActivePlayMessage { // musicplayermessage diff --git a/src/interactivemsghandler.js b/src/interactivemsghandler.js index d951db5..ba1fdff 100644 --- a/src/interactivemsghandler.js +++ b/src/interactivemsghandler.js @@ -3,11 +3,11 @@ const CONFIG = require("../config.json"); const log = require("loglevel"); -var iapm; +var interactivePlayMessage; var updateInterval; -function init( +const init = ( message, title, artist, @@ -20,11 +20,11 @@ function init( onNext, onRepeat, playlistLenth -) { - if (typeof iapm !== "undefined") { +) => { + if (typeof interactivePlayMessage !== "undefined") { destroy(); } - iapm = new InterActivePlayMessage( + interactivePlayMessage = new InterActivePlayMessage( message, title, artist, @@ -38,12 +38,12 @@ function init( onRepeat, playlistLenth ); -} +}; -function destroy() { - if (typeof iapm !== "undefined") { - iapm.destroy(); - iapm = undefined; +const destroy = () => { + if (typeof interactivePlayMessage !== "undefined") { + interactivePlayMessage.destroy(); + interactivePlayMessage = undefined; } else { throw Error("No Interactive Message Found"); } @@ -52,31 +52,32 @@ function destroy() { clearInterval(updateInterval); updateInterval = undefined; } -} +}; -function hasMessage() { - if (typeof iapm === "undefined") { +const hasMessage = () => { + if (typeof interactivePlayMessage === "undefined") { return false; } else { return true; } -} +}; + /** * * @param {Function} callback function to retrieve current ticks */ -function startUpate(callback) { +const startUpate = (callback) => { if ( typeof CONFIG["interactive-seek-bar-update-intervall"] === "number" && CONFIG["interactive-seek-bar-update-intervall"] > 0 ) { updateInterval = setInterval(() => { - iapm.updateProgress(callback()); + interactivePlayMessage.updateProgress(callback()); }, CONFIG["interactive-seek-bar-update-intervall"]); } -} +}; -function updateCurrentSongMessage( +const updateCurrentSongMessage = ( title, artist, imageURL, @@ -84,11 +85,11 @@ function updateCurrentSongMessage( ticksLength, playlistIndex, playlistLenth -) { - log.log(iapm); +) => { + log.log(interactivePlayMessage); - if (typeof iapm !== "undefined") { - iapm.updateCurrentSongMessage( + if (typeof interactivePlayMessage !== "undefined") { + interactivePlayMessage.updateCurrentSongMessage( title, artist, imageURL, @@ -100,12 +101,12 @@ function updateCurrentSongMessage( } else { throw Error("No Interactive Message Found"); } -} +}; module.exports = { init, destroy, hasMessage, startUpate, - updateCurrentSongMessage, + updateCurrentSongMessage };