mirror of
https://github.com/musix-org/musix-oss
synced 2025-07-31 07:24:33 +00:00
Initial
This commit is contained in:
24
commands/help.js
Normal file
24
commands/help.js
Normal file
@@ -0,0 +1,24 @@
|
||||
module.exports = {
|
||||
name: 'help',
|
||||
description: 'Help command.',
|
||||
cooldown: 5,
|
||||
execute(message, args, client, RichEmbed) {
|
||||
const embed = new RichEmbed()
|
||||
.setTitle('Commands for Musix!')
|
||||
.addField('```+play```', 'Play a song.', true)
|
||||
.addField('```+queue```', 'Display the queue.', true)
|
||||
.addField('```+np```', 'Display whats currently playing.', true)
|
||||
.addField('```+volume```', 'Change or check the volume.', true)
|
||||
.addField('```+pause```', 'Pause the music.', true)
|
||||
.addField('```+resume```', 'Resume the music.', true)
|
||||
.addField('```+stop```', 'Stop the music, Clear the queue and leave the current voice channel.', true)
|
||||
.addField('```+skip```', 'Skip a song.', true)
|
||||
.addField('```+invite```', 'Invite Musix.', true)
|
||||
.addField('```+ping```', 'See the current ping for Musix', true)
|
||||
.addField('```+info```', 'Display info and instructions.', true)
|
||||
.addField('```+help```', 'Display the help.', true)
|
||||
.setAuthor(client.user.username, client.user.displayAvatarURL)
|
||||
.setColor('#2780cd')
|
||||
return message.channel.send(embed);
|
||||
}
|
||||
};
|
16
commands/info.js
Normal file
16
commands/info.js
Normal file
@@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
name: 'info',
|
||||
description: 'Info command.',
|
||||
cooldown: 5,
|
||||
execute(message, args, client, RichEmbed) {
|
||||
const embed = new RichEmbed()
|
||||
.setTitle('**Musix instructions and info**:')
|
||||
.addField('If you encounter any errors with musix please report about them on the offical musix support server!', 'https://discord.gg/rvHuJtB', true)
|
||||
.addField('On errors you can do +stop to reset the queue and try again!', 'To use all commands make sure you have `MANAGE_MESSAGES` and `MANAGE_CHANNELS` permissions!')
|
||||
.addField('Current Ping in milliseconds', `${Math.floor(client.ping * 10) / 10} ms`, true)
|
||||
.addField('Be careful with the Volume command! Volume is not recommended to be put over 3 with user volume at 100%!', 'Volume will reset to 1 always when a new song begins!', true)
|
||||
.setAuthor(client.user.username, client.user.displayAvatarURL)
|
||||
.setColor('#2780cd')
|
||||
return message.channel.send(embed);
|
||||
}
|
||||
};
|
8
commands/invite.js
Normal file
8
commands/invite.js
Normal file
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
name: 'invite',
|
||||
description: 'Invite command.',
|
||||
cooldown: 5,
|
||||
execute(message, args, client, RichEmbed) {
|
||||
return message.channel.send('Invite me with: https://bit.ly/2VGcuBR');
|
||||
}
|
||||
};
|
10
commands/np.js
Normal file
10
commands/np.js
Normal file
@@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
name: 'np',
|
||||
description: 'Now playing command.',
|
||||
cooldown: 5,
|
||||
execute(message, args, client, RichEmbed) {
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
if (!serverQueue) return message.channel.send(':x: There is nothing playing.');
|
||||
return message.channel.send(`🎶 Now playing: **${serverQueue.songs[0].title}**`);
|
||||
}
|
||||
};
|
16
commands/pause.js
Normal file
16
commands/pause.js
Normal file
@@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
name: 'pause',
|
||||
description: 'Pause command.',
|
||||
cooldown: 5,
|
||||
execute(message, args, client, RichEmbed) {
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
if (serverQueue && serverQueue.playing === 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('There is nothing playing.');
|
||||
}
|
||||
};
|
8
commands/ping.js
Normal file
8
commands/ping.js
Normal file
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
name: 'ping',
|
||||
description: 'Ping command.',
|
||||
cooldown: 5,
|
||||
execute(message, args, client, RichEmbed) {
|
||||
return message.channel.send(`My current Ping: **${Math.floor(client.ping * 10) / 10} ms**.`);
|
||||
}
|
||||
};
|
64
commands/play.js
Normal file
64
commands/play.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const YouTube = require("simple-youtube-api");
|
||||
const youtube = new YouTube(process.env.API_KEY);
|
||||
|
||||
module.exports = {
|
||||
name: 'play',
|
||||
description: 'Play command.',
|
||||
usage: '[song name]',
|
||||
args: true,
|
||||
cooldown: 3,
|
||||
async execute(message, args, client, RichEmbed) {
|
||||
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!');
|
||||
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!');
|
||||
}
|
||||
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);
|
||||
}
|
||||
return message.channel.send(`:white_check_mark: Playlist: **${playlist.title}** has been added to the queue!`);
|
||||
} else {
|
||||
try {
|
||||
var video = await youtube.getVideo(url);
|
||||
} catch (error) {
|
||||
try {
|
||||
var videos = await youtube.searchVideos(searchString, 10);
|
||||
let index = 0;
|
||||
const embed = new 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.")
|
||||
.setColor("#2780cd")
|
||||
message.channel.send(embed);
|
||||
try {
|
||||
var response = await message.channel.awaitMessages(message2 => message2.content > 0 && message2.content < 11, {
|
||||
maxMatches: 1,
|
||||
time: 10000,
|
||||
errors: ['time']
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return Message.channel.send(':x: Cancelling video selection.');
|
||||
}
|
||||
const videoIndex = parseInt(response.first().content);
|
||||
var video = await youtube.getVideoByID(videos[videoIndex - 1].id);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return message.channel.send(':x: I could not obtain any search results.');
|
||||
}
|
||||
}
|
||||
return client.handleVideo(video, message, voiceChannel);
|
||||
}
|
||||
}
|
||||
};
|
30
commands/queue.js
Normal file
30
commands/queue.js
Normal file
@@ -0,0 +1,30 @@
|
||||
module.exports = {
|
||||
name: 'queue',
|
||||
description: 'Queue command.',
|
||||
cooldown: 5,
|
||||
async execute(message, args, client, RichEmbed) {
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
if (!serverQueue) return message.channel.send(':x: There is nothing playing.');
|
||||
let page = parseInt(args[1]);
|
||||
if (!page) page = 1;
|
||||
let queuesongs = serverQueue.songs.slice((page - 1) * 10 + 1, page * 20 + 1);
|
||||
let queuemessage = `${queuesongs.map(song => `**#** ${song.title}`).join('\n')}`
|
||||
if (queuemessage.length >= 1972) {
|
||||
let finalQueuemessage = queuemessage.slice(0, 1972).split('**#**').slice(0, -1).join('**#**');
|
||||
const overflowSongsAmount = queuemessage.replace(finalQueuemessage, '').split('**#**').length;
|
||||
finalQueuemessage += `\nI could not display all the songs at once. ${overflowSongsAmount} songs were not displayed here.`;
|
||||
queuemessage = finalQueuemessage;
|
||||
}
|
||||
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(queuemessage)
|
||||
.setFooter(`🎶 **Now playing:** ${serverQueue.songs[0].title}`)
|
||||
.setColor("#2780cd")
|
||||
return message.channel.send(embed);
|
||||
}
|
||||
};
|
16
commands/resume.js
Normal file
16
commands/resume.js
Normal file
@@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
name: 'resume',
|
||||
description: 'Resume command.',
|
||||
cooldown: 5,
|
||||
execute(message, args, client, RichEmbed) {
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
if (serverQueue && !serverQueue.playing) {
|
||||
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(':x: The music is not paused!');
|
||||
}
|
||||
};
|
15
commands/skip.js
Normal file
15
commands/skip.js
Normal file
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
name: 'skip',
|
||||
description: 'Skip command.',
|
||||
cooldown: 5,
|
||||
execute(message, args, client, RichEmbed) {
|
||||
const { voiceChannel } = message.member;
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
if (!voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in a voice channel to skip songs!');
|
||||
if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could skip for you.');
|
||||
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!');
|
||||
}
|
||||
};
|
16
commands/stop.js
Normal file
16
commands/stop.js
Normal file
@@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
name: 'stop',
|
||||
description: 'Stop command.',
|
||||
cooldown: 5,
|
||||
execute(message, args, client, RichEmbed) {
|
||||
const { voiceChannel } = message.member;
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
if (!voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in a voice channel to stop the music!');
|
||||
if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could stop for you.');
|
||||
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!')
|
||||
}
|
||||
};
|
18
commands/volume.js
Normal file
18
commands/volume.js
Normal file
@@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
name: 'volume',
|
||||
description: 'Volume command.',
|
||||
cooldown: 5,
|
||||
execute(message, args, client, RichEmbed) {
|
||||
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.');
|
||||
if (!args[1]) return message.channel.send(`:loud_sound: The current volume is: **${serverQueue.volume}**`);
|
||||
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 (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);
|
||||
return message.channel.send(`:loud_sound: I set the volume to: **${args[1]}**`);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user