Code Reformatting

pull/11/head
Trivernis 6 years ago
parent 2400429b72
commit 98b809ba66

@ -35,7 +35,7 @@ function main() {
} }
}) })
}); });
client.login(authToken).then(()=> { client.login(authToken).then(() => {
logger.debug("Logged in"); logger.debug("Logged in");
}); });
@ -44,19 +44,20 @@ function main() {
function registerCommands() { function registerCommands() {
cmd.createGlobalCommand(prefix + 'ping', () => { cmd.createGlobalCommand(prefix + 'ping', () => {
return 'Pong!'; return 'Pong!';
}, [], "Try it yourself."); }, [], "Try it yourself.");
cmd.createGlobalCommand(prefix + 'repeatafterme', (msg, argv, args) => { cmd.createGlobalCommand(prefix + 'repeatafterme', (msg, argv, args) => {
return args.join(' '); return args.join(' ');
},[], "Repeats what you say"); }, [], "Repeats what you say");
cmd.createGlobalCommand(prefix + 'addpresence', (msg, argv, args) => { cmd.createGlobalCommand(prefix + 'addpresence', (msg, argv, args) => {
let p = args.join(' '); let p = args.join(' ');
presences.push(p); presences.push(p);
fs.writeFile('./data/presences.txt', presences.join('\n'), (err) => {}); fs.writeFile('./data/presences.txt', presences.join('\n'), (err) => {
});
return `Added Presence \`${p}\``; return `Added Presence \`${p}\``;
},[], "Adds a presence to the rotation.", 'owner'); }, [], "Adds a presence to the rotation.", 'owner');
cmd.createGlobalCommand(prefix + 'shutdown', (msg) => { cmd.createGlobalCommand(prefix + 'shutdown', (msg) => {
msg.reply('Shutting down...').finally(() => { msg.reply('Shutting down...').finally(() => {
@ -66,7 +67,7 @@ function registerCommands() {
process.exit(0); process.exit(0);
}); });
}); });
},[], "Shuts the bot down.", 'owner'); }, [], "Shuts the bot down.", 'owner');
cmd.createGlobalCommand(prefix + 'rotate', () => { cmd.createGlobalCommand(prefix + 'rotate', () => {
try { try {

@ -50,7 +50,7 @@ const winston = require('winston'),
* A function to return the logger that has been created after appending an exception handler * A function to return the logger that has been created after appending an exception handler
* @returns {Object} * @returns {Object}
*/ */
exports.getLogger = function() { exports.getLogger = function () {
logger.exceptions.handle( logger.exceptions.handle(
new winston.transports.File({ new winston.transports.File({
filename: './.log/exceptions.log' filename: './.log/exceptions.log'

@ -11,7 +11,7 @@ let connections = {};
/* Function Definition */ /* Function Definition */
exports.DJ = class{ exports.DJ = class {
constructor(voiceChannel) { constructor(voiceChannel) {
this.conn = null; this.conn = null;
this.disp = null; this.disp = null;
@ -80,7 +80,7 @@ exports.DJ = class{
setTimeout(() => { setTimeout(() => {
if (this.voiceChannel && this.voiceChannel.members.size === 1) if (this.voiceChannel && this.voiceChannel.members.size === 1)
logger.verbose(`Exiting ${this.voiceChannel.name}`); logger.verbose(`Exiting ${this.voiceChannel.name}`);
this.stop(); this.stop();
}, 300000); }, 300000);
} else if (this.connected) } else if (this.connected)
setTimeout(() => this.checkListeners(), 10000); setTimeout(() => this.checkListeners(), 10000);
@ -226,7 +226,7 @@ exports.DJ = class{
this.voiceChannel.leave(); this.voiceChannel.leave();
logger.debug("Left VoiceChannel"); logger.debug("Left VoiceChannel");
} }
} catch(error) { } catch (error) {
logger.verbose(JSON.stringify(error)); logger.verbose(JSON.stringify(error));
} }
} }
@ -236,7 +236,7 @@ exports.DJ = class{
* end event of the dispatcher that automatically plays the next song. If no dispatcher is found * end event of the dispatcher that automatically plays the next song. If no dispatcher is found
* It tries to play the next song with playYouTube * It tries to play the next song with playYouTube
*/ */
skip () { skip() {
logger.debug("Skipping song"); logger.debug("Skipping song");
if (this.disp !== null) { if (this.disp !== null) {
this.disp.end(); this.disp.end();
@ -298,7 +298,7 @@ exports.setLogger = function (newLogger) {
* Connects to a voicechannel * Connects to a voicechannel
* @param voiceChannel * @param voiceChannel
*/ */
exports.connect = function(voiceChannel) { exports.connect = function (voiceChannel) {
let gid = voiceChannel.guild.id; let gid = voiceChannel.guild.id;
let voiceDJ = new this.DJ(voiceChannel); let voiceDJ = new this.DJ(voiceChannel);
djs[gid] = voiceDJ; djs[gid] = voiceDJ;
@ -310,7 +310,7 @@ exports.connect = function(voiceChannel) {
* @param filename * @param filename
* @param guildId * @param guildId
*/ */
exports.playFile = function(guildId, filename) { exports.playFile = function (guildId, filename) {
djs[guildId].playFile(filename); djs[guildId].playFile(filename);
}; };
@ -319,7 +319,7 @@ exports.playFile = function(guildId, filename) {
* @param voiceChannel * @param voiceChannel
* @param url * @param url
*/ */
exports.play = function(voiceChannel, url) { exports.play = function (voiceChannel, url) {
let guildId = voiceChannel.guild.id; let guildId = voiceChannel.guild.id;
if (!djs[guildId]) { if (!djs[guildId]) {
this.connect(voiceChannel).then(() => { this.connect(voiceChannel).then(() => {
@ -335,7 +335,7 @@ exports.play = function(voiceChannel, url) {
* @param voiceChannel * @param voiceChannel
* @param url * @param url
*/ */
exports.playnext = function(voiceChannel, url) { exports.playnext = function (voiceChannel, url) {
let guildId = voiceChannel.guild.id; let guildId = voiceChannel.guild.id;
if (!djs[guildId]) { if (!djs[guildId]) {
this.connect(voiceChannel).then(() => { this.connect(voiceChannel).then(() => {
@ -351,14 +351,14 @@ exports.playnext = function(voiceChannel, url) {
* @param percentage * @param percentage
* @param guildId * @param guildId
*/ */
exports.setVolume = function(guildId, percentage) { exports.setVolume = function (guildId, percentage) {
djs[guildId].setVolume(percentage); djs[guildId].setVolume(percentage);
}; };
/** /**
* pauses the music * pauses the music
*/ */
exports.pause = function(guildId) { exports.pause = function (guildId) {
djs[guildId].pause(); djs[guildId].pause();
}; };
@ -366,7 +366,7 @@ exports.pause = function(guildId) {
* Resumes the music * Resumes the music
* @param guildId * @param guildId
*/ */
exports.resume = function(guildId) { exports.resume = function (guildId) {
djs[guildId].resume(); djs[guildId].resume();
}; };
@ -374,7 +374,7 @@ exports.resume = function(guildId) {
* Stops the music * Stops the music
* @param guildId * @param guildId
*/ */
exports.stop = function(guildId) { exports.stop = function (guildId) {
djs[guildId].stop(); djs[guildId].stop();
delete djs[guildId]; delete djs[guildId];
}; };
@ -383,7 +383,7 @@ exports.stop = function(guildId) {
* Skips the song * Skips the song
* @param guildId * @param guildId
*/ */
exports.skip = function(guildId) { exports.skip = function (guildId) {
djs[guildId].skip(); djs[guildId].skip();
}; };
@ -391,7 +391,7 @@ exports.skip = function(guildId) {
* Clears the playlist * Clears the playlist
* @param guildId * @param guildId
*/ */
exports.clearQueue = function(guildId) { exports.clearQueue = function (guildId) {
djs[guildId].clear(); djs[guildId].clear();
}; };
@ -399,7 +399,7 @@ exports.clearQueue = function(guildId) {
* Returns the queue * Returns the queue
* @param guildId * @param guildId
*/ */
exports.getQueue = function(guildId) { exports.getQueue = function (guildId) {
return djs[guildId].playlist; return djs[guildId].playlist;
}; };
@ -407,7 +407,7 @@ exports.getQueue = function(guildId) {
* evokes the callback function with the title of the current song * evokes the callback function with the title of the current song
* @param guildId * @param guildId
*/ */
exports.nowPlaying = function(guildId) { exports.nowPlaying = function (guildId) {
return djs[guildId].song; return djs[guildId].song;
}; };
@ -415,7 +415,7 @@ exports.nowPlaying = function(guildId) {
* shuffles the queue * shuffles the queue
* @param guildId * @param guildId
*/ */
exports.shuffle = function(guildId) { exports.shuffle = function (guildId) {
djs[guildId].shuffle(); djs[guildId].shuffle();
}; };

@ -3,7 +3,9 @@
*/ */
const fs = require('fs'); const fs = require('fs');
function noOp() {} function noOp() {
}
let sysdataPath = './res/data/sys.json'; let sysdataPath = './res/data/sys.json';
let sysData = {}; let sysData = {};
@ -35,7 +37,7 @@ exports.Cleanup = function Cleanup(callback) {
// attach user callback to the process event emitter // attach user callback to the process event emitter
// if no callback, it will still exit gracefully on Ctrl-C // if no callback, it will still exit gracefully on Ctrl-C
callback = callback || noOp; callback = callback || noOp;
process.on('cleanup',callback); process.on('cleanup', callback);
// do app specific cleaning before exiting // do app specific cleaning before exiting
process.on('exit', function () { process.on('exit', function () {
@ -49,7 +51,7 @@ exports.Cleanup = function Cleanup(callback) {
}); });
//catch uncaught exceptions, trace, then exit normally //catch uncaught exceptions, trace, then exit normally
process.on('uncaughtException', function(e) { process.on('uncaughtException', function (e) {
console.log('Uncaught Exception...'); console.log('Uncaught Exception...');
console.log(e.stack); console.log(e.stack);
process.exit(99); process.exit(99);
@ -58,7 +60,7 @@ exports.Cleanup = function Cleanup(callback) {
/* FS */ /* FS */
exports.dirExistence = function(path, callback) { exports.dirExistence = function (path, callback) {
fs.exists(path, (exist) => { fs.exists(path, (exist) => {
if (!exist) { if (!exist) {
fs.mkdir(path, (err) => { fs.mkdir(path, (err) => {

Loading…
Cancel
Save