1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-07-31 07:24:33 +00:00
This commit is contained in:
MatteZ02
2019-10-10 16:43:04 +03:00
parent 6f6ac8a6fa
commit 50b9bed483
9432 changed files with 1988816 additions and 167 deletions

View File

@@ -2,11 +2,11 @@ module.exports = {
name: 'bug',
description: 'Report a bug',
cooldown: 5,
async execute(msg, args, client, RichEmbed) {
const embed = new RichEmbed()
async execute(message, args, client, Discord, prefix) {
const embed = new Discord.RichEmbed()
.setTitle(`Found a bug with ${client.user.username}?\nDM the core developer:`)
.setDescription(`Matte#5254\nOr join the support server: https://discord.gg/rvHuJtB`)
.setDescription(`Matte#0002\nOr join the support server: https://discord.gg/rvHuJtB`)
.setColor('#b50002');
msg.channel.send(embed);
message.channel.send(embed);
},
};

View File

@@ -2,18 +2,17 @@ module.exports = {
name: 'eval',
description: 'Evaluation command',
cooldown: 5,
async execute(message, args, client, RichEmbed) {
async execute(message, args, client, Discord, prefix) {
const serverQueue = client.queue.get(message.guild.id);
const status = process.env.hosted
if (message.author.id !== '360363051792203779') return message.channel.send(':x: You are not allowed to do that!');
const input = message.content.slice(6)
const input = message.content.slice(prefix.length + 4);
let output;
try {
output = await eval(input);
} catch (error) {
output = error.toString();
}
const embed = new RichEmbed()
const embed = new Discord.RichEmbed()
.setTitle('Evaluation Command')
.setColor('#b50002')
.setDescription(`Input: \`\`\`js\n${input.replace(/; /g, ';').replace(/;/g, ';\n')}\n\`\`\`\nOutput: \`\`\`\n${output}\n\`\`\``);

View File

@@ -2,18 +2,18 @@ module.exports = {
name: 'help',
description: 'Help command.',
cooldown: 5,
execute(message, args, client, RichEmbed, prefix) {
const embed = new RichEmbed()
execute(message, args, client, Discord, prefix) {
const embed = new Discord.RichEmbed()
.setTitle('Commands for Musix!')
.addField(`${prefix}play | ${prefix}p`, 'Play a song.', true)
.addField(`${prefix}skip | ${prefix}s`, 'Skip a song.', true)
.addField(`${prefix}queue | ${prefix}q`, 'Display the queue.', true)
.addField(`${prefix}nowplaying | ${prefix}np`, 'Display whats currently playing.', true)
.addField(`${prefix}nowplaying | ${prefix}np`, 'Display what\'s currently playing.', true)
.addField(`${prefix}volume`, 'Change or check the volume.', true)
.addField(`${prefix}pause`, 'Pause the music.', true)
.addField(`${prefix}resume`, 'Resume the music.', true)
.addField(`${prefix}loop`, 'Loop the queue.', true)
.addField(`${prefix}stop`, 'Stop the music, Clear the queue and leave the current voice channel.', true)
.addField(`${prefix}restartmusic`, 'Restart the music. Recommended to use instead of stop on any possible errors.', true)
.addField(`${prefix}invite`, 'Invite Musix.', true)
.addField(`${prefix}status`, 'See different information for Musix.', true)
.addField(`${prefix}bug`, 'Report a bug.', true)

View File

@@ -2,8 +2,8 @@ module.exports = {
name: 'invite',
description: 'Invite command.',
cooldown: 5,
execute(message, args, client, RichEmbed) {
const embed = new RichEmbed()
execute(message, args, client, Discord, prefix) {
const embed = new Discord.RichEmbed()
.setTitle('Invite Musix to your Discord server!')
.setURL('https://bit.ly/2YDrKgh')
.setColor('#b50002')

29
commands/loop.js Normal file
View File

@@ -0,0 +1,29 @@
module.exports = {
name: 'loop',
description: 'loop command.',
cooldown: 10,
async execute(message, args, client, Discord, prefix) {
const serverQueue = client.queue.get(message.guild.id);
const permissions = message.channel.permissionsFor(message.author);
const { voiceChannel } = message.member;
if (serverQueue) {
if (message.author.id !== '360363051792203779') {
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to loop the queue!');
if (client.global.db.musix_guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to loop the queue!');
}
}
if (!serverQueue.looping) {
client.secondaryQueue = [...serverQueue.songs]
serverQueue.looping = true;
message.channel.send(':repeat: Looping the queue now!');
} else {
serverQueue.looping = false;
client.secondaryQueue = [];
message.channel.send(':repeat: No longer looping the queue!');
}
} else {
message.channel.send(':x: There is nothing playing!');
}
}
};

View File

@@ -2,8 +2,8 @@ module.exports = {
name: 'nowplaying',
description: 'Now playing command.',
cooldown: 5,
async execute(message, args, client, RichEmbed) {
const ytdl = require('ytdl-core')
async execute(message, args, client, Discord, prefix) {
const ytdl = require('ytdl-core');
const serverQueue = client.queue.get(message.guild.id);
if (!serverQueue) return message.channel.send(':x: There is nothing playing.');
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
@@ -12,13 +12,12 @@ module.exports = {
let barlength = 30;
let completedpercent = ((completed / songtime) * barlength).toFixed(0);
let array = []; for (let i = 0; i < completedpercent - 1; i++) { array.push('⎯'); } array.push('⭗'); for (let i = 0; i < barlength - completedpercent - 1; i++) { array.push('⎯'); }
const totallength = Math.floor(data.length_seconds / 60) + ':' + (data.length_seconds - (Math.floor(data.length_seconds / 60) * 60))
const timeins = serverQueue.connection.dispatcher.time / 1000
const timepassed = Math.floor(timeins / 60) + ':' + Math.round(timeins - (Math.floor(timeins / 60) * 60))
const embed = new RichEmbed()
const embed = new Discord.RichEmbed()
.setTitle("__Now playing__")
.setDescription(`🎶**Now playing:** ${serverQueue.songs[0].title}\n${array.join('')} | \`${timepassed} / ${totallength}\``)
.setDescription(`🎶**Now playing:** ${serverQueue.songs[0].title}\n${array.join('')} | \`${client.funcs.msToTime(completed)} / ${client.funcs.msToTime(songtime)}\``)
.setURL(serverQueue.songs[0].url)
.setColor("#b50002")
return message.channel.send(embed);
}
};

View File

@@ -2,16 +2,20 @@ module.exports = {
name: 'pause',
description: 'Pause command.',
cooldown: 5,
execute(message, args, client, RichEmbed) {
execute(message, args, client, Discord, prefix) {
const serverQueue = client.queue.get(message.guild.id);
const permissions = message.channel.permissionsFor(message.author);
const { voiceChannel } = message.member;
if (serverQueue && serverQueue.playing === true) {
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to pause the music!');
if (message.author.id !== '360363051792203779') {
if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to pause the music!');
if (client.global.db.musix_guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to pause the music!');
}
}
serverQueue.playing = false;
serverQueue.connection.dispatcher.pause();
return message.channel.send('⏸ Paused the music for you!');
return message.channel.send('⏸ Paused the music!');
}
return message.channel.send(':x: There is nothing playing.');
}

View File

@@ -6,27 +6,31 @@ module.exports = {
usage: '[song name]',
args: true,
cooldown: 3,
async execute(message, args, client, RichEmbed) {
async execute(message, args, client, Discord, prefix) {
const youtube = new YouTube(client.config.apikey);
const searchString = args.slice(1).join(" ");
const url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
const serverQueue = client.queue.get(message.guild.id);
const voiceChannel = message.member.voiceChannel;
if (!voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in a voice channel to play music!');
if (!serverQueue) {
if (!voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in a voice channel to play music!');
} else {
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to play music!');
}
if (!args[1]) return message.channel.send(':x: You need to use a link or search for a song!');
const permissions = voiceChannel.permissionsFor(message.client.user);
if (!permissions.has('CONNECT')) {
return message.channel.send(':x: I cannot connect to your voice channel, make sure I have the proper permissions!');
}
if (!permissions.has('SPEAK')) {
return message.channel.send(':x: I cannot speak in this voice channel, make sure I have the proper permissions!');
return message.channel.send(':x: I cannot speak in your voice channel, make sure I have the proper permissions!');
}
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
const playlist = await youtube.getPlaylist(url);
const videos = await playlist.getVideos();
for (const video of Object.values(videos)) {
const video2 = await youtube.getVideoByID(video.id);
await client.handleVideo(video2, message, voiceChannel, true);
await client.funcs.handleVideo(video2, message, voiceChannel, client, true);
}
return message.channel.send(`:white_check_mark: Playlist: **${playlist.title}** has been added to the queue!`);
} else {
@@ -36,7 +40,7 @@ module.exports = {
try {
var videos = await youtube.searchVideos(searchString, 10);
let index = 0;
const embed = new RichEmbed()
const embed = new Discord.RichEmbed()
.setTitle("__Song Selection__")
.setDescription(`${videos.map(video2 => `**${++index}** ${video2.title} `).join('\n')}`)
.setFooter("Please provide a number ranging from 1-10 to select one of the search results.")
@@ -59,7 +63,7 @@ module.exports = {
return message.channel.send(':x: I could not obtain any search results.');
}
}
return client.funcs.handleVideo(video, message, voiceChannel, client);
return client.funcs.handleVideo(video, message, voiceChannel, client, false);
}
}
};

View File

@@ -2,7 +2,7 @@ module.exports = {
name: 'queue',
description: 'Queue command.',
cooldown: 5,
async execute(message, args, client, RichEmbed) {
async execute(message, args, client, Discord, prefix) {
const serverQueue = client.queue.get(message.guild.id);
if (!serverQueue) return message.channel.send(':x: There is nothing playing.');
if (args[1]) {
@@ -17,12 +17,20 @@ module.exports = {
const hashs = queuemessage.split('**#**').length;
for (let i = 0; i < hashs; i++) {
queuemessage = queuemessage.replace('**#**', `**${i + 1}**`);
}
const embed = new RichEmbed()
.setTitle("__Song queue__")
.setDescription(`**Now playing:** ${serverQueue.songs[0].title}🎶\n${pagetext}\n${queuemessage}`)
.setColor("#b50002")
return message.channel.send(embed);
if (!serverQueue.looping) {
const embed = new Discord.RichEmbed()
.setTitle("__Song queue__")
.setDescription(`**Now playing:** ${serverQueue.songs[0].title}🎶\n${pagetext}\n${queuemessage}`)
.setColor("#b50002")
return message.channel.send(embed);
} else {
const embed = new Discord.RichEmbed()
.setTitle("__Song queue__")
.setDescription(`**Now playing:** ${serverQueue.songs[0].title}🎶\n${pagetext}\n${queuemessage}`)
.setFooter('🔁 Currently looping the queue!')
.setColor("#b50002")
return message.channel.send(embed);
}
}
};

View File

@@ -2,16 +2,20 @@ module.exports = {
name: 'resume',
description: 'Resume command.',
cooldown: 5,
execute(message, args, client, RichEmbed) {
execute(message, args, client, Discord, prefix) {
const serverQueue = client.queue.get(message.guild.id);
const permissions = message.channel.permissionsFor(message.author);
const { voiceChannel } = message.member;
if (serverQueue && !serverQueue.playing) {
if (message.author.id !== '360363051792203779') {
if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to resume the music!');
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to loop the queue!');
if (client.global.db.musix_guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to resume the music!');
}
}
serverQueue.playing = true;
serverQueue.connection.dispatcher.resume();
return message.channel.send('▶ Resumed the music for you!');
return message.channel.send('▶ Resumed the music!');
}
return message.channel.send(':x: The music is not paused!');
}

30
commands/seek.js Normal file
View File

@@ -0,0 +1,30 @@
module.exports = {
name: 'seek',
description: 'seek command.',
cooldown: 10,
async execute(message, args, client, Discord, prefix) {
const ytdl = require('ytdl-core');
const serverQueue = client.queue.get(message.guild.id);
const permissions = message.channel.permissionsFor(message.author);
const { voiceChannel } = message.member;
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
if (serverQueue) {
if (message.author.id !== '360363051792203779') {
return message.channel.send(':x: This command is currently disabled!');
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to seek the song!');
if (client.global.db.musix_guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to seek the song!');
}
}
if (!args[1]) return message.channel.send(`:x: Correct usage: \`${prefix}seek <seeking point in seconds>\``);
if (isNaN(args[1])) return message.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.');
const argsNumber = parseInt(args[1]);
if (argsNumber < 0) return message.channel.send(':x: The seeking point needs to be a positive number!');
if (argsNumber > data.length_seconds) return message.channel.send(`:x: The lenght of this song is ${data.length_seconds} seconds! You can't seek further than that!`);
serverQueue.connection.dispatcher.end('seek');
client.funcs.play(message.guild, serverQueue.songs[0], client, message, args[1]);
} else {
message.channel.send(':x: There is nothing playing!');
}
}
};

View File

@@ -3,24 +3,44 @@ module.exports = {
usage: '[setting]',
description: 'Change the settings',
cooldown: 10,
async execute(message, args, client, RichEmbed, prefix) {
async execute(message, args, client, Discord, prefix) {
const permissions = message.channel.permissionsFor(message.author);
if (message.author.id !== '360363051792203779') {
if (!permissions.has('MANAGE_GUILD')) return message.channel.send(':x: You need the `MANAGE_SERVER` permission to change the settings!');
}
if (args[1] === 'prefix') {
if (!args[2]) return message.channel.send(':x: You need to define the prefix!');
if (args[2].length > 5) return message.channel.send(':x: The prefix must be less than or equal to 5 characters');
await client.setPrefix(args[2], message.guild.id);
message.channel.send(`:white_check_mark: New prefix set to: \`${args[2]}\`\n`);
if (!args[2]) return message.channel.send(`<:thonk:461691390972264449> Current prefix: \`${client.global.db.musix_guilds[message.guild.id].musix_prefix}\``);
client.global.db.musix_guilds[message.guild.id].musix_prefix = args[2];
message.channel.send(`:white_check_mark: New prefix set to: \`${args[2]}\``);
} else if (args[1] === 'volume') {
if (!args[2]) return message.channel.send(`:speaker: Current default volume is: \`${client.global.db.musix_guilds[message.guild.id].defaultVolume}\``);
if (isNaN(args[2])) return message.channel.send(':x: I\'m sorry, But the default volume needs to be a valid __number__.');
if (args[2].length > 2) return message.channel.send(':x: The default volume must be below `100` for quality and safety resons.');
client.global.db.musix_guilds[message.guild.id].defaultVolume = args[2];
message.channel.send(`:white_check_mark: Default volume set to: \`${args[2]}\``);
} else if (args[1] === 'permissions') {
if (!args[2]) return message.channel.send(`🔒 Permission requirement: \`${client.global.db.musix_guilds[message.guild.id].permissions}\``);
if (args[2] === 'true') {
if (client.global.db.musix_guilds[message.guild.id].permissions === false) {
client.global.db.musix_guilds[message.guild.id].permissions = true;
message.channel.send(`:white_check_mark: Permissions requirement now set to: \`true\``);
} else return message.channel.send(':x: That value is already `true`!');
} else if (args[2] === 'false') {
if (client.global.db.musix_guilds[message.guild.id].permissions === true) {
client.global.db.musix_guilds[message.guild.id].permissions = false;
message.channel.send(`:white_check_mark: Permissions requirement now set to: \`false\``);
} else return message.channel.send(':x: That value is already `false`!');
} else return message.channel.send(':x: Please define a boolean! (true/false)');
} else {
const embed = new RichEmbed()
const embed = new Discord.RichEmbed()
.setTitle('Guild settings for Musix')
.addField('prefix', 'Change the guild specific prefix.', true)
.addField('volume', 'Change the default volume that the bot will start playing at.', true)
.addField('permissions', 'Change whether to require permissions to use eg `skip, stop, pause, loop, etc...`')
.setFooter(`how to use: ${prefix}settings <Setting name> <value>`)
.setAuthor(client.user.username, client.user.displayAvatarURL)
.setColor('#b50002')
return message.channel.send(embed);
}
},
};
};

View File

@@ -2,16 +2,18 @@ module.exports = {
name: 'skip',
description: 'Skip command.',
cooldown: 5,
execute(message, args, client, RichEmbed) {
execute(message, args, client, Discord, prefix) {
const { voiceChannel } = message.member;
const serverQueue = client.queue.get(message.guild.id);
const permissions = message.channel.permissionsFor(message.author);
if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could skip for you.');
if (message.author.id !== '360363051792203779') {
if (!voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in a voice channel to skip songs!');
if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to skip songs!');
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to skip the song!');
if (client.global.db.musix_guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to skip songs!');
}
}
message.channel.send(':fast_forward: Skipped the song for you!');
serverQueue.connection.dispatcher.end('Skip command has been used!');
message.channel.send(':fast_forward: Skipped the song!');
serverQueue.connection.dispatcher.end('skipped');
}
};

View File

@@ -2,7 +2,7 @@ module.exports = {
name: 'status',
description: 'Status command.',
cooldown: 5,
execute(message, args, client, RichEmbed) {
execute(message, args, client, Discord, prefix) {
let rawUptime = client.uptime;
let uptime = {};
uptime['d'] = rawUptime / 86400000;
@@ -14,24 +14,22 @@ module.exports = {
} else {
finalUptime = `${Math.round(uptime.d * 10) / 10} days`;
}
let onlinehost = process.env.hosted;
let hosted = process.env.hosted;
if (onlinehost !== undefined) {
hosted = 'Online';
} else {
if (process.env.LOCALLYHOSTED === "true") {
hosted = 'Locally';
} else {
hosted = 'Online';
}
let ping = Math.floor(client.ping * 10) / 10;
const embed = new RichEmbed()
const embed = new Discord.RichEmbed()
.setTitle(`Status for ${client.user.username}`)
.addField(':signal_strength: Ping', ping, true)
.addField(':stopwatch: Uptime', finalUptime, true)
.addField(`:play_pause: Currently playing music on ${client.voiceConnections.size} guilds.`, `Of ${client.guilds.size} Guilds.`, true)
.addField(`:play_pause: Currently playing music on`, `${client.voiceConnections.size} guild(s)`, true)
.addField(':satellite: Currently hosted', hosted, true)
.addField(`💿 Operating system`, process.platform, true)
.setAuthor(client.user.username, client.user.displayAvatarURL)
.setColor('#b50002')
return message.channel.send(embed);
}
};
};

View File

@@ -2,17 +2,20 @@ module.exports = {
name: 'stop',
description: 'Stop command.',
cooldown: 5,
execute(message, args, client, RichEmbed) {
execute(message, args, client, Discord, prefix) {
const { voiceChannel } = message.member;
const serverQueue = client.queue.get(message.guild.id);
const permissions = message.channel.permissionsFor(message.author);
if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could stop for you.');
if (message.author.id !== '360363051792203779') {
if (!voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in a voice channel to stop the music!');
if (!permissions.has('MANAGE_CHANNELS')) return message.channel.send(':x: You need the `MANAGE_CHANNELS` permission to stop the music!');
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to stop the music!');
if (client.global.db.musix_guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_CHANNELS')) return message.channel.send(':x: You need the `MANAGE_CHANNELS` permission to stop the music!');
}
}
serverQueue.songs = [];
serverQueue.connection.dispatcher.end('Stop command has been used!');
message.channel.send(':stop_button: Stopped the music for you!')
serverQueue.looping = false;
serverQueue.connection.dispatcher.end('Stopped');
message.channel.send(':stop_button: Stopped the music!')
}
};

View File

@@ -2,7 +2,7 @@ module.exports = {
name: 'volume',
description: 'Volume command.',
cooldown: 5,
execute(message, args, client, RichEmbed) {
execute(message, args, client, Discord, prefix) {
const { voiceChannel } = message.member;
const serverQueue = client.queue.get(message.guild.id);
const permissions = message.channel.permissionsFor(message.author);
@@ -11,11 +11,15 @@ module.exports = {
if (!args[1]) return message.channel.send(`:loud_sound: The current volume is: **${serverQueue.volume}**`);
if (message.author.id !== '360363051792203779') {
if (!voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in a voice channel to change the volume!');
if (!permissions.has('MANAGE_CHANNELS')) return message.channel.send(':x: You need the `MANAGE_CHANNELS` permission to change the volume!');
if (client.global.db.musix_guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_CHANNELS')) return message.channel.send(':x: You need the `MANAGE_CHANNELS` permission to change the volume!');
}
if (isNaN(args[1])) return message.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.');
if (args[1] > 100) return message.channel.send(':x: The max volume is `100`!');
if (args[1] < 0) return message.channel.send(':x: The volume needs to be a positive number!');
}
if (isNaN(args[1])) return msg.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.');
serverQueue.volume = args[1]; // eslint-disable-line
serverQueue.connection.dispatcher.setVolumeLogarithmic(args[1] / 5);
serverQueue.volume = args[1];
serverQueue.connection.dispatcher.setVolume(args[1] / 5);
return message.channel.send(`:loud_sound: I set the volume to: **${args[1]}**`);
}
};