mirror of
				https://github.com/warengroup/eximiabots-radiox.git
				synced 2025-11-04 01:09:32 +00:00 
			
		
		
		
	Large update
This commit is contained in:
		@@ -1,31 +0,0 @@
 | 
				
			|||||||
module.exports = {
 | 
					 | 
				
			||||||
    name: 'cmduses',
 | 
					 | 
				
			||||||
    alias: 'none',
 | 
					 | 
				
			||||||
    usage: '',
 | 
					 | 
				
			||||||
    description: 'list all commands and how many times they\'ve been used',
 | 
					 | 
				
			||||||
    onlyDev: true,
 | 
					 | 
				
			||||||
    permission: 'dev',
 | 
					 | 
				
			||||||
    category: 'info',
 | 
					 | 
				
			||||||
    async execute(msg, args, client, Discord) {
 | 
					 | 
				
			||||||
        const cmduses = [];
 | 
					 | 
				
			||||||
        client.commands.forEach((value, key) => {
 | 
					 | 
				
			||||||
            cmduses.push([key, value.uses]);
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
        cmduses.sort((a, b) => {
 | 
					 | 
				
			||||||
            return b[1] - a[1];
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
        const cmdnamelength = Math.max(...cmduses.map(x => x[0].length)) + 4;
 | 
					 | 
				
			||||||
        const numberlength = Math.max(...cmduses.map(x => x[1].toString().length), 4);
 | 
					 | 
				
			||||||
        const markdownrows = ['Command' + ' '.repeat(cmdnamelength - 'command'.length) + ' '.repeat(numberlength - 'uses'.length) + 'Uses'];
 | 
					 | 
				
			||||||
        cmduses.forEach(x => {
 | 
					 | 
				
			||||||
            if (x[1] > 0) markdownrows.push(x[0] + '.'.repeat(cmdnamelength - x[0].length) + ' '.repeat(numberlength - x[1].toString().length) + x[1].toString());
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
        const embed = new Discord.MessageEmbed();
 | 
					 | 
				
			||||||
        embed
 | 
					 | 
				
			||||||
            .setTitle('Musix Command Usage During Current Uptime')
 | 
					 | 
				
			||||||
            .setDescription('```ml\n' + markdownrows.join('\n') + '\n```')
 | 
					 | 
				
			||||||
            .setFooter('These statistics are from the current uptime.')
 | 
					 | 
				
			||||||
            .setColor(client.config.embedColor);
 | 
					 | 
				
			||||||
        msg.channel.send(embed);
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@@ -1,24 +0,0 @@
 | 
				
			|||||||
module.exports = {
 | 
					 | 
				
			||||||
    name: 'eval',
 | 
					 | 
				
			||||||
    alias: 'e',
 | 
					 | 
				
			||||||
    usage: '<code>',
 | 
					 | 
				
			||||||
    description: 'Evaluation command. DEV ONLY!',
 | 
					 | 
				
			||||||
    onlyDev: true,
 | 
					 | 
				
			||||||
    permission: 'dev',
 | 
					 | 
				
			||||||
    category: 'util',
 | 
					 | 
				
			||||||
    async execute(msg, args, client, Discord, prefix) {
 | 
					 | 
				
			||||||
        const radio = client.radio.get(msg.guild.id);
 | 
					 | 
				
			||||||
        const input = msg.content.slice(prefix.length + 4);
 | 
					 | 
				
			||||||
        let output;
 | 
					 | 
				
			||||||
        try {
 | 
					 | 
				
			||||||
            output = await eval(input);
 | 
					 | 
				
			||||||
        } catch (error) {
 | 
					 | 
				
			||||||
            output = error.toString();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        const embed = new Discord.MessageEmbed()
 | 
					 | 
				
			||||||
            .setTitle('Evaluation Command')
 | 
					 | 
				
			||||||
            .setColor(client.config.embedColor)
 | 
					 | 
				
			||||||
            .setDescription(`Input: \`\`\`js\n${input.replace(/; /g, ';').replace(/;/g, ';\n')}\n\`\`\`\nOutput: \`\`\`\n${output}\n\`\`\``);
 | 
					 | 
				
			||||||
        return msg.channel.send(embed);
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@@ -1,24 +0,0 @@
 | 
				
			|||||||
module.exports = {
 | 
					 | 
				
			||||||
    name: 'join',
 | 
					 | 
				
			||||||
    alias: 'j',
 | 
					 | 
				
			||||||
    usage: '',
 | 
					 | 
				
			||||||
    description: 'Make Musix join the channel your channel',
 | 
					 | 
				
			||||||
    onlyDev: true,
 | 
					 | 
				
			||||||
    permission: 'none',
 | 
					 | 
				
			||||||
    category: 'util',
 | 
					 | 
				
			||||||
    async execute(msg, args, client, Discord, prefix) {
 | 
					 | 
				
			||||||
        try {
 | 
					 | 
				
			||||||
            const radio = client.radio.get(msg.guild.id);
 | 
					 | 
				
			||||||
            const voiceChannel = msg.member.voice.channel;
 | 
					 | 
				
			||||||
            const connection = await voiceChannel.join();
 | 
					 | 
				
			||||||
            if (radio) {
 | 
					 | 
				
			||||||
                radio.connection = connection;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            msg.channel.send(`<:green_check_mark:674265384777416705> Joined ${voiceChannel.name}!`);
 | 
					 | 
				
			||||||
        } catch (error) {
 | 
					 | 
				
			||||||
            client.radio.delete(msg.guild.id);
 | 
					 | 
				
			||||||
            client.channels.fetch(client.config.debug_channel).send("Error with connecting to voice channel: " + error);
 | 
					 | 
				
			||||||
            return msg.channel.send(`<:redx:674263474704220182> An error occured: ${error}`);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@@ -7,7 +7,6 @@ module.exports = {
 | 
				
			|||||||
	permission: 'none',
 | 
						permission: 'none',
 | 
				
			||||||
	category: 'music',
 | 
						category: 'music',
 | 
				
			||||||
	async execute(msg, args, client, Discord, prefix) {
 | 
						async execute(msg, args, client, Discord, prefix) {
 | 
				
			||||||
		const searchString = args.slice(1).join(" ");
 | 
					 | 
				
			||||||
		const url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
 | 
							const url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
 | 
				
			||||||
		const radio = client.radio.get(msg.guild.id);
 | 
							const radio = client.radio.get(msg.guild.id);
 | 
				
			||||||
		const voiceChannel = msg.member.voice.channel;
 | 
							const voiceChannel = msg.member.voice.channel;
 | 
				
			||||||
@@ -24,6 +23,30 @@ module.exports = {
 | 
				
			|||||||
		if (!permissions.has('SPEAK')) {
 | 
							if (!permissions.has('SPEAK')) {
 | 
				
			||||||
			return msg.channel.send('<:redx:674263474704220182> I cannot speak in your voice channel, make sure I have the proper permissions!');
 | 
								return msg.channel.send('<:redx:674263474704220182> I cannot speak in your voice channel, make sure I have the proper permissions!');
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return client.funcs.handleRadio(msg, voiceChannel, client, url);
 | 
					
 | 
				
			||||||
 | 
							if (radio) {
 | 
				
			||||||
 | 
								radio.connection.dispatcher.end();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							const construct = {
 | 
				
			||||||
 | 
								textChannel: msg.channel,
 | 
				
			||||||
 | 
								voiceChannel: voiceChannel,
 | 
				
			||||||
 | 
								connection: null,
 | 
				
			||||||
 | 
								playing: false,
 | 
				
			||||||
 | 
								url: url,
 | 
				
			||||||
 | 
								name: null,
 | 
				
			||||||
 | 
								volume: client.config.volume,
 | 
				
			||||||
 | 
							};
 | 
				
			||||||
 | 
							client.radio.set(msg.guild.id, construct);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							try {
 | 
				
			||||||
 | 
								const connection = await voiceChannel.join();
 | 
				
			||||||
 | 
								construct.connection = connection;
 | 
				
			||||||
 | 
								client.funcs.play(msg.guild, client, url);
 | 
				
			||||||
 | 
							} catch (error) {
 | 
				
			||||||
 | 
								client.radio.delete(msg.guild.id);
 | 
				
			||||||
 | 
								client.debug_channel.send("Error with connecting to voice channel: " + error);
 | 
				
			||||||
 | 
								return msg.channel.send(`<:redx:674263474704220182> An error occured: ${error}`);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,30 +0,0 @@
 | 
				
			|||||||
const fs = require('fs');
 | 
					 | 
				
			||||||
const path = require('path')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
module.exports = {
 | 
					 | 
				
			||||||
    name: 'reload',
 | 
					 | 
				
			||||||
    alias: 'none',
 | 
					 | 
				
			||||||
    usage: '',
 | 
					 | 
				
			||||||
    description: 'Reload all files',
 | 
					 | 
				
			||||||
    onlyDev: true,
 | 
					 | 
				
			||||||
    permission: 'none',
 | 
					 | 
				
			||||||
    category: 'util',
 | 
					 | 
				
			||||||
    async execute(msg, args, client, Discord, prefix, command) {
 | 
					 | 
				
			||||||
        const commandFiles = fs.readdirSync(path.join(path.dirname(__dirname), 'commands')).filter(f => f.endsWith('.js'));
 | 
					 | 
				
			||||||
        for (const file of commandFiles) {
 | 
					 | 
				
			||||||
            const command = require(`./${file}`);
 | 
					 | 
				
			||||||
            command.uses = 0;
 | 
					 | 
				
			||||||
            client.commands.set(command.name, command);
 | 
					 | 
				
			||||||
            client.commandAliases.set(command.alias, command);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        const settingFiles = fs.readdirSync(path.join(path.dirname(__dirname), 'commands/settings')).filter(f => f.endsWith('.js'));
 | 
					 | 
				
			||||||
        for (const file of settingFiles) {
 | 
					 | 
				
			||||||
            const option = require(`./settings/${file}`);
 | 
					 | 
				
			||||||
            client.settingCmd.set(option.name, option);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        /*fs.readdirSync(path.join(__dirname, 'funcs')).forEach(filename => {
 | 
					 | 
				
			||||||
            this.funcs[filename.slice(0, -3)] = require(`../struct/funcs/${filename}`);
 | 
					 | 
				
			||||||
        });*/
 | 
					 | 
				
			||||||
        msg.channel.send('All files reloaded!');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@@ -1,14 +0,0 @@
 | 
				
			|||||||
module.exports = {
 | 
					 | 
				
			||||||
    name: 'restart',
 | 
					 | 
				
			||||||
    alias: 'none',
 | 
					 | 
				
			||||||
    usage: '',
 | 
					 | 
				
			||||||
    description: 'Restart the bot',
 | 
					 | 
				
			||||||
    onlyDev: true,
 | 
					 | 
				
			||||||
    permission: 'none',
 | 
					 | 
				
			||||||
    category: 'util',
 | 
					 | 
				
			||||||
    async execute(msg, args, client, Discord, prefix, command) {
 | 
					 | 
				
			||||||
        client.destroy();
 | 
					 | 
				
			||||||
        require('../index.js');
 | 
					 | 
				
			||||||
        msg.channel.send('restarted!');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@@ -9,7 +9,7 @@ module.exports = {
 | 
				
			|||||||
	execute(msg, args, client, Discord, prefix, command) {
 | 
						execute(msg, args, client, Discord, prefix, command) {
 | 
				
			||||||
		const radio = client.radio.get(msg.guild.id);
 | 
							const radio = client.radio.get(msg.guild.id);
 | 
				
			||||||
		if (client.funcs.check(client, msg, command)) {
 | 
							if (client.funcs.check(client, msg, command)) {
 | 
				
			||||||
			radio.connection.dispatcher.end('Stopped');
 | 
								radio.connection.dispatcher.end();
 | 
				
			||||||
			msg.channel.send('<:stop:674685626108477519> Stopped the music!')
 | 
								msg.channel.send('<:stop:674685626108477519> Stopped the music!')
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,6 @@ module.exports = {
 | 
				
			|||||||
	description: 'Volume command.',
 | 
						description: 'Volume command.',
 | 
				
			||||||
	alias: 'none',
 | 
						alias: 'none',
 | 
				
			||||||
	usage: '<volume>',
 | 
						usage: '<volume>',
 | 
				
			||||||
	cooldown: 5,
 | 
					 | 
				
			||||||
	onlyDev: false,
 | 
						onlyDev: false,
 | 
				
			||||||
	permission: 'MANAGE_MESSAGES',
 | 
						permission: 'MANAGE_MESSAGES',
 | 
				
			||||||
	category: 'music',
 | 
						category: 'music',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +1,11 @@
 | 
				
			|||||||
module.exports = {
 | 
					module.exports = {
 | 
				
			||||||
    name: 'ready',
 | 
					    name: 'ready',
 | 
				
			||||||
    async execute(client, Discord) {
 | 
					    async execute(client, Discord) {
 | 
				
			||||||
 | 
					        const debugChannel = await client.channels.fetch(client.config.debug_channel);
 | 
				
			||||||
 | 
					        client.debug_channel = debugChannel
 | 
				
			||||||
        if (client.config.devMode) {
 | 
					        if (client.config.devMode) {
 | 
				
			||||||
            console.log('dev mode');
 | 
					            console.log('dev mode');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        client.user.setActivity(`@${client.user.username} help | 🎶`, { type: 'LISTENING' });
 | 
					 | 
				
			||||||
        client.user.setStatus('online');
 | 
					 | 
				
			||||||
        console.log('- Activated -');
 | 
					        console.log('- Activated -');
 | 
				
			||||||
        setInterval(() => {
 | 
					 | 
				
			||||||
            client.funcs.ffmpeg(client, Discord);
 | 
					 | 
				
			||||||
        }, 7200000);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,13 +1,32 @@
 | 
				
			|||||||
module.exports = {
 | 
					module.exports = {
 | 
				
			||||||
    name: 'voiceStateUpdate',
 | 
					    name: 'voiceStateUpdate',
 | 
				
			||||||
    async execute(client, newMember) {
 | 
					    async execute(client, oldState, newState) {
 | 
				
			||||||
        const serverQueue = client.radio.get(newMember.guild.id);
 | 
					        let change = false;
 | 
				
			||||||
        if (!serverQueue) return;
 | 
					        const radio = client.radio.get(newState.guild.id);
 | 
				
			||||||
        if (newMember === client.user) {
 | 
					        if (!radio) return;
 | 
				
			||||||
            if (newMember.voice.channel !== serverQueue.voiceChannel) {
 | 
					        if (newState.member.id === client.user.id && oldState.member.id === client.user.id) {
 | 
				
			||||||
                serverQueue.voiceChannel = newMember.voice.channel;
 | 
					            if (newState.member.voice.channel === null) {
 | 
				
			||||||
                console.log(`Changed serverQueue voiceChannel since Musix was moved to a different channel!`);
 | 
					                radio.songs = [];
 | 
				
			||||||
            }
 | 
					                radio.looping = false;
 | 
				
			||||||
 | 
					                radio.endReason = "manual disconnect";
 | 
				
			||||||
 | 
					                return client.queue.delete(newState.guild.id);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (newState.member.voice.channel !== radio.voiceChannel) {
 | 
				
			||||||
 | 
					                change = true;
 | 
				
			||||||
 | 
					                radio.voiceChannel = newState.member.voice.channel;
 | 
				
			||||||
 | 
					                radio.connection = newState.connection;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (oldState.channel === null) return;
 | 
				
			||||||
 | 
					        if (oldState.channel.members.size === 1 && oldState.channel === radio.voiceChannel || change) {
 | 
				
			||||||
 | 
					            setTimeout(() => {
 | 
				
			||||||
 | 
					                if (!radio) return;
 | 
				
			||||||
 | 
					                if (radio.voiceChannel.members.size === 1) {
 | 
				
			||||||
 | 
					                    radio.songs = [];
 | 
				
			||||||
 | 
					                    radio.looping = false;
 | 
				
			||||||
 | 
					                    radio.connection.dispatcher.end();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }, 12000);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,8 +39,8 @@ module.exports = class extends Client {
 | 
				
			|||||||
        this.on('message', (msg) => {
 | 
					        this.on('message', (msg) => {
 | 
				
			||||||
            require(`${events}msg`).execute(this, msg, Discord);
 | 
					            require(`${events}msg`).execute(this, msg, Discord);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        this.on('voiceStateUpdate', (newMember) => {
 | 
					        this.on('voiceStateUpdate', (oldState, newState) => {
 | 
				
			||||||
            require(`${events}voiceStateUpdate`).execute(this, newMember);
 | 
					            require(`${events}voiceStateUpdate`).execute(this, oldState, newState);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        this.on('error', (error) => {
 | 
					        this.on('error', (error) => {
 | 
				
			||||||
            client.channels.fetch(client.config.debug_channel).send('Error: ' + error);
 | 
					            client.channels.fetch(client.config.debug_channel).send('Error: ' + error);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,6 @@
 | 
				
			|||||||
module.exports = function (msg, args, client, Discord, prefix, command) {
 | 
					module.exports = function (msg, args, client, Discord, prefix, command) {
 | 
				
			||||||
    const permissions = msg.channel.permissionsFor(msg.client.user);
 | 
					    const permissions = msg.channel.permissionsFor(msg.client.user);
 | 
				
			||||||
    if (!permissions.has('EMBED_LINKS')) return msg.channel.send('<:redx:674263474704220182> I cannot send embeds (Embed links), make sure I have the proper permissions!');
 | 
					    if (!permissions.has('EMBED_LINKS')) return msg.channel.send('<:redx:674263474704220182> I cannot send embeds (Embed links), make sure I have the proper permissions!');
 | 
				
			||||||
    //if (!permissions.has('EXTERNAL_EMOJIS')) return msg.channel.send('<:redx:674263474704220182> I cannot use external emojis, make sure I have the proper permissions!'); DEPRACATED!
 | 
					 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        command.uses++;
 | 
					        command.uses++;
 | 
				
			||||||
        command.execute(msg, args, client, Discord, prefix, command);
 | 
					        command.execute(msg, args, client, Discord, prefix, command);
 | 
				
			||||||
@@ -11,7 +10,7 @@ module.exports = function (msg, args, client, Discord, prefix, command) {
 | 
				
			|||||||
            .setTitle(`Musix ${error.toString()}`)
 | 
					            .setTitle(`Musix ${error.toString()}`)
 | 
				
			||||||
            .setDescription(error.stack.replace(/at /g, '**at **'))
 | 
					            .setDescription(error.stack.replace(/at /g, '**at **'))
 | 
				
			||||||
            .setColor('#b50002');
 | 
					            .setColor('#b50002');
 | 
				
			||||||
        //client.channels.fetch(client.config.debug_channel).send(embed);
 | 
					        client.debug_channel.send(embed);
 | 
				
			||||||
        console.error(error);
 | 
					        console.error(error);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +0,0 @@
 | 
				
			|||||||
module.exports = async function (client) {
 | 
					 | 
				
			||||||
    try {
 | 
					 | 
				
			||||||
        await client.channels.fetch(client.config.secondary_test_channel)
 | 
					 | 
				
			||||||
            .then(x => x.join());
 | 
					 | 
				
			||||||
    } catch (error) {
 | 
					 | 
				
			||||||
        client.channels.fetch(client.config.debug_channel).send("Error detected: " + error);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@@ -1,29 +0,0 @@
 | 
				
			|||||||
module.exports = async function (msg, voiceChannel, client, url) {
 | 
					 | 
				
			||||||
    const radio = client.radio.get(msg.guild.id);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (radio) {
 | 
					 | 
				
			||||||
        radio.connection.dispatcher.end('Stopped');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    const construct = {
 | 
					 | 
				
			||||||
        textChannel: msg.channel,
 | 
					 | 
				
			||||||
        voiceChannel: voiceChannel,
 | 
					 | 
				
			||||||
        connection: null,
 | 
					 | 
				
			||||||
        playing: false,
 | 
					 | 
				
			||||||
        url: url,
 | 
					 | 
				
			||||||
        name: null,
 | 
					 | 
				
			||||||
        volume: client.config.volume,
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    client.radio.set(msg.guild.id, construct);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    try {
 | 
					 | 
				
			||||||
        const connection = await voiceChannel.join();
 | 
					 | 
				
			||||||
        construct.connection = connection;
 | 
					 | 
				
			||||||
        client.funcs.play(msg.guild, client, url);
 | 
					 | 
				
			||||||
    } catch (error) {
 | 
					 | 
				
			||||||
        client.radio.delete(msg.guild.id);
 | 
					 | 
				
			||||||
        //client.channels.fetch(client.config.debug_channel).send("Error with connecting to voice channel: " + error);
 | 
					 | 
				
			||||||
        return msg.channel.send(`<:redx:674263474704220182> An error occured: ${error}`);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,17 +0,0 @@
 | 
				
			|||||||
module.exports = function msToTime(duration, format) {
 | 
					 | 
				
			||||||
    var seconds = Math.floor((duration / 1000) % 60),
 | 
					 | 
				
			||||||
        minutes = Math.floor((duration / (1000 * 60)) % 60),
 | 
					 | 
				
			||||||
        hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
 | 
					 | 
				
			||||||
    days = Math.floor((duration / (1000 * 60 * 60 * 24)) % 24);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    days = (days < 10) ? "0" + days : days;
 | 
					 | 
				
			||||||
    hours = (hours < 10) ? "0" + hours : hours;
 | 
					 | 
				
			||||||
    minutes = (minutes < 10) ? "0" + minutes : minutes;
 | 
					 | 
				
			||||||
    seconds = (seconds < 10) ? "0" + seconds : seconds;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (format === "hh:mm:ss") {
 | 
					 | 
				
			||||||
        return `${hours}:${minutes}:${seconds}`;
 | 
					 | 
				
			||||||
    } else if (format === "dd:hh:mm:ss") {
 | 
					 | 
				
			||||||
        return `${days}:${hours}:${minutes}:${seconds}`;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user