1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 00:23:17 +00:00

Update 3.0.2

This commit is contained in:
MatteZ02 2020-03-03 22:24:41 +02:00
parent 295f5521e9
commit 58c5c3065a
25 changed files with 108 additions and 70 deletions

22
commands/bass.js Normal file
View File

@ -0,0 +1,22 @@
module.exports = {
name: 'bass',
description: 'Bassboost command.',
alias: 'none',
usage: '<bass>',
cooldown: 5,
onlyDev: false,
permission: 'MANAGE_MESSAGES',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
if (!args[1] && serverQueue) return msg.channel.send(`:loud_sound: The current bass is: **${serverQueue.bass}**`);
const bass = parseFloat(args[1]);
if (client.funcs.check(client, msg, command)) {
if (isNaN(bass)) return msg.channel.send('<:redx:674263474704220182> I\'m sorry, But you need to enter a valid __number__.');
if (bass > 100) return msg.channel.send('<:redx:674263474704220182> The max bass is `100`!');
if (bass < 0) return msg.channel.send('<:redx:674263474704220182> The volume needs to be a positive number!');
serverQueue.bass = bass;
return msg.channel.send(`<:volumehigh:674685637626167307> The bass level **${bass}** will be applied when the next song starts playing!`);
}
}
};

View File

@ -1,33 +0,0 @@
module.exports = {
name: 'disconnect',
alias: 'dc',
usage: '',
description: 'Disconnect the bot from a voice channel.',
onlyDev: true,
permission: 'MANAGE_CHANNELS',
category: 'util',
async execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
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!')
}
}
};

13
commands/end.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
name: 'end',
alias: 'e',
usage: '',
description: 'end the queue',
onlyDev: true,
permission: 'dev',
category: 'util',
async execute(msg, args, client, Discord, prefix, command) {
client.queue.delete(guild.id);
msg.channel.send('Queue deleted!');
}
};

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 && !x.onlyDev).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

@ -22,9 +22,9 @@ module.exports = {
const option = require(`./settings/${file}`);
client.settingCmd.set(option.name, option);
}
fs.readdirSync(path.join(__dirname, 'funcs')).forEach(filename => {
/*fs.readdirSync(path.join(__dirname, 'funcs')).forEach(filename => {
this.funcs[filename.slice(0, -3)] = require(`../struct/funcs/${filename}`);
});
});*/
msg.channel.send('All files reloaded!');
}
};

View File

@ -10,7 +10,7 @@ module.exports = {
const serverQueue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
if (!args[1]) return msg.channel.send('<:redx:674263474704220182> Please provide a song position in queue for me to remove!');
const pos = parseInt(args[1] - 1);
const pos = parseInt(args[1]);
if (isNaN(pos)) return msg.channel.send('<:redx:674263474704220182> You need to enter a number!');
if (pos < 1) return msg.channel.send('<:redx:674263474704220182> That songs does not exist!');
if (pos > serverQueue.songs.length) return msg.channel.send(`<:redx:674263474704220182> There is only ${serverQueue.songs.length} amount of songs in the queue!`);

View File

@ -7,9 +7,8 @@ module.exports = {
permission: 'none',
category: 'util',
async execute(msg, args, client, Discord, prefix, command) {
client.destroy()
const MusicClient = require('../struct/client.js');
const newClient = new MusicClient({});
client.destroy();
require('../index.js');
msg.channel.send('restarted!');
}
};

View File

@ -17,6 +17,7 @@ module.exports = {
if (pos < 0) return msg.channel.send('<:redx:674263474704220182> The seeking point needs to be a positive number!');
if (pos > data.length_seconds) return msg.channel.send(`<:redx:674263474704220182> The lenght of this song is ${data.length_seconds} seconds! You can't seek further than that!`);
serverQueue.connection.dispatcher.end('seek');
serverQueue.endReason = "seek";
client.funcs.play(msg.guild, serverQueue.songs[0], client, msg, pos, false);
}
}

View File

