mirror of
https://github.com/musix-org/musix-oss
synced 2024-12-22 21:13:18 +00:00
commit
1f310190d9
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,6 @@
|
||||
.env
|
||||
serviceAccount.json
|
||||
package.json
|
||||
package-lock.json
|
||||
.vscode/
|
||||
node_modules/
|
||||
|
@ -3,7 +3,11 @@ module.exports = {
|
||||
description: 'Evaluation command',
|
||||
cooldown: 5,
|
||||
async execute(message, args, client, Discord, prefix) {
|
||||
const ytdl = require('ytdl-core');
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
if (serverQueue) {
|
||||
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
|
||||
}
|
||||
if (message.author.id !== '360363051792203779') return message.channel.send(':x: You are not allowed to do that!');
|
||||
const input = message.content.slice(prefix.length + 4);
|
||||
let output;
|
||||
|
10
commands/forcestop.js
Normal file
10
commands/forcestop.js
Normal file
@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
name: 'forcestop',
|
||||
description: 'force stop command.',
|
||||
cooldown: 5,
|
||||
execute(message, args, client, Discord, prefix) {
|
||||
if (message.author.id !== '360363051792203779') return message.channel.send(':x: You are not allowed to do that!')
|
||||
client.queue.delete(message.guild.id);
|
||||
message.channel.send('queue deleted')
|
||||
}
|
||||
};
|
@ -9,6 +9,7 @@ module.exports = {
|
||||
.addField(`${prefix}skip | ${prefix}s`, 'Skip a song.', true)
|
||||
.addField(`${prefix}queue | ${prefix}q`, 'Display the queue.', true)
|
||||
.addField(`${prefix}nowplaying | ${prefix}np`, 'Display what\'s currently playing.', true)
|
||||
.addField(`${prefix}remove | ${prefix}rm`, 'Remove songs from the queue.', true)
|
||||
.addField(`${prefix}volume`, 'Change or check the volume.', true)
|
||||
.addField(`${prefix}pause`, 'Pause the music.', true)
|
||||
.addField(`${prefix}resume`, 'Resume the music.', true)
|
||||
|
@ -8,18 +8,18 @@ module.exports = {
|
||||
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 (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to loop the queue!');
|
||||
if (client.global.db.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 (client.global.db.guilds[message.guild.id].dj) {
|
||||
if (!message.member.roles.has(client.global.db.guilds[message.guild.id].djrole)) return message.channel.send(':x: You need the `DJ` role to loop the queue!');
|
||||
} else 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 {
|
||||
|
@ -15,6 +15,7 @@ module.exports = {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setTitle("__Now playing__")
|
||||
.setDescription(`🎶**Now playing:** ${serverQueue.songs[0].title}\n${array.join('')} | \`${client.funcs.msToTime(completed)} / ${client.funcs.msToTime(songtime)}\``)
|
||||
.setFooter(`Queued by ${serverQueue.songs[0].author.tag}`)
|
||||
.setURL(serverQueue.songs[0].url)
|
||||
.setColor("#b50002")
|
||||
return message.channel.send(embed);
|
||||
|
@ -7,10 +7,12 @@ module.exports = {
|
||||
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 (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to pause the music!');
|
||||
if (message.author.id !== '360363051792203779') {
|
||||
if (client.global.db.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!');
|
||||
if (client.global.db.guilds[message.guild.id].dj) {
|
||||
if (!message.member.roles.has(client.global.db.guilds[message.guild.id].djrole)) return message.channel.send(':x: You need the `DJ` role to pause the music!');
|
||||
} else if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to pause the music!');
|
||||
}
|
||||
}
|
||||
serverQueue.playing = false;
|
||||
|
@ -16,7 +16,7 @@ module.exports = {
|
||||
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 (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel 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);
|
||||
|
158
commands/playlist.js
Normal file
158
commands/playlist.js
Normal file
@ -0,0 +1,158 @@
|
||||
const YouTube = require("simple-youtube-api");
|
||||
const he = require('he');
|
||||
|
||||
module.exports = {
|
||||
name: 'playlist',
|
||||
usage: '[option]',
|
||||
description: 'Save and load queues',
|
||||
cooldown: 10,
|
||||
async execute(message, args, client, Discord, prefix) {
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
if (message.author.id !== '360363051792203779') {
|
||||
if (client.global.db.guilds[message.guild.id].dj) {
|
||||
if (!message.member.roles.has(client.global.db.guilds[message.guild.id].djrole)) return message.channel.send(':x: You need the `DJ` role to modify or play the playlist!');
|
||||
} else if (!permissions.has('MANAGE_GUILD')) return message.channel.send(':x: You need the `MANAGE_SERVER` permission to modify the playlist!');
|
||||
}
|
||||
if (client.global.db.guilds[message.guild.id].premium) {
|
||||
if (args[1] === 'play') {
|
||||
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 your voice channel, make sure I have the proper permissions!');
|
||||
}
|
||||
let songs;
|
||||
if (!voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in a voice channel to play music!');
|
||||
if (args[2]) {
|
||||
if (client.global.db.guilds[args[2]].premium && client.global.db.playlists[args[2]].saved) {
|
||||
songs = client.global.db.playlists[args[2]].songs;
|
||||
} else return message.channel.send(':x: There is no queue saved for this guild!')
|
||||
} else {
|
||||
songs = client.global.db.playlists[message.guild.id].songs;
|
||||
}
|
||||
if (client.global.db.playlists[message.guild.id].saved) {
|
||||
if (!serverQueue) {
|
||||
const construct = {
|
||||
textChannel: message.channel,
|
||||
voiceChannel: message.member.voiceChannel,
|
||||
connection: null,
|
||||
songs: [...songs],
|
||||
volume: client.global.db.guilds[message.guild.id].defaultVolume,
|
||||
playing: true,
|
||||
looping: false
|
||||
};
|
||||
client.queue.set(message.guild.id, construct);
|
||||
message.channel.send(":white_check_mark: Queue set!");
|
||||
try {
|
||||
var connection = await message.member.voiceChannel.join();
|
||||
construct.connection = connection;
|
||||
client.funcs.play(message.guild, construct.songs[0], client, message, 0, false);
|
||||
} catch (error) {
|
||||
client.queue.delete(message.guild.id);
|
||||
return message.channel.send(`:x: An error occured: ${error}`);
|
||||
}
|
||||
} else {
|
||||
serverQueue.connection.dispatcher.end("queue set");
|
||||
serverQueue.songs = [...client.global.db.playlists[message.guild.id].songs];
|
||||
message.channel.send(":white_check_mark: Queue set!");
|
||||
}
|
||||
} else return message.channel.send(':x: There is no queue set for this server!')
|
||||
} else if (args[1] === 'save') {
|
||||
if (!serverQueue) return message.channel.send(':x: There is nothing playing!');
|
||||
client.global.db.playlists[message.guild.id] = {
|
||||
songs: serverQueue.songs,
|
||||
firstSong: serverQueue.songs[0],
|
||||
saved: true,
|
||||
};
|
||||
message.channel.send(":white_check_mark: Queue saved!");
|
||||
} else if (args[1] === 'add') {
|
||||
if (client.global.db.playlists[message.guild.id].saved) {
|
||||
const youtube = new YouTube(client.config.apikey);
|
||||
const searchString = args.slice(2).join(" ");
|
||||
const url = args[2] ? args[2].replace(/<(.+)>/g, "$1") : "";
|
||||
if (!args[2]) return message.channel.send(':x: You need to use a link or search for a song!');
|
||||
try {
|
||||
var video = await youtube.getVideo(url);
|
||||
} catch (error) {
|
||||
try {
|
||||
var videos = await youtube.searchVideos(searchString, 10);
|
||||
let index = 0;
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setTitle("__Song Selection__")
|
||||
.setDescription(`${videos.map(video2 => `**${++index}** ${he.decode(video2.title)} `).join('\n')}`)
|
||||
.setFooter("Please provide a number ranging from 1-10 to select one of the search results.")
|
||||
.setColor("#b50002")
|
||||
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!');
|
||||
}
|
||||
}
|
||||
let song = {
|
||||
id: video.id,
|
||||
title: Discord.Util.escapeMarkdown(video.title),
|
||||
url: `https://www.youtube.com/watch?v=${video.id}`
|
||||
}
|
||||
client.global.db.playlists[message.guild.id].songs.push(song);
|
||||
message.channel.send(`:white_check_mark: ${song.title} added to the playlist!`);
|
||||
} else return message.channel.send(':x: There is no playlist saved! Start by using the save option!')
|
||||
} else if (args[1] === 'remove') {
|
||||
if (client.global.db.playlists[message.guild.id].saved) {
|
||||
if (!args[2]) return message.channel.send(':x: Please provide a number on the position of the song that you wan\'t to remove!');
|
||||
const songNum = parseInt(args[2]) - 1;
|
||||
if (isNaN(songNum)) return message.channel.send(':x: You need to enter a __number__!');
|
||||
if (songNum === 0) return message.channel.send(':x: You can not remove the currently playing song!');
|
||||
if (parseInt(songNum) > client.global.db.playlists[message.guild.id].songs.size) return message.channel.send(`:x: There is only ${serverQueue.songs.size} amount of songs in the queue!`);
|
||||
message.channel.send(`🗑️ removed \`${client.global.db.playlists[message.guild.id].songs[songNum].title}\` from the playlist!`);
|
||||
return client.global.db.playlists[message.guild.id].songs.splice(songNum, 1);
|
||||
} else return message.channel.send(':x: There is no playlist saved! Start by using the save option!')
|
||||
} else if (args[1] === 'list') {
|
||||
if (args[2]) {
|
||||
if (isNaN(args[2])) return msg.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.');
|
||||
}
|
||||
let page = parseInt(args[2]);
|
||||
if (!page) page = 1;
|
||||
let pagetext = `:page_facing_up: Page: ${page} :page_facing_up:`
|
||||
let queuesongs = client.global.db.playlists[message.guild.id].songs.slice((page - 1) * 20, page * 20);
|
||||
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}**`);
|
||||
}
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setTitle("__playlist queue__")
|
||||
.setDescription(`${pagetext}\n${queuemessage}`)
|
||||
.setColor("#b50002")
|
||||
return message.channel.send(embed);
|
||||
} else {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setTitle('Options for playlist!')
|
||||
.addField('play', 'Play the guild specific queue.', true)
|
||||
.addField('save', 'Save the currently playing queue. Note that this will overwrite the currently saved queue!', true)
|
||||
.addField('add', 'Add songs to the playlist. Like song selection', true)
|
||||
.addField('remove', 'Remove songs from the playlist.', true)
|
||||
.addField('list', 'Display the playlist.', true)
|
||||
.setFooter(`how to use: ${prefix}playlist <Option> <Optional option>`)
|
||||
.setAuthor(client.user.username, client.user.displayAvatarURL)
|
||||
.setColor('#b50002')
|
||||
return message.channel.send(embed);
|
||||
}
|
||||
} else return message.channel.send(":x: This is not a premium guild!");
|
||||
},
|
||||
};
|
26
commands/remove.js
Normal file
26
commands/remove.js
Normal file
@ -0,0 +1,26 @@
|
||||
module.exports = {
|
||||
name: 'remove',
|
||||
description: 'Remove command.',
|
||||
cooldown: 5,
|
||||
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');
|
||||
if (!args[1]) return message.channel.send(':x: Please provide a song position in queue for me to remove!');
|
||||
const pos = parseInt(args[1]);
|
||||
if (isNaN(pos)) return message.channel.send(':x: You need to enter a number!');
|
||||
if (pos === 0) return message.channel.send(':x: You can not remove the currently playing song!');
|
||||
if (pos > serverQueue.songs.size) return message.channel.send(`:x: There is only ${serverQueue.songs.size} amount of songs in the queue!`);
|
||||
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 voice channel as Musix to remove songs!');
|
||||
if (client.global.db.guilds[message.guild.id].dj) {
|
||||
if (serverQueue.songs[pos].author !== message.author) {
|
||||
if (!message.member.roles.has(client.global.db.guilds[message.guild.id].djrole)) return message.channel.send(':x: You need the `DJ` role to remove songs queue by others!');
|
||||
}
|
||||
} else if (!permissions.has('MANAGE_MESSAGES') && serverQueue.songs[pos].author !== message.author) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to remove songs queued by others!');
|
||||
}
|
||||
message.channel.send(`🗑️ removed \`${serverQueue.songs[pos].title}\` from the queue!`);
|
||||
return serverQueue.songs.splice(pos, 1);
|
||||
}
|
||||
};
|
@ -8,9 +8,11 @@ module.exports = {
|
||||
const { voiceChannel } = message.member;
|
||||
if (serverQueue && !serverQueue.playing) {
|
||||
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 (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to loop the queue!');
|
||||
if (client.global.db.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!');
|
||||
if (client.global.db.guilds[message.guild.id].dj) {
|
||||
if (!message.member.roles.has(client.global.db.guilds[message.guild.id].djrole)) return message.channel.send(':x: You need the `DJ` role to resume the music!');
|
||||
} else if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to resume the music!');
|
||||
}
|
||||
}
|
||||
serverQueue.playing = true;
|
||||
|
@ -11,18 +11,20 @@ module.exports = {
|
||||
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 (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to seek the song!');
|
||||
if (client.global.db.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 (client.global.db.guilds[message.guild.id].dj) {
|
||||
if (!message.member.roles.has(client.global.db.guilds[message.guild.id].djrole)) return message.channel.send(':x: You need the `DJ` role to seek the song!');
|
||||
} else 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!`);
|
||||
const pos = parseInt(args[1])
|
||||
if (isNaN(pos)) return message.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.');
|
||||
if (pos < 0) return message.channel.send(':x: The seeking point needs to be a positive number!');
|
||||
if (pos > 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]);
|
||||
client.funcs.play(message.guild, serverQueue.songs[0], client, message, pos, false);
|
||||
} else {
|
||||
message.channel.send(':x: There is nothing playing!');
|
||||
}
|
||||
|
@ -21,22 +21,84 @@ module.exports = {
|
||||
} else if (args[1] === 'permissions') {
|
||||
if (!args[2]) return message.channel.send(`🔒 Permission requirement: \`${client.global.db.guilds[message.guild.id].permissions}\``);
|
||||
if (args[2] === 'true') {
|
||||
if (client.global.db.guilds[message.guild.id].permissions === false) {
|
||||
if (!client.global.db.guilds[message.guild.id].permissions) {
|
||||
client.global.db.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.guilds[message.guild.id].permissions === true) {
|
||||
if (client.global.db.guilds[message.guild.id].permissions) {
|
||||
client.global.db.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 if (args[1] === 'setpremium' && message.author.id === '360363051792203779') {
|
||||
if (args[2]) {
|
||||
const guild = client.guilds.get(args[2]);
|
||||
if (!client.global.db.guilds[guild.id].premium) {
|
||||
client.global.db.playlists[guild.id] = {
|
||||
songs: [],
|
||||
firstSong: undefined,
|
||||
saved: false,
|
||||
};
|
||||
client.global.db.guilds[guild.id].premium = true;
|
||||
message.channel.send(`:white_check_mark: Guild ${guild.name} | ${guild.id} is now premium! :tada:`)
|
||||
} else {
|
||||
client.global.db.guilds[guild.id].premium = false;
|
||||
message.channel.send(`:white_check_mark: Guild ${guild.name} | ${guild.id} is no longer premium!`)
|
||||
}
|
||||
} else {
|
||||
if (!client.global.db.guilds[message.guild.id].premium) {
|
||||
client.global.db.playlists[message.guild.id] = {
|
||||
songs: [],
|
||||
firstSong: undefined,
|
||||
saved: false,
|
||||
};
|
||||
client.global.db.guilds[message.guild.id].premium = true;
|
||||
message.channel.send(':white_check_mark: This guild is now premium! :tada:')
|
||||
} else {
|
||||
client.global.db.guilds[message.guild.id].premium = false;
|
||||
message.channel.send(":white_check_mark: This guild is no longer premium!")
|
||||
}
|
||||
}
|
||||
} else if (args[1] === "setdj") {
|
||||
if (!client.global.db.guilds[message.guild.id].dj) {
|
||||
if (!client.global.db.guilds[message.guild.id].permissions) {
|
||||
client.global.db.guilds[message.guild.id].permissions = true;
|
||||
}
|
||||
client.global.db.guilds[message.guild.id].dj = true;
|
||||
if (message.guild.roles.find(x => x.name === "DJ")) {
|
||||
client.global.db.guilds[message.guild.id].djrole = message.guild.roles.find(x => x.name === "DJ").id;
|
||||
message.channel.send(':white_check_mark: I found a `DJ` role from this guild! This role is now the DJ role.');
|
||||
} else {
|
||||
const permissions = message.channel.permissionsFor(message.client.user);
|
||||
if (!permissions.has('MANAGE_ROLES')) return message.channel.send(':x: I cannot create roles (Manage roles), make sure I have the proper permissions! I will need this permission to create a `DJ` role since i did not find one!');
|
||||
message.guild.createRole({
|
||||
name: 'DJ',
|
||||
})
|
||||
.then(role => client.global.db.guilds[message.guild.id].djrole = role.id)
|
||||
.catch(console.error)
|
||||
message.channel.send(':white_check_mark: I did not find a role `DJ` so i have created one for you!');
|
||||
}
|
||||
} else {
|
||||
client.global.db.guilds[message.guild.id].dj = false;
|
||||
message.channel.send(':white_check_mark: `DJ` now set to `false`');
|
||||
}
|
||||
} else if (args[1] === 'announcesongs') {
|
||||
if (client.global.db.guilds[message.guild.id].startPlaying) {
|
||||
client.global.db.guilds[message.guild.id].startPlaying = false;
|
||||
return message.channel.send(':white_check_mark: announcesongs now set to `false`!');
|
||||
} else {
|
||||
client.global.db.guilds[message.guild.id].startPlaying = true;
|
||||
return message.channel.send(':white_check_mark: announcesongs now set to `true`!');
|
||||
}
|
||||
} else {
|
||||
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...`')
|
||||
.addField('prefix', 'Change the guild specific prefix. (string)', true)
|
||||
.addField('volume', 'Change the default volume that the bot will start playing at. (number)', true)
|
||||
.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.')
|
||||
.setFooter(`how to use: ${prefix}settings <Setting name> <value>`)
|
||||
.setAuthor(client.user.username, client.user.displayAvatarURL)
|
||||
.setColor('#b50002')
|
||||
|
@ -8,9 +8,11 @@ module.exports = {
|
||||
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 !== 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 (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to skip the song!');
|
||||
if (client.global.db.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!');
|
||||
if (client.global.db.guilds[message.guild.id].dj) {
|
||||
if (!message.member.roles.has(client.global.db.guilds[message.guild.id].djrole)) return message.channel.send(':x: You need the `DJ` role to skip songs!');
|
||||
} else 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!');
|
||||
|
@ -14,11 +14,6 @@ module.exports = {
|
||||
} else {
|
||||
finalUptime = `${Math.round(uptime.d * 10) / 10} days`;
|
||||
}
|
||||
if (process.env.LOCALLYHOSTED === "true") {
|
||||
hosted = 'Locally';
|
||||
} else {
|
||||
hosted = 'Online';
|
||||
}
|
||||
let ping = Math.floor(client.ping * 10) / 10;
|
||||
|
||||
const embed = new Discord.RichEmbed()
|
||||
@ -26,7 +21,6 @@ module.exports = {
|
||||
.addField(':signal_strength: Ping', ping, true)
|
||||
.addField(':stopwatch: Uptime', finalUptime, 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')
|
||||
|
@ -5,12 +5,14 @@ module.exports = {
|
||||
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.');
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
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 stop the music!');
|
||||
if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could stop for you.');
|
||||
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to stop the music!');
|
||||
if (client.global.db.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!');
|
||||
if (client.global.db.guilds[message.guild.id].dj) {
|
||||
if (!message.member.roles.has(client.global.db.guilds[message.guild.id].djrole)) return message.channel.send(':x: You need the `DJ` role to stop the music!');
|
||||
} else if (!permissions.has('MANAGE_CHANNELS')) return message.channel.send(':x: You need the `MANAGE_CHANNELS` permission to stop the music!');
|
||||
}
|
||||
}
|
||||
serverQueue.songs = [];
|
||||
|
@ -9,17 +9,20 @@ module.exports = {
|
||||
if (message.author.id === '384002606621655040') return message.channel.send('You are not doying that!');
|
||||
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}**`);
|
||||
const volume = parseFloat(args[1]);
|
||||
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 (client.global.db.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 (client.global.db.guilds[message.guild.id].dj) {
|
||||
if (!message.member.roles.has(client.global.db.guilds[message.guild.id].djrole)) return message.channel.send(':x: You need the `DJ` role to change the volume!');
|
||||
} else 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!');
|
||||
}
|
||||
serverQueue.volume = args[1];
|
||||
serverQueue.connection.dispatcher.setVolume(args[1] / 5);
|
||||
return message.channel.send(`:loud_sound: I set the volume to: **${args[1]}**`);
|
||||
if (isNaN(volume)) return message.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.');
|
||||
if (volume > 100) return message.channel.send(':x: The max volume is `100`!');
|
||||
if (volume < 0) return message.channel.send(':x: The volume needs to be a positive number!');
|
||||
serverQueue.volume = volume;
|
||||
serverQueue.connection.dispatcher.setVolume(volume / 5);
|
||||
return message.channel.send(`:loud_sound: I set the volume to: **${volume}**`);
|
||||
}
|
||||
};
|
||||
|
@ -5,11 +5,19 @@ module.exports = {
|
||||
prefix: '>',
|
||||
defaultVolume: 5,
|
||||
permissions: false,
|
||||
premium: false,
|
||||
dj: false,
|
||||
djrole: null,
|
||||
startPlaying: true
|
||||
});
|
||||
client.global.db.guilds[guild.id] = {
|
||||
prefix: ">",
|
||||
defaultVolume: 5,
|
||||
permissions: false,
|
||||
premium: false,
|
||||
dj: false,
|
||||
djrole: null,
|
||||
startPlaying: true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ module.exports = {
|
||||
prefix: ">",
|
||||
defaultVolume: 5,
|
||||
permissions: false,
|
||||
premium: false,
|
||||
dj: false,
|
||||
djrole: null
|
||||
};
|
||||
});
|
||||
return message.channel.send(':white_check_mark: Reset all guild settings!')
|
||||
@ -16,6 +19,9 @@ module.exports = {
|
||||
prefix: ">",
|
||||
defaultVolume: 5,
|
||||
permissions: false,
|
||||
premium: false,
|
||||
dj: false,
|
||||
djrole: null
|
||||
};
|
||||
}
|
||||
let prefix = client.global.db.guilds[message.guild.id].prefix;
|
||||
@ -39,6 +45,9 @@ module.exports = {
|
||||
if (commandName === 'np') {
|
||||
commandName = 'nowplaying';
|
||||
}
|
||||
if (commandName === 'rm') {
|
||||
commandName = 'remove';
|
||||
}
|
||||
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
|
||||
const permissions = message.channel.permissionsFor(message.client.user);
|
||||
if (!permissions.has('EMBED_LINKS')) return message.channel.send(':x: I cannot send embeds (Embed links), make sure I have the proper permissions!');
|
||||
@ -52,6 +61,7 @@ module.exports = {
|
||||
.setDescription(error.stack.replace(/at /g, '**at **'))
|
||||
.setColor('#b50002');
|
||||
client.fetchUser('360363051792203779').then(user => user.send(embed)).catch(console.error);
|
||||
client.channels.get('634718645188034560').send(embed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,22 +2,50 @@ module.exports = {
|
||||
name: 'ready',
|
||||
async execute(client, dbl) {
|
||||
const remoteMusixGuildsData = await client.funcs.dbget('guilds', null, client);
|
||||
const remoteMusixPlaylistsData = await client.funcs.dbget('playlists', null, client);
|
||||
remoteMusixGuildsData.forEach(guildData => {
|
||||
client.global.db.guilds[guildData.id] = guildData.d;
|
||||
});
|
||||
remoteMusixPlaylistsData.forEach(guildData => {
|
||||
client.global.db.playlists[guildData.id] = guildData.d;
|
||||
});
|
||||
console.log('- DB Set -');
|
||||
client.user.setActivity(`@musix help | 🎶`, { type: 'LISTENING' });
|
||||
client.user.setStatus('dnd');
|
||||
dbl.postStats(client.guilds.size);
|
||||
console.log('- Activated -');
|
||||
let users = 0;
|
||||
client.guilds.forEach(guild => {
|
||||
users += guild.memberCount;
|
||||
})
|
||||
let status = [`${users} users on ${client.guilds.size} guilds!`, '@musix help | 🎶'];
|
||||
let i = 0;
|
||||
setInterval(() => {
|
||||
if (i == status.length) {
|
||||
i = 0;
|
||||
}
|
||||
client.user.setActivity(status[i], { type: 'LISTENING' });
|
||||
i++;
|
||||
}, 30000);
|
||||
setInterval(async () => {
|
||||
client.guilds.forEach(guild => {
|
||||
client.db.collection('guilds').doc(guild.id).set({
|
||||
prefix: client.global.db.guilds[guild.id].prefix,
|
||||
defaultVolume: client.global.db.guilds[guild.id].defaultVolume,
|
||||
permissions: client.global.db.guilds[guild.id].permissions,
|
||||
premium: client.global.db.guilds[guild.id].premium,
|
||||
dj: client.global.db.guilds[guild.id].dj,
|
||||
djrole: client.global.db.guilds[guild.id].djrole,
|
||||
startPlaying: client.global.db.guilds[guild.id].startPlaying
|
||||
});
|
||||
if (client.global.db.guilds[guild.id].premium) {
|
||||
client.db.collection('playlists').doc(guild.id).set({
|
||||
songs: client.global.db.playlists[guild.id].songs,
|
||||
saved: client.global.db.playlists[guild.id].saved,
|
||||
});
|
||||
}
|
||||
});
|
||||
dbl.postStats(client.guilds.size);
|
||||
}, 1200000);
|
||||
}, 1800000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ module.exports = async function (video, message, voiceChannel, client, playlist
|
||||
let song = {
|
||||
id: video.id,
|
||||
title: Discord.Util.escapeMarkdown(video.title),
|
||||
url: `https://www.youtube.com/watch?v=${video.id}`
|
||||
url: `https://www.youtube.com/watch?v=${video.id}`,
|
||||
author: message.author
|
||||
}
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
if (client.global.db.guilds[message.guild.id].defaultVolume === undefined) {
|
||||
@ -28,16 +29,14 @@ module.exports = async function (video, message, voiceChannel, client, playlist
|
||||
try {
|
||||
var connection = await voiceChannel.join();
|
||||
construct.connection = connection;
|
||||
client.funcs.play(message.guild, construct.songs[0], client, message, 0);
|
||||
client.funcs.play(message.guild, construct.songs[0], client, message, 0, true);
|
||||
} catch (error) {
|
||||
client.queue.delete(message.guild.id);
|
||||
client.channels.get('634718645188034560').send("Error with connecting to voice channel: " + error);
|
||||
return message.channel.send(`:x: An error occured: ${error}`);
|
||||
}
|
||||
} else {
|
||||
serverQueue.songs.push(song);
|
||||
if (serverQueue.looping) {
|
||||
client.secondaryQueue.push(song);
|
||||
}
|
||||
if (playlist) return undefined;
|
||||
return message.channel.send(`:white_check_mark: **${song.title}** has been added to the queue!`);
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
module.exports = async function (guild, song, client, message, seek) {
|
||||
module.exports = async function (guild, song, client, message, seek, play) {
|
||||
const Discord = require('discord.js');
|
||||
const ytdl = require('ytdl-core');
|
||||
const serverQueue = client.queue.get(guild.id);
|
||||
if (!song) {
|
||||
console.log('No song')
|
||||
serverQueue.voiceChannel.leave();
|
||||
client.queue.delete(guild.id);
|
||||
return;
|
||||
@ -17,19 +18,21 @@ module.exports = async function (guild, song, client, message, seek) {
|
||||
} else {
|
||||
console.log(reason);
|
||||
}
|
||||
serverQueue.songs.shift();
|
||||
if (serverQueue.looping && serverQueue.songs.length === 0) {
|
||||
serverQueue.songs = [...client.secondaryQueue];
|
||||
if (serverQueue.looping) {
|
||||
serverQueue.songs.push(serverQueue.songs[0]);
|
||||
}
|
||||
serverQueue.songs.shift();
|
||||
client.funcs.play(guild, serverQueue.songs[0], client, message);
|
||||
});
|
||||
dispatcher.setVolume(serverQueue.volume / 10);
|
||||
dispatcher.on("error", error => console.error(error));
|
||||
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
|
||||
let songtime = (data.length_seconds * 1000).toFixed(0);
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setTitle(`:musical_note: Start playing: **${song.title}**`)
|
||||
.setDescription(`Song duration: \`${client.funcs.msToTime(songtime)}\``)
|
||||
.setColor("#b50002")
|
||||
serverQueue.textChannel.send(embed);
|
||||
if (client.global.db.guilds[guild.id].startPlaying || play) {
|
||||
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
|
||||
let songtime = (data.length_seconds * 1000).toFixed(0);
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setTitle(`:musical_note: Start playing: **${song.title}**`)
|
||||
.setDescription(`Song duration: \`${client.funcs.msToTime(songtime)}\``)
|
||||
.setColor("#b50002")
|
||||
serverQueue.textChannel.send(embed);
|
||||
}
|
||||
}
|
||||
|
2
index.js
2
index.js
@ -18,6 +18,7 @@ client.db.FieldValue = require('firebase-admin').firestore.FieldValue;
|
||||
client.global = {
|
||||
db: {
|
||||
guilds: {},
|
||||
playlists: {},
|
||||
},
|
||||
};
|
||||
|
||||
@ -25,7 +26,6 @@ client.commands = new Discord.Collection();
|
||||
client.events = new Discord.Collection();
|
||||
client.cooldowns = new Discord.Collection();
|
||||
client.queue = new Map();
|
||||
client.secondaryQueue = [];
|
||||
client.funcs = {};
|
||||
|
||||
client.funcs.handleVideo = require('./funcs/handleVideo.js');
|
||||
|
1581
package-lock.json
generated
1581
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@ -13,14 +13,14 @@
|
||||
"dependencies": {
|
||||
"dblapi.js": "^2.3.0",
|
||||
"discord.js": "^11.5.1",
|
||||
"dotenv": "^8.1.0",
|
||||
"ffmpeg": "0.0.4",
|
||||
"firebase": "^6.6.0",
|
||||
"firebase-admin": "^8.5.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"ffmpeg-binaries": "^4.0.0",
|
||||
"firebase": "^6.6.2",
|
||||
"firebase-admin": "^8.6.1",
|
||||
"fs": "0.0.1-security",
|
||||
"he": "^1.2.0",
|
||||
"ms": "^2.1.1",
|
||||
"node-opus": "^0.3.2",
|
||||
"ms": "^2.1.2",
|
||||
"node-opus": "^0.3.3",
|
||||
"request": "^2.88.0",
|
||||
"simple-youtube-api": "^5.2.1",
|
||||
"ytdl-core": "^0.29.7"
|
||||
|
Loading…
Reference in New Issue
Block a user