1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-22 21:13:18 +00:00
This commit is contained in:
MatteZ02 2020-02-10 21:04:42 +02:00
parent 8647d8782f
commit c1bbdf9532
10 changed files with 45 additions and 32 deletions

1
.gitignore vendored
View File

@ -3,5 +3,4 @@ dev/
.env
.vscode/
package-lock.json
src/struct/config/.env
src/struct/config/serviceAccount.json

View File

@ -3,14 +3,31 @@ module.exports = {
alias: 'dc',
usage: 'disconnect',
description: 'Disconnect the bot from a voice channel.',
onlyDev: false,
onlyDev: true,
permission: 'MANAGE_CHANNELS',
category: 'util',
async execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
serverQueue.voiceChannel.leave();
if (msg.author.id !== client.config.devId) {
if (msg.member.voice.channel !== serverQueue.voiceChannel) return msg.channel.send(`<:redx:674263474704220182> I'm sorry but you need to be in the same voice channel as Musix to use this command!`);
if (client.global.db.guilds[msg.guild.id].permissions === true) {
if (client.global.db.guilds[msg.guild.id].dj) {
if (!msg.member.roles.has(client.global.db.guilds[msg.guild.id].djrole)) {
msg.channel.send('<:redx:674263474704220182> You need the `DJ` role to use this command!');
};
} else if (!permissions.has(command.permission)) {
msg.channel.send(`<:redx:674263474704220182> You need the \`${command.permission}\` permission to use this command!`);
}
};
}
if (serverQueue && serverQueue.playing) {
return msg.channel.send('<:redx:674263474704220182> There is something playing! Use the `stop` command instead!');
}
if (msg.guild.voiceConnection) {
msg.guild.voiceConnection.channel.leave();
msg.channel.send('<:green_check_mark:674265384777416705> Left the voice channel!');
} else {
msg.channel.send('<:redx:674263474704220182> i\'m not connected to a voice channel!')
}
}
};

View File

@ -23,7 +23,7 @@ module.exports = {
}
let commands = '';
for (let i = 0; i < categories.length; i++) {
commands += `**» ${categories[i].toUpperCase()}**\n${client.commands.filter(x => x.category === categories[i] && !x.omitFromHelp).map(x => `\`${x.name}\``).join(', ')}\n`;
commands += `**» ${categories[i].toUpperCase()}**\n${client.commands.filter(x => x.category === categories[i] && !x.omitFromHelp && !x.onlyDev).map(x => `\`${x.name}\``).join(', ')}\n`;
}
const embed = new Discord.MessageEmbed()
.setTitle(`${client.user.username} help:`)

View File

@ -3,7 +3,7 @@ module.exports = {
alias: 'j',
usage: 'join',
description: 'Make Musix join the channel your channel',
onlyDev: false,
onlyDev: true,
permission: 'none',
category: 'util',
async execute(msg, args, client, Discord, prefix) {

View File

@ -11,18 +11,6 @@ module.exports = {
if (client.funcs.check(client, msg, command)) {
client.funcs.shuffle(serverQueue.songs);
msg.channel.send('<:shuffle:674685595980791871> Queue suffled!');
/*let currentIndex = serverQueue.songs.length,
temporaryValue,
randomIndex;
while (0 !== currentIndex) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
temporaryValue = serverQueue.songs[currentIndex];
serverQueue.songs[currentIndex] = serverQueue.songs[randomIndex];
serverQueue.songs[randomIndex] = temporaryValue;*
}*/
}
}
};

View File

@ -15,9 +15,9 @@ module.exports = {
}
}
}
if (client.config.devMode && msg.member.id !== client.config.devId) return msg.channel.send('<:redx:674263474704220182> Dev mode has been turned on! Commands are only available to developer(s)!');
if (!msg.content.startsWith(prefix)) return;
if (!args[0]) return;
if (client.config.devMode && msg.member.id !== client.config.devId) return msg.channel.send('<:redx:674263474704220182> Dev mode has been turned on! Commands are only available to developer(s)!');
const commandName = args[0].toLowerCase();
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName);
if (!command && msg.content !== `${prefix}`) return;

View File

@ -1,4 +1,3 @@
const Discord = require('discord.js');
const MusicClient = require('./struct/client.js');
const client = new MusicClient({});
require('dotenv/config');

View File

@ -1,9 +1,15 @@
require('dotenv/config');
module.exports = {
//credentials
token: process.env.TOKEN,
api_key: process.env.API_KEY,
devToken: process.env.DEVTOKEN,
dblKey: process.env.DBLKEY,
api_key: process.env.GOOGLE_API_KEY,
//channels
debug_channel: "634718645188034560",
primary_test_channel: "617633098296721409",
secondary_test_channel: "570531724002328577",
devId: "360363051792203779",
//misc
embedColor: "#B127CD",
@ -13,7 +19,7 @@ module.exports = {
dblApi: false,
saveDB: false,
//db values
prefix: "-",
prefix: "*",
defaultVolume: 5,
permissions: false,
dj: false,

View File

@ -1,6 +1,6 @@
module.exports = async function (client) {
try {
await client.channels.get('570531724002328577').join()
await client.channels.get(client.configs.secondary_test_channel).join()
} catch (error) {
client.channels.get(client.config.debug_channel).send("Error detected: " + error);
}

View File

@ -1,11 +1,15 @@
module.exports = function msToTime(duration) {
var seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
module.exports = function msToTime(duration, format) {
if (format = "hh:mm:ss") {
var seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds;
hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds;
return `${hours}:${minutes}:${seconds}`;
return `${hours}:${minutes}:${seconds}`;
} else if (format = "dd:hh:mm") {
}
}