@ -14,6 +14,7 @@ module.exports = {
.addField('permissions', 'Change whether to require permissions to use eg `skip, stop, pause, loop, etc...`', true)
.addField('setdj', 'Set a DJ role. This will allow chosen users to freely use all Musix commands. This will automatically set the `permissions` settings to true in order for the `DJ` role to have effect!', true)
.addField('announcesongs', 'Whether to announce songs that start playing or not.')
.addField('bass', 'Change the default bass level', true)
.setFooter(`how to use: ${prefix}settings <Setting name> <value>`)
.setAuthor(client.user.username, client.user.displayAvatarURL)
.setColor(client.embedColor)

14
commands/settings/bass.js Normal file
View File

@ -0,0 +1,14 @@
module.exports = {
name: 'bass',
async execute(msg, args, client, Discord, prefix) {
if (!args[2]) return msg.channel.send('Currect bass level: ' + client.global.db.guilds[msg.guild.id].bass);
if (args[2] === "false") {
client.global.db.guilds[msg.guild.id].bass = false;
msg.channel.send(`Bass is now false!`);
}
const level = parseInt(args[2]);
if (isNaN(level)) return msg.channel.send('You need to provide a number?');
client.global.db.guilds[msg.guild.id].bass = level;
msg.channel.send(`Bass level is now ${level}!`);
}
};

View File

@ -28,6 +28,7 @@ module.exports = {
};
function skipSong(serverQueue, msg) {
msg.channel.send('<:skip:674685614221688832> Skipped the song!');
serverQueue.endReason = "skip";
serverQueue.connection.dispatcher.end('skipped');
};
function vote(serverQueue, msg) {

View File

@ -10,7 +10,7 @@ module.exports = {
const serverQueue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
if (!args[1]) return msg.channel.send(`<:redx:674263474704220182> correct usage: \`${command.usage}\``);
const point = parseInt(args[1]);
const point = parseInt(args[1] - 1);
if (isNaN(point)) return msg.channel.send('<:redx:674263474704220182> I\'m sorry, But you need to enter a valid __number__.');
if (point > serverQueue.songs.size) return msg.channel.send('<:redx:674263474704220182> That song does not exist!');
if (point < 1) return msg.channel.send('<:redx:674263474704220182> You can\'t skip to the song currently playing!');
@ -19,6 +19,7 @@ module.exports = {
i++;
serverQueue.songs.shift();
}
serverQueue.endReason = "skipto";
serverQueue.connection.dispatcher.end('skipto');
}
}

View File

@ -8,7 +8,6 @@ module.exports = {
category: 'info',
execute(msg, args, client, Discord, prefix) {
const uptime = client.funcs.msToTime(client.uptime, "dd:hh:mm:ss");
const ping = Math.floor(client.ping * 10) / 10;
msg.channel.send('<a:loading:674284196700618783> Pinging...').then(m => {
const latency = m.createdTimestamp - msg.createdTimestamp;

View File

@ -11,6 +11,7 @@ module.exports = {
if (client.funcs.check(client, msg, command)) {
serverQueue.songs = [];
serverQueue.looping = false;
serverQueue.endReason = "stop";
serverQueue.connection.dispatcher.end('Stopped');
msg.channel.send('<:stop:674685626108477519> Stopped the music!')
}

View File

@ -8,6 +8,7 @@ module.exports = {
dj: client.config.dj,
djrole: client.config.djrole,
startPlaying: client.config.startPlaying,
bass: client.config.bass,
});
client.global.db.guilds[guild.id] = {
prefix: client.config.prefix,
@ -16,6 +17,7 @@ module.exports = {
dj: client.config.dj,
djrole: client.config.djrole,
startPlaying: client.config.startPlaying,
bass: client.config.bass,
};
}
}

View File

@ -21,7 +21,7 @@ module.exports = {
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.onlyDev && msg.author.id !== client.config.devId) return msg.channel.send('<:redx:674263474704220182> You are not allowed to do that!');
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 (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)!');
client.funcs.exe(msg, args, client, Discord, prefix, command);
}
}

View File

@ -3,6 +3,8 @@ const DBL = require("dblapi.js");
module.exports = {
name: 'ready',
async execute(client, Discord) {
const debugChannel = await client.channels.fetch(client.config.debug_channel);
client.debug_channel = debugChannel
const remoteMusixGuildsData = await client.funcs.dbget('guilds', null, client);
remoteMusixGuildsData.forEach(guildData => {
client.global.db.guilds[guildData.id] = guildData.d;
@ -17,6 +19,7 @@ module.exports = {
dj: client.config.dj,
djrole: client.config.djrole,
startPlaying: client.config.startPlaying,
bass: client.config.bass,
};
});
}
@ -45,6 +48,7 @@ module.exports = {
dj: client.global.db.guilds[guild.id].dj,
djrole: client.global.db.guilds[guild.id].djrole,
startPlaying: client.global.db.guilds[guild.id].startPlaying,
bass: client.global.db.guilds[guild.id].bass,
});
});
}

View File

