mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 04:26:00 +00:00
Update V3.0.4
This commit is contained in:
24
src/commands/bass.js
Normal file
24
src/commands/bass.js
Normal file
@ -0,0 +1,24 @@
|
||||
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, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (!args[1] && queue) return msg.channel.send(`${client.messages.currentBass}**${queue.bass}**`);
|
||||
const bass = parseFloat(args[1]);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
if (isNaN(bass)) return msg.channel.send(client.messages.validNumber);
|
||||
if (bass > 100) return msg.channel.send(client.messages.maxBass);
|
||||
if (bass < 0) return msg.channel.send(client.messages.positiveBass);
|
||||
queue.bass = bass;
|
||||
let message;
|
||||
message = client.messages.bassApplied.replace("%BASS%", bass);
|
||||
return msg.channel.send(message);
|
||||
}
|
||||
}
|
||||
};
|
31
src/commands/cmduses.js
Normal file
31
src/commands/cmduses.js
Normal file
@ -0,0 +1,31 @@
|
||||
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, command) {
|
||||
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(client.messages.cmdUsesTitle)
|
||||
.setDescription('```ml\n' + markdownrows.join('\n') + '\n```')
|
||||
.setFooter(client.messages.cmdUsesFooter)
|
||||
.setColor(client.config.embedColor);
|
||||
msg.channel.send(embed);
|
||||
},
|
||||
};
|
13
src/commands/end.js
Normal file
13
src/commands/end.js
Normal 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, command) {
|
||||
client.queue.delete(msg.guild.id);
|
||||
msg.channel.send(client.messages.queueDeleted);
|
||||
}
|
||||
};
|
29
src/commands/eval.js
Normal file
29
src/commands/eval.js
Normal file
@ -0,0 +1,29 @@
|
||||
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, command) {
|
||||
const ytdl = require('ytdl-core');
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
let data;
|
||||
if (queue) {
|
||||
data = await Promise.resolve(ytdl.getInfo(queue.songs[0].url));
|
||||
}
|
||||
const input = msg.content.slice(client.global.db.guilds[msg.guild.id].prefix.length + 5);
|
||||
let output;
|
||||
try {
|
||||
output = await eval(input);
|
||||
} catch (error) {
|
||||
output = error.toString();
|
||||
}
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle(client.messages.evalTitle)
|
||||
.setColor(client.config.embedColor)
|
||||
.setDescription(`Input: \`\`\`js\n${input.replace(/; /g, ';').replace(/;/g, ';\n')}\n\`\`\`\nOutput: \`\`\`\n${output}\n\`\`\``);
|
||||
return msg.channel.send(embed);
|
||||
},
|
||||
};
|
38
src/commands/help.js
Normal file
38
src/commands/help.js
Normal file
@ -0,0 +1,38 @@
|
||||
module.exports = {
|
||||
name: 'help',
|
||||
alias: 'h',
|
||||
usage: '<command(opt)>',
|
||||
description: 'See the help for Musix.',
|
||||
onlyDev: false,
|
||||
permission: 'none',
|
||||
category: 'info',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
if (args[1]) {
|
||||
if (!client.commands.has(args[1]) || (client.commands.has(args[1]) && client.commands.get(args[1]).omitFromHelp === true && msg.guild.id !== '489083836240494593')) return msg.channel.send('That command does not exist');
|
||||
const command = client.commands.get(args[1]);
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle(`${client.global.db.guilds[msg.guild.id].prefix}${command.name} ${command.usage}`)
|
||||
.setDescription(command.description)
|
||||
.setFooter(`${client.messages.helpCmdFooter} \`${command.alias}\``)
|
||||
.setColor(client.config.embedColor)
|
||||
msg.channel.send(embed);
|
||||
} else {
|
||||
const categories = [];
|
||||
for (let i = 0; i < client.commands.size; i++) {
|
||||
if (!categories.includes(client.commands.array()[i].category)) categories.push(client.commands.array()[i].category);
|
||||
}
|
||||
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`;
|
||||
}
|
||||
let message;
|
||||
message = client.messages.helpFooter.replace("%PREFIX%", client.global.db.guilds[msg.guild.id].prefix);
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle(`${client.user.username} ${client.messages.helpTitle}`)
|
||||
.setDescription(commands)
|
||||
.setFooter(message)
|
||||
.setColor(client.config.embedColor)
|
||||
msg.channel.send(embed);
|
||||
}
|
||||
}
|
||||
};
|
17
src/commands/invite.js
Normal file
17
src/commands/invite.js
Normal file
@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
name: 'invite',
|
||||
alias: 'i',
|
||||
usage: '',
|
||||
description: 'Invite Musix.',
|
||||
onlyDev: false,
|
||||
permission: 'none',
|
||||
category: 'info',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle(client.messages.inviteTitle)
|
||||
.setURL(client.config.invite)
|
||||
.setColor(client.config.embedColor)
|
||||
msg.channel.send(embed);
|
||||
msg.channel.send(client.messages.joinSupport + client.config.supportServer);
|
||||
}
|
||||
};
|
24
src/commands/join.js
Normal file
24
src/commands/join.js
Normal file
@ -0,0 +1,24 @@
|
||||
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, command) {
|
||||
try {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
const voiceChannel = msg.member.voice.channel;
|
||||
const connection = await voiceChannel.join();
|
||||
if (queue) {
|
||||
queue.connection = connection;
|
||||
}
|
||||
msg.channel.send(`${client.messages.joined} ${voiceChannel.name}!`);
|
||||
} catch (error) {
|
||||
client.queue.delete(msg.guild.id);
|
||||
client.channels.get(client.config.debug_channel).send(client.messages.errorConnecting + error);
|
||||
return msg.channel.send(client.messages.error);
|
||||
}
|
||||
}
|
||||
};
|
21
src/commands/loop.js
Normal file
21
src/commands/loop.js
Normal file
@ -0,0 +1,21 @@
|
||||
module.exports = {
|
||||
name: 'loop',
|
||||
alias: 'none',
|
||||
usage: '',
|
||||
description: 'loop the queue.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
if (!queue.looping) {
|
||||
queue.looping = true;
|
||||
msg.channel.send(client.messages.looping);
|
||||
} else {
|
||||
queue.looping = false;
|
||||
msg.channel.send(client.messages.noLooping);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
23
src/commands/loopsong.js
Normal file
23
src/commands/loopsong.js
Normal file
@ -0,0 +1,23 @@
|
||||
module.exports = {
|
||||
name: 'loopsong',
|
||||
alias: 'loops',
|
||||
usage: '',
|
||||
description: 'loop the currently playing song.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
if (!queue.songLooping) {
|
||||
queue.songLooping = true;
|
||||
let message;
|
||||
message = client.messages.loopingSong.replace("%TITLE%", queue.songs[0].title);
|
||||
msg.channel.send(message);
|
||||
} else {
|
||||
queue.songLooping = false;
|
||||
msg.channel.send(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
32
src/commands/nowplaying.js
Normal file
32
src/commands/nowplaying.js
Normal file
@ -0,0 +1,32 @@
|
||||
module.exports = {
|
||||
name: 'nowplaying',
|
||||
alias: 'np',
|
||||
usage: '',
|
||||
description: 'See the currently playing song position and length.',
|
||||
onlyDev: false,
|
||||
permission: 'none',
|
||||
category: 'music',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const getThumb = require('video-thumbnail-url');
|
||||
const ytdl = require('ytdl-core');
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (!queue) return msg.channel.send(client.messages.noServerQueue);
|
||||
let data = await Promise.resolve(ytdl.getInfo(queue.songs[0].url));
|
||||
let songtime = (data.length_seconds * 1000).toFixed(0);
|
||||
queue.time = queue.connection.dispatcher.streamTime;
|
||||
let completed = (queue.time.toFixed(0));
|
||||
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 thumbnail = getThumb(queue.songs[0].url);
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle(client.messages.nowPlaying)
|
||||
.setDescription(`${client.messages.nowPlayingDesc} ${queue.songs[0].title}\n${array.join('')} | \`${client.funcs.msToTime(completed, "hh:mm:ss")} / ${client.funcs.msToTime(songtime, "hh:mm:ss")}\``)
|
||||
.setFooter(`Queued by ${queue.songs[0].author.tag}`)
|
||||
.setURL(queue.songs[0].url)
|
||||
.setThumbnail(thumbnail._rejectionHandler0)
|
||||
.setColor(client.config.embedColor)
|
||||
return msg.channel.send(embed);
|
||||
}
|
||||
};
|
||||
|
18
src/commands/pause.js
Normal file
18
src/commands/pause.js
Normal file
@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
name: 'pause',
|
||||
alias: 'none',
|
||||
usage: '',
|
||||
description: 'Pause the currently playing music.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
if (queue.paused) return msg.channel.send(client.messages.alreadyPaused);
|
||||
queue.paused = true;
|
||||
queue.connection.dispatcher.pause(true);
|
||||
return msg.channel.send(client.messages.paused);
|
||||
}
|
||||
}
|
||||
};
|
54
src/commands/play.js
Normal file
54
src/commands/play.js
Normal file
@ -0,0 +1,54 @@
|
||||
const YouTube = require("simple-youtube-api");
|
||||
|
||||
module.exports = {
|
||||
name: 'play',
|
||||
alias: 'p',
|
||||
usage: '<song name>',
|
||||
description: 'Play some music.',
|
||||
onlyDev: false,
|
||||
permission: 'none',
|
||||
category: 'music',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const youtube = new YouTube(client.config.api_key);
|
||||
const searchString = args.slice(1).join(" ");
|
||||
const url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
const voiceChannel = msg.member.voice.channel;
|
||||
if (!queue) {
|
||||
if (!msg.member.voice.channel) return msg.channel.send(client.messages.noVoiceChannel);
|
||||
} else {
|
||||
if (voiceChannel !== queue.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel);
|
||||
}
|
||||
if (!args[1]) return msg.channel.send(client.messages.noQuery);
|
||||
if (voiceChannel.full) return msg.channel.send(client.messages.channelFull);
|
||||
if (!voiceChannel.joinable) return msg.channel.send(client.messages.noPermsConnect);
|
||||
if (!voiceChannel.speakable) return msg.channel.send(client.messages.noPermsSpeak);
|
||||
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
|
||||
const lmsg = await msg.channel.send(client.messages.loadingSongs);
|
||||
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.funcs.handleVideo(video2, msg, voiceChannel, client, true);
|
||||
}
|
||||
client.messages.playlistAdded = client.messages.playlistAdded.replace("%TITLE%", playlist.title);
|
||||
return lmsg.edit(client.messages.playlistAdded);
|
||||
} else {
|
||||
try {
|
||||
var video = await youtube.getVideo(url);
|
||||
} catch (error) {
|
||||
try {
|
||||
const videos = await youtube.searchVideos(searchString, 1);
|
||||
var video = await youtube.getVideoByID(videos[0].id);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
if (err.code === 403) {
|
||||
return msg.channel.send(client.messages.quotaReached);
|
||||
}
|
||||
return msg.channel.send(client.messages.noResults);
|
||||
}
|
||||
}
|
||||
return client.funcs.handleVideo(video, msg, voiceChannel, client, false);
|
||||
}
|
||||
}
|
||||
};
|
28
src/commands/queue.js
Normal file
28
src/commands/queue.js
Normal file
@ -0,0 +1,28 @@
|
||||
module.exports = {
|
||||
name: 'queue',
|
||||
alias: 'q',
|
||||
usage: '<page(opt)>',
|
||||
description: 'See the queue.',
|
||||
onlyDev: false,
|
||||
permission: 'none',
|
||||
category: 'music',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (!queue) return msg.channel.send(client.messages.noServerQueue);
|
||||
const page = 1;
|
||||
let queuesongs = queue.songs.slice((page - 1) * 20 + 1, page * 20 + 1);
|
||||
let queuemessage = `${queuesongs.map(song => `**#** ${song.title}`).join('\n')}`
|
||||
const hashs = queuemessage.split('**#**').length;
|
||||
for (let i = 0; i < hashs; i++) {
|
||||
queuemessage = queuemessage.replace('**#**', `**${i + 1}**`);
|
||||
}
|
||||
let message;
|
||||
message = client.messages.queueDesc.replace("%SONG%", queue.songs[0].title);
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle(client.messages.queueTitle)
|
||||
.setDescription(`${message}\n${queuemessage}`)
|
||||
.setFooter(`${queue.songs.length} ${client.messages.queueFooter}`)
|
||||
.setColor(client.config.embedColor)
|
||||
return msg.channel.send(embed);
|
||||
}
|
||||
};
|
25
src/commands/remove.js
Normal file
25
src/commands/remove.js
Normal file
@ -0,0 +1,25 @@
|
||||
module.exports = {
|
||||
name: 'remove',
|
||||
alias: 'rm',
|
||||
usage: '<song pos>',
|
||||
description: 'Remove a song from the queue',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
if (!args[1]) return msg.channel.send(client.messages.provideASong);
|
||||
const pos = parseInt(args[1]);
|
||||
if (isNaN(pos)) return msg.channel.send(client.messages.validNumber);
|
||||
if (pos < 1) return msg.channel.send(client.messages.noSongs);
|
||||
let message1;
|
||||
let message2;
|
||||
message1 = client.messages.queueLength.replace("%LENGTH%", queue.songs.length);
|
||||
if (pos > queue.songs.length) return msg.channel.send(message1);
|
||||
message2 = client.messages.removed.replace("%SONG%", queue.songs[pos].title);
|
||||
msg.channel.send(message2);
|
||||
return queue.songs.splice(pos, 1);
|
||||
}
|
||||
}
|
||||
};
|
12
src/commands/restart.js
Normal file
12
src/commands/restart.js
Normal file
@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
name: 'restart',
|
||||
alias: 'none',
|
||||
usage: '',
|
||||
description: 'restart all shards',
|
||||
onlyDev: true,
|
||||
permission: 'dev',
|
||||
category: 'util',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
client.shard.respawnAll(client.config.shardDelay, client.config.respawnDelay, client.config.spawnTimeout);
|
||||
}
|
||||
};
|
18
src/commands/resume.js
Normal file
18
src/commands/resume.js
Normal file
@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
name: 'resume',
|
||||
alias: 'none',
|
||||
usage: '',
|
||||
description: 'Resume the paused music.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
if (!queue.paused) return msg.channel.send(client.messages.notPaused);
|
||||
queue.paused = false;
|
||||
queue.connection.dispatcher.resume(true);
|
||||
return msg.channel.send(client.messages.resumed);
|
||||
}
|
||||
}
|
||||
};
|
13
src/commands/savedb.js
Normal file
13
src/commands/savedb.js
Normal file
@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
name: 'savedb',
|
||||
alias: 'save',
|
||||
usage: '',
|
||||
description: 'save the database',
|
||||
onlyDev: true,
|
||||
permission: 'dev',
|
||||
category: 'util',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
client.funcs.saveDB(client);
|
||||
msg.channel.send(client.messages.dbSaved);
|
||||
}
|
||||
};
|
71
src/commands/search.js
Normal file
71
src/commands/search.js
Normal file
@ -0,0 +1,71 @@
|
||||
const YouTube = require("simple-youtube-api");
|
||||
const he = require('he');
|
||||
|
||||
module.exports = {
|
||||
name: 'search',
|
||||
alias: 'sr',
|
||||
usage: '<search word(s)>',
|
||||
description: 'Search the top 10 queryes and choose one.',
|
||||
onlyDev: false,
|
||||
permission: 'none',
|
||||
category: 'music',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const youtube = new YouTube(client.config.api_key);
|
||||
const searchString = args.slice(1).join(" ");
|
||||
const url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
const voiceChannel = msg.member.voice.channel;
|
||||
if (!queue) {
|
||||
if (!msg.member.voice.channel) return msg.channel.send(client.messages.noVoiceChannel);
|
||||
} else {
|
||||
if (voiceChannel !== queue.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel);
|
||||
}
|
||||
if (!args[1]) return msg.channel.send(client.messages.noQuery);
|
||||
if (voiceChannel.full) return msg.channel.send(client.messages.channelFull);
|
||||
if (!voiceChannel.joinable) return msg.channel.send(client.messages.noPermsConnect);
|
||||
if (!voiceChannel.speakable) return msg.channel.send(client.messages.noPermsSpeak);
|
||||
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
|
||||
const lmsg = await msg.channel.send(client.messages.loadingSongs);
|
||||
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.funcs.handleVideo(video2, msg, voiceChannel, client, true);
|
||||
}
|
||||
let message;
|
||||
message = client.messages.playlistAdded.replace("%TITLE%", playlist.title);
|
||||
return lmsg.edit(message);
|
||||
} else {
|
||||
try {
|
||||
var video = await youtube.getVideo(url);
|
||||
} catch (error) {
|
||||
try {
|
||||
var videos = await youtube.searchVideos(searchString, 10);
|
||||
let index = 0;
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle(client.messages.songSelection)
|
||||
.setDescription(`${videos.map(video2 => `**${++index}** ${he.decode(video2.title)} `).join('\n')}`)
|
||||
.setFooter(client.messages.provideANumber)
|
||||
.setColor(client.config.embedColor)
|
||||
msg.channel.send(embed);
|
||||
try {
|
||||
var response = await msg.channel.awaitMessages(message2 => message2.content > 0 && message2.content < 11 && message2.author === msg.author, {
|
||||
max: 1,
|
||||
time: 10000,
|
||||
errors: ['time']
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return msg.channel.send(client.messages.cancellingVideoSelection);
|
||||
}
|
||||
const videoIndex = parseInt(response.first().content);
|
||||
var video = await youtube.getVideoByID(videos[videoIndex - 1].id);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return msg.channel.send(client.messages.noResults);
|
||||
}
|
||||
}
|
||||
return client.funcs.handleVideo(video, msg, voiceChannel, client, false);
|
||||
}
|
||||
}
|
||||
};
|
29
src/commands/seek.js
Normal file
29
src/commands/seek.js
Normal file
@ -0,0 +1,29 @@
|
||||
module.exports = {
|
||||
name: 'seek',
|
||||
alias: 'none',
|
||||
usage: '<point in song>',
|
||||
description: 'Seek to a specific point in the currently playing song.',
|
||||
onlyDev: true,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const ytdl = require('ytdl-core');
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
let data = await Promise.resolve(ytdl.getInfo(queue.songs[0].url));
|
||||
if (!args[1]) return msg.channel.send(`${client.messages.correctUsage}\`${client.global.db.guilds[msg.guild.id].prefix}seek ${command.usage}\``);
|
||||
let point = args[1];
|
||||
const pos = parseInt(args[1]);
|
||||
if (isNaN(pos)) {
|
||||
if (pos < 0) return msg.channel.send(client.messages.seekingPointPositive);
|
||||
let message;
|
||||
message = client.messages.seekMax.replace("%LENGTH%", data.length_seconds);
|
||||
if (pos > data.length_seconds) return msg.channel.send(message);
|
||||
point = pos;
|
||||
}
|
||||
queue.connection.dispatcher.end();
|
||||
queue.endReason = "seek";
|
||||
client.funcs.play(msg.guild, queue.songs[0], client, msg, point, false);
|
||||
}
|
||||
}
|
||||
};
|
44
src/commands/settings.js
Normal file
44
src/commands/settings.js
Normal file
@ -0,0 +1,44 @@
|
||||
module.exports = {
|
||||
name: 'settings',
|
||||
alias: 'pref',
|
||||
usage: '<setting> <value(opt)>',
|
||||
description: 'Change the server settings for Musix.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_GUILD',
|
||||
category: 'util',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle(client.messages.settingsTitle)
|
||||
.addField(client.messages.settingsPrefix, client.messages.settingsPrefixDesc, true)
|
||||
.addField(client.messages.settingsVolume, client.messages.settingsVolumeDesc, true)
|
||||
.addField(client.messages.settingsPermissions, client.messages.settingsPermissionsDesc, true)
|
||||
.addField(client.messages.settingsSetDj, client.messages.settingsSetDjDesc, true)
|
||||
.addField(client.messages.settingsAnnounceSongs, client.messages.settingsAnnounceSongsDesc)
|
||||
.addField(client.messages.settingsBass, client.messages.settingsBassDesc, true)
|
||||
.setFooter(client.messages.settingsFooter)
|
||||
.setAuthor(client.user.username, client.user.displayAvatarURL)
|
||||
.setColor(client.config.embedColor)
|
||||
const permissions = msg.channel.permissionsFor(msg.author);
|
||||
if (msg.author.id !== client.config.devId) {
|
||||
if (!permissions.has(command.permission)) return msg.channel.send(client.messages.noPermsManageSettings);
|
||||
}
|
||||
if (args[1]) {
|
||||
const optionName = args[1].toLowerCase();
|
||||
const option = client.settingCmd.get(optionName) || client.settingCmd.find(cmd => cmd.aliases && cmd.aliases.includes(optionName));
|
||||
if (!option) return msg.channel.send(embed);
|
||||
try {
|
||||
option.execute(msg, args, client);
|
||||
} catch (error) {
|
||||
msg.reply(client.messages.errorExeOpt);
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle(`Musix ${error.toString()}`)
|
||||
.setDescription(error.stack.replace(/at /g, '**at **'))
|
||||
.setColor(client.config.embedColor);
|
||||
client.fetchUser(client.config.devId).then(user => user.send(embed)).catch(console.error);
|
||||
client.channels.get(client.config.debug_channel).send(embed);
|
||||
}
|
||||
} else {
|
||||
return msg.channel.send(embed);
|
||||
}
|
||||
},
|
||||
};
|
17
src/commands/settings/announcesongs.js
Normal file
17
src/commands/settings/announcesongs.js
Normal file
@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
name: 'announcesongs',
|
||||
async execute(msg, args, client) {
|
||||
if (!args[2]) return msg.channel.send(`${client.messages.announceSongs} \`${client.global.db.guilds[msg.guild.id].permissions}\``);
|
||||
if (args[2] === 'true') {
|
||||
if (!client.global.db.guilds[msg.guild.id].announceSongs) {
|
||||
client.global.db.guilds[msg.guild.id].announceSongs = true;
|
||||
msg.channel.send(client.messages.permissionsSetTrue);
|
||||
} else return msg.channel.send(client.messages.announceSongsTrue);
|
||||
} else if (args[2] === 'false') {
|
||||
if (client.global.db.guilds[msg.guild.id].announceSongs) {
|
||||
client.global.db.guilds[msg.guild.id].announceSongs = false;
|
||||
msg.channel.send(client.messages.announceSongsFalse);
|
||||
} else return msg.channel.send(client.messages.announceSongsFalse);
|
||||
} else return msg.channel.send(client.messages.boolean);
|
||||
}
|
||||
};
|
14
src/commands/settings/bass.js
Normal file
14
src/commands/settings/bass.js
Normal file
@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
name: 'bass',
|
||||
async execute(msg, args, client) {
|
||||
if (!args[2]) return msg.channel.send(client.messages.currentDefaultBass + client.global.db.guilds[msg.guild.id].bass);
|
||||
if (args[2] === "false") {
|
||||
client.global.db.guilds[msg.guild.id].bass = false;
|
||||
msg.channel.send(client.messages.bassFalse);
|
||||
}
|
||||
const level = parseInt(args[2]);
|
||||
if (isNaN(level)) return msg.channel.send(client.messages.validNumber);
|
||||
client.global.db.guilds[msg.guild.id].bass = level;
|
||||
msg.channel.send(`${client.messages.bassLevel} ${level}!`);
|
||||
}
|
||||
};
|
17
src/commands/settings/permissions.js
Normal file
17
src/commands/settings/permissions.js
Normal file
@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
name: 'permissions',
|
||||
async execute(msg, args, client) {
|
||||
if (!args[2]) return msg.channel.send(`${client.messages.permission} \`${client.global.db.guilds[msg.guild.id].permissions}\``);
|
||||
if (args[2] === 'true') {
|
||||
if (!client.global.db.guilds[msg.guild.id].permissions) {
|
||||
client.global.db.guilds[msg.guild.id].permissions = true;
|
||||
msg.channel.send(client.messages.permissionsSetTrue);
|
||||
} else return msg.channel.send(client.messages.permissionsTrue);
|
||||
} else if (args[2] === 'false') {
|
||||
if (client.global.db.guilds[msg.guild.id].permissions) {
|
||||
client.global.db.guilds[msg.guild.id].permissions = false;
|
||||
msg.channel.send(client.messages.permissionsSetFalse);
|
||||
} else return msg.channel.send(client.messages.permissionsFalse);
|
||||
} else return msg.channel.send(client.messages.boolean);
|
||||
}
|
||||
};
|
9
src/commands/settings/prefix.js
Normal file
9
src/commands/settings/prefix.js
Normal file
@ -0,0 +1,9 @@
|
||||
module.exports = {
|
||||
name: 'prefix',
|
||||
async execute(msg, args, client) {
|
||||
if (!args[2]) return msg.channel.send(`${client.messages.currentPrefix} \`${client.global.db.guilds[msg.guild.id].prefix}\``);
|
||||
if (args[2].length > 5) return msg.channel.send(client.messages.prefixMaxLength);
|
||||
client.global.db.guilds[msg.guild.id].prefix = args[2];
|
||||
msg.channel.send(`${client.messages.prefixSet} \`${args[2]}\``);
|
||||
}
|
||||
};
|
14
src/commands/settings/reset.js
Normal file
14
src/commands/settings/reset.js
Normal file
@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
name: 'reset',
|
||||
async execute(msg, args, client) {
|
||||
client.global.db.guilds[msg.guild.id] = {
|
||||
prefix: client.config.prefix,
|
||||
defaultVolume: 5,
|
||||
permissions: false,
|
||||
premium: false,
|
||||
dj: false,
|
||||
djrole: null
|
||||
};
|
||||
msg.channel.send(client.messages.reset);
|
||||
}
|
||||
};
|
28
src/commands/settings/setDj.js
Normal file
28
src/commands/settings/setDj.js
Normal file
@ -0,0 +1,28 @@
|
||||
module.exports = {
|
||||
name: 'setdj',
|
||||
async execute(msg, args, client) {
|
||||
if (!client.global.db.guilds[msg.guild.id].dj) {
|
||||
if (!client.global.db.guilds[msg.guild.id].permissions) {
|
||||
client.global.db.guilds[msg.guild.id].permissions = true;
|
||||
}
|
||||
if (msg.guild.roles.cache.find(x => x.name === "DJ")) {
|
||||
client.global.db.guilds[msg.guild.id].djrole = msg.guild.roles.cache.find(x => x.name === "DJ").id;
|
||||
msg.channel.send(client.messages.djRoleFound);
|
||||
client.global.db.guilds[msg.guild.id].dj = true;
|
||||
} else {
|
||||
const permissions = msg.channel.permissionsFor(msg.client.user);
|
||||
if (!permissions.has('MANAGE_ROLES')) return msg.channel.send(client.messages.noPermsManageRoles);
|
||||
msg.guild.createRole({
|
||||
name: 'DJ',
|
||||
})
|
||||
.then(role => client.global.db.guilds[msg.guild.id].djrole = role.id)
|
||||
.catch(console.error)
|
||||
client.global.db.guilds[msg.guild.id].dj = true;
|
||||
msg.channel.send(client.messages.djRoleCreated);
|
||||
}
|
||||
} else {
|
||||
client.global.db.guilds[msg.guild.id].dj = false;
|
||||
msg.channel.send(client.messages.djFalse);
|
||||
}
|
||||
}
|
||||
};
|
10
src/commands/settings/volume.js
Normal file
10
src/commands/settings/volume.js
Normal file
@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
name: 'volume',
|
||||
async execute(msg, args, client) {
|
||||
if (!args[2]) return msg.channel.send(`${client.messages.currentDefaultVolume} \`${client.global.db.guilds[msg.guild.id].defaultVolume}\``);
|
||||
if (isNaN(args[2])) return msg.channel.send(client.messages.defaultVolumeNumber);
|
||||
if (args[2].length > 2) return msg.channel.send(client.messages.defaultVolumeMax);
|
||||
client.global.db.guilds[msg.guild.id].defaultVolume = args[2];
|
||||
msg.channel.send(`${client.messages.defaultVolumeSet} \`${args[2]}\``);
|
||||
}
|
||||
};
|
16
src/commands/shuffle.js
Normal file
16
src/commands/shuffle.js
Normal file
@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
name: 'shuffle',
|
||||
alias: 'none',
|
||||
usage: '',
|
||||
description: 'Shuffle the queue.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
client.funcs.shuffle(queue.songs);
|
||||
msg.channel.send(client.messages.shuffled);
|
||||
}
|
||||
}
|
||||
};
|
50
src/commands/skip.js
Normal file
50
src/commands/skip.js
Normal file
@ -0,0 +1,50 @@
|
||||
module.exports = {
|
||||
name: 'skip',
|
||||
alias: 's',
|
||||
usage: '',
|
||||
description: 'Skip the currently playing song.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
const permissions = msg.channel.permissionsFor(msg.author);
|
||||
if (!queue || !queue.playing) return msg.channel.send(client.messages.noServerQueue);
|
||||
if (msg.author.id !== client.config.devId) {
|
||||
if (msg.member.voice.channel !== queue.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel);
|
||||
if (client.global.db.guilds[msg.guild.id].permissions) {
|
||||
if (!msg.member.roles.cache.has(client.global.db.guilds[msg.guild.id].djrole) || !permissions.has(command.permission)) {
|
||||
return vote(queue, msg, client);
|
||||
} else {
|
||||
return skipSong(queue, msg, client);
|
||||
}
|
||||
} else {
|
||||
return skipSong(queue, msg, client);
|
||||
}
|
||||
} else {
|
||||
return skipSong(queue, msg, client);
|
||||
}
|
||||
}
|
||||
};
|
||||
function skipSong(queue, msg, client) {
|
||||
msg.channel.send(client.messages.skipped);
|
||||
queue.endReason = "skip";
|
||||
queue.connection.dispatcher.end();
|
||||
};
|
||||
function vote(queue, msg, client) {
|
||||
queue.votesNeeded = Math.floor(queue.voiceChannel.members.size / 2);
|
||||
queue.votesNeeded.toFixed();
|
||||
if (queue.voiceChannel.members.size > 2) {
|
||||
if (queue.voters.includes(msg.member.id)) return msg.channel.send(client.messages.alreadyVoted);
|
||||
queue.votes++;
|
||||
queue.voters.push(msg.member.id);
|
||||
if (queue.votes >= queue.votesNeeded) {
|
||||
queue.voters = [];
|
||||
queue.votes = 0;
|
||||
queue.votesNeeded = null;
|
||||
return skipSong(queue, msg);
|
||||
} else return msg.channel.send(`${client.messages.notEnoughVotes} ${queue.votes} / ${queue.votesNeeded}!`);
|
||||
} else {
|
||||
return skipSong(queue, msg);
|
||||
}
|
||||
};
|
24
src/commands/skipto.js
Normal file
24
src/commands/skipto.js
Normal file
@ -0,0 +1,24 @@
|
||||
module.exports = {
|
||||
name: 'skipto',
|
||||
alias: 'st',
|
||||
usage: '<point in queue>',
|
||||
description: 'Skip to a point in the queue',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
if (!args[1]) return msg.channel.send(`${client.messages.correctUsage}\`${command.usage}\``);
|
||||
const point = parseInt(args[1] - 1);
|
||||
if (isNaN(point)) return msg.channel.send(client.messages.validNumber);
|
||||
if (point > queue.songs.size) return msg.channel.send(client.messages.noSongs);
|
||||
if (point < 0) return msg.channel.send(client.messages.cantSkipToCurrent);
|
||||
for (let i = 0; i < point; i++) {
|
||||
queue.songs.shift();
|
||||
}
|
||||
queue.endReason = "skipto";
|
||||
queue.connection.dispatcher.end();
|
||||
}
|
||||
}
|
||||
};
|
26
src/commands/status.js
Normal file
26
src/commands/status.js
Normal file
@ -0,0 +1,26 @@
|
||||
module.exports = {
|
||||
name: 'status',
|
||||
alias: 'stats',
|
||||
usage: '',
|
||||
description: 'See the current status for Musix.',
|
||||
onlyDev: false,
|
||||
permission: 'none',
|
||||
category: 'info',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const uptime = client.funcs.msToTime(client.uptime, "dd:hh:mm:ss");
|
||||
msg.channel.send(client.messages.pinging).then(m => {
|
||||
const latency = m.createdTimestamp - msg.createdTimestamp;
|
||||
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle(client.messages.statusTitle)
|
||||
.addField(client.messages.statusField1, client.ws.ping, true)
|
||||
.addField(client.messages.statusField2, latency, true)
|
||||
.addField(client.messages.statusField3, uptime, true)
|
||||
.addField(client.messages.statusField4, client.shard.ids)
|
||||
.setAuthor(client.user.username, client.user.displayAvatarURL)
|
||||
.setColor(client.config.embedColor)
|
||||
m.delete();
|
||||
return msg.channel.send(embed);
|
||||
});
|
||||
}
|
||||
};
|
19
src/commands/stop.js
Normal file
19
src/commands/stop.js
Normal file
@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
name: 'stop',
|
||||
description: 'Stop command.',
|
||||
alias: 'none',
|
||||
usage: '',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_CHANNELS',
|
||||
category: 'music',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
queue.songs = [];
|
||||
queue.looping = false;
|
||||
queue.endReason = "stop";
|
||||
queue.connection.dispatcher.end();
|
||||
msg.channel.send(client.messages.stop)
|
||||
}
|
||||
}
|
||||
};
|
23
src/commands/volume.js
Normal file
23
src/commands/volume.js
Normal file
@ -0,0 +1,23 @@
|
||||
module.exports = {
|
||||
name: 'volume',
|
||||
description: 'Volume command.',
|
||||
alias: 'none',
|
||||
usage: '<volume>',
|
||||
cooldown: 5,
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (!args[1] && queue) return msg.channel.send(`${client.messages.currentVolume}**${queue.volume}**`);
|
||||
const volume = parseFloat(args[1]);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
if (isNaN(volume)) return msg.channel.send(client.messages.validNumber);
|
||||
if (volume > 100) return msg.channel.send(client.messages.maxVolume);
|
||||
if (volume < 0) return msg.channel.send(client.messages.positiveVolume);
|
||||
queue.volume = volume;
|
||||
queue.connection.dispatcher.setVolume(volume / 5);
|
||||
return msg.channel.send(`${client.messages.setVolume}**${volume}**`);
|
||||
}
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user