1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-10 05:10:17 +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 .env
.vscode/ .vscode/
package-lock.json package-lock.json
src/struct/config/.env
src/struct/config/serviceAccount.json src/struct/config/serviceAccount.json

View File

@ -3,14 +3,31 @@ module.exports = {
alias: 'dc', alias: 'dc',
usage: 'disconnect', usage: 'disconnect',
description: 'Disconnect the bot from a voice channel.', description: 'Disconnect the bot from a voice channel.',
onlyDev: false, onlyDev: true,
permission: 'MANAGE_CHANNELS', permission: 'MANAGE_CHANNELS',
category: 'util', category: 'util',
async execute(msg, args, client, Discord, prefix, command) { async execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id); const serverQueue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) { if (msg.author.id !== client.config.devId) {
serverQueue.voiceChannel.leave(); 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!'); 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 = ''; let commands = '';
for (let i = 0; i < categories.length; i++) { 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() const embed = new Discord.MessageEmbed()
.setTitle(`${client.user.username} help:`) .setTitle(`${client.user.username} help:`)

View File

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

View File

@ -11,18 +11,6 @@ module.exports = {
if (client.funcs.check(client, msg, command)) { if (client.funcs.check(client, msg, command)) {
client.funcs.shuffle(serverQueue.songs); client.funcs.shuffle(serverQueue.songs);
msg.channel.send('<:shuffle:674685595980791871> Queue suffled!'); 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 (!msg.content.startsWith(prefix)) return;
if (!args[0]) 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 commandName = args[0].toLowerCase();
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName); 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; if (!command && msg.content !== `${prefix}`) return;

View File

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

View File

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

View File

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

View File

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