@ -1,6 +1,6 @@
{
"name": "musix",
"version": "1.0.0",
"version": "3.0.2",
"description": "V3 for Musix the discord music bot",
"main": "./index.js",
"scripts": {
@ -18,7 +18,7 @@
"homepage": "https://github.com/MatteZ02/Musix-V3#readme",
"dependencies": {
"dblapi.js": "^2.3.1",
"discord.js": "github:discordjs/discord.js",
"discord.js": "^12.0.1",
"dotenv": "^8.2.0",
"ffmpeg": "0.0.4",
"firebase": "^7.8.0",

View File

@ -68,6 +68,9 @@ module.exports = class extends Client {
this.on('voiceStateUpdate', (newMember) => {
require(`${events}voiceStateUpdate`).execute(this, newMember);
});
this.on('error', (error) => {
client.channels.fetch(client.config.debug_channel).send('Error: ' + error);
});
this.login(this.config.token).catch(err => console.log('Failed to login: ' + err));
}

View File

@ -15,8 +15,8 @@ module.exports = {
embedColor: "#b50002",
invite: "https://discordapp.com/api/oauth2/authorize?client_id=607266889537945605&permissions=3427328&redirect_uri=https%3A%2F%2Fdiscordapp.com%2Foauth2%2Fauthorize%3Fclient_id%3D607266889537945605%26%3Bscope%3Dbot%26%3Bpermissions%3D0&scope=bot",
//Settings
devMode: false,
dblApi: true,
devMode: true,
dblApi: false,
saveDB: true,
//db values
prefix: ">",
@ -26,4 +26,5 @@ module.exports = {
dj: false,
djrole: null,
startPlaying: true,
bass: 1,
}

View File

@ -0,0 +1,17 @@
module.exports = {
textChannel: null,
voiceChannel: null,
connection: null,
songs: [],
volume: null,
bass: null,
playing: false,
paused: false,
looping: false,
songLooping: false,
votes: 0,
voters: [],
votesNeeded: null,
time: 0,
endReason: null,
}

View File

@ -11,8 +11,7 @@ module.exports = function (msg, args, client, Discord, prefix, command) {
.setTitle(`Musix ${error.toString()}`)
.setDescription(error.stack.replace(/at /g, '**at **'))
.setColor('#b50002');
//client.fetchUser(client.config.devId).then(user => user.send(embed)).catch(console.error);
//client.channels.get(client.config.debug_channel).send(embed);
client.debug_channel.send(embed);
console.error(error);
}
};

View File

@ -3,6 +3,6 @@ module.exports = async function (client) {
await client.channels.fetch(client.config.secondary_test_channel)
.then(x => x.join());
} catch (error) {
client.channels.get(client.config.debug_channel).send("Error detected: " + error);
client.debug_channel.send("Error detected: " + error);
}
};

View File

@ -6,28 +6,21 @@ module.exports = async function (video, msg, voiceChannel, client, playlist = fa
url: `https://www.youtube.com/watch?v=${video.id}`,
author: msg.author
}
const serverQueue = client.queue.get(msg.guild.id);
if (serverQueue) {
serverQueue.songs.push(song);
if (playlist) return;
return msg.channel.send(`<:green_check_mark:674265384777416705> **${song.title}** has been added to the queue!`);
}
const construct = {
textChannel: msg.channel,
voiceChannel: voiceChannel,
connection: null,
songs: [],
volume: client.global.db.guilds[msg.guild.id].defaultVolume,
playing: false,
paused: false,
looping: false,
songLooping: false,
votes: 0,
voters: [],
votesNeeded: null,
time: 0,
};
const construct = require("../config/queueConfig.js");
construct.textChannel = msg.channel;
construct.voiceChannel = voiceChannel;
construct.volume = client.global.db.guilds[msg.guild.id].defaultVolume;
construct.bass = client.global.db.guilds[msg.guild.id].bass;
construct.songs.push(song);
client.queue.set(msg.guild.id, construct);
@ -37,7 +30,7 @@ module.exports = async function (video, msg, voiceChannel, client, playlist = fa
client.funcs.play(msg.guild, construct.songs[0], client, 0, true);
} catch (error) {
client.queue.delete(msg.guild.id);
//client.channels.get(client.config.debug_channel).send("Error with connecting to voice channel: " + error);
client.debug_channel.send("Error with connecting to voice channel: " + error);
return msg.channel.send(`<:redx:674263474704220182> An error occured: ${error}`);
}
return;

View File

@ -2,7 +2,6 @@ module.exports = async function (guild, song, client, seek, play) {
const Discord = require('discord.js');
const ytdl = require('ytdl-core');
const getThumb = require('video-thumbnail-url');
const prism = require('prism-media');
const serverQueue = client.queue.get(guild.id);
if (!song) {
@ -13,15 +12,16 @@ module.exports = async function (guild, song, client, seek, play) {
}
const dispatcher = serverQueue.connection
.play(await ytdl(song.url, { filter: "audio", highWaterMark: 1 << 25, volume: false }), { seek: seek, bitrate: 1024, passes: 10, volume: 1 })
.on("finish", reason => {
client.dispatcher.finish(client, reason, guild);
.play(await ytdl(song.url, { filter: "audio", highWaterMark: 1 << 25, volume: false }), { seek: seek, bitrate: 1024, passes: 10, volume: 1, bassboost: serverQueue.bass })
.on("end", () => {
client.dispatcher.finish(client, serverQueue.endReason, guild);
});
dispatcher.on('start', () => {
dispatcher.player.streamingData.pausedTime = 0;
});
dispatcher.on('error', error => {
console.error(error);
client.debug_channel.send('Error with the dispatcher: ' + error);
serverQueue.voiceChannel.leave();
client.queue.delete(guild.id);
return serverQueue.textChannel.send('<:redx:674263474704220182> An error has occured while playing music! The queue has been deleted.');