1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-14 03:30:18 +00:00

Option handler for playlists and settings. Exe function to execute command files. Command aliases updated.

This commit is contained in:
MatteZ02 2019-10-31 20:29:26 +02:00
parent 1899c8647b
commit 8615735431
33 changed files with 392 additions and 277 deletions

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
name: 'bug', name: 'bug',
description: 'Report a bug', description: 'Report a bug',
alias: 'bug',
cooldown: 5, cooldown: 5,
async execute(message, args, client, Discord, prefix) { async execute(message, args, client, Discord, prefix) {
const embed = new Discord.RichEmbed() const embed = new Discord.RichEmbed()

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
name: 'eval', name: 'eval',
description: 'Evaluation command', description: 'Evaluation command',
alias: 'eval',
cooldown: 5, cooldown: 5,
async execute(message, args, client, Discord, prefix) { async execute(message, args, client, Discord, prefix) {
const ytdl = require('ytdl-core'); const ytdl = require('ytdl-core');
@ -8,7 +9,7 @@ module.exports = {
if (serverQueue) { if (serverQueue) {
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url)); 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!'); if (message.author.id !== client.global.devId) return message.channel.send(':x: You are not allowed to do that!');
const input = message.content.slice(prefix.length + 4); const input = message.content.slice(prefix.length + 4);
let output; let output;
try { try {

View File

@ -1,9 +1,10 @@
module.exports = { module.exports = {
name: 'forcestop', name: 'forcestop',
description: 'force stop command.', description: 'force stop command.',
alias: 'fs',
cooldown: 5, cooldown: 5,
execute(message, args, client, Discord, prefix) { execute(message, args, client, Discord, prefix) {
if (message.author.id !== '360363051792203779') return message.channel.send(':x: You are not allowed to do that!') if (message.author.id !== client.global.devId) return message.channel.send(':x: You are not allowed to do that!')
client.queue.delete(message.guild.id); client.queue.delete(message.guild.id);
message.channel.send('queue deleted') message.channel.send('queue deleted')
} }

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
name: 'help', name: 'help',
description: 'Help command.', description: 'Help command.',
alias: 'help',
cooldown: 5, cooldown: 5,
execute(message, args, client, Discord, prefix) { execute(message, args, client, Discord, prefix) {
const embed = new Discord.RichEmbed() const embed = new Discord.RichEmbed()

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
name: 'invite', name: 'invite',
description: 'Invite command.', description: 'Invite command.',
alias: 'invite',
cooldown: 5, cooldown: 5,
execute(message, args, client, Discord, prefix) { execute(message, args, client, Discord, prefix) {
const embed = new Discord.RichEmbed() const embed = new Discord.RichEmbed()

View File

@ -1,13 +1,14 @@
module.exports = { module.exports = {
name: 'loop', name: 'loop',
description: 'loop command.', description: 'loop command.',
alias: 'loop',
cooldown: 10, cooldown: 10,
async execute(message, args, client, Discord, prefix) { async execute(message, args, client, Discord, prefix) {
const serverQueue = client.queue.get(message.guild.id); const serverQueue = client.queue.get(message.guild.id);
const permissions = message.channel.permissionsFor(message.author); const permissions = message.channel.permissionsFor(message.author);
const { voiceChannel } = message.member; const { voiceChannel } = message.member;
if (serverQueue) { if (serverQueue) {
if (message.author.id !== '360363051792203779') { if (message.author.id !== client.global.devId) {
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 (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 (client.global.db.guilds[message.guild.id].permissions === true) {
if (client.global.db.guilds[message.guild.id].dj) { if (client.global.db.guilds[message.guild.id].dj) {

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
name: 'nowplaying', name: 'nowplaying',
description: 'Now playing command.', description: 'Now playing command.',
alias: 'np',
cooldown: 5, cooldown: 5,
async execute(message, args, client, Discord, prefix) { async execute(message, args, client, Discord, prefix) {
const ytdl = require('ytdl-core'); const ytdl = require('ytdl-core');

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
name: 'pause', name: 'pause',
description: 'Pause command.', description: 'Pause command.',
alias: 'pause',
cooldown: 5, cooldown: 5,
execute(message, args, client, Discord, prefix) { execute(message, args, client, Discord, prefix) {
const serverQueue = client.queue.get(message.guild.id); const serverQueue = client.queue.get(message.guild.id);
@ -8,7 +9,7 @@ module.exports = {
const { voiceChannel } = message.member; const { voiceChannel } = message.member;
if (serverQueue && serverQueue.playing === true) { 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 voice channel 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 (message.author.id !== client.global.devId) {
if (client.global.db.guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].permissions === true) {
if (client.global.db.guilds[message.guild.id].dj) { 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!'); 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!');

View File

@ -5,6 +5,7 @@ module.exports = {
name: 'play', name: 'play',
description: 'Play command.', description: 'Play command.',
usage: '[song name]', usage: '[song name]',
alias: 'p',
args: true, args: true,
cooldown: 3, cooldown: 3,
async execute(message, args, client, Discord, prefix) { async execute(message, args, client, Discord, prefix) {

View File

@ -5,152 +5,43 @@ module.exports = {
name: 'playlist', name: 'playlist',
usage: '[option]', usage: '[option]',
description: 'Save and load queues', description: 'Save and load queues',
alias: 'pl',
cooldown: 10, cooldown: 10,
async execute(message, args, client, Discord, prefix) { async execute(message, args, client, Discord, prefix) {
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')
const permissions = message.channel.permissionsFor(message.author); const permissions = message.channel.permissionsFor(message.author);
const serverQueue = client.queue.get(message.guild.id); if (message.author.id !== client.global.devId) {
if (message.author.id !== '360363051792203779') {
if (client.global.db.guilds[message.guild.id].dj) { 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!'); 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!'); } 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 (client.global.db.guilds[message.guild.id].premium) {
if (args[1] === 'play') { if (args[1]) {
const voiceChannel = message.member.voiceChannel; const optionName = args[1].toLowerCase();
if (!voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in a voice channel to play music!'); const option = client.playlistCmd.get(optionName) || client.playlistCmd.find(cmd => cmd.aliases && cmd.aliases.includes(optionName));
const permissions = voiceChannel.permissionsFor(message.client.user); if (!option) return message.channel.send(embed);
if (!permissions.has('CONNECT')) { try {
return message.channel.send(':x: I cannot connect to your voice channel, make sure I have the proper permissions!'); option.execute(message, args, client, Discord, prefix);
} catch (error) {
message.reply(`:x: there was an error trying to execute that option! Please contact support with \`${prefix}bug\`!`);
const embed = new Discord.RichEmbed()
.setTitle(`Musix ${error.toString()}`)
.setDescription(error.stack.replace(/at /g, '**at **'))
.setColor('#b50002');
client.fetchUser(client.config.devId).then(user => user.send(embed)).catch(console.error);
client.channels.get('634718645188034560').send(embed);
console.log(error);
} }
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 { } 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); return message.channel.send(embed);
} }
} else return message.channel.send(":x: This is not a premium guild!"); } else return message.channel.send(":x: This is not a premium guild!");

51
commands/playlist/add.js Normal file
View File

@ -0,0 +1,51 @@
const YouTube = require("simple-youtube-api");
const he = require('he');
module.exports = {
name: 'add',
async execute(message, args, client, Discord, prefix) {
if (client.global.db.playlists[message.guild.id].saved) {
const serverQueue = client.queue.get(message.guild.id);
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!');
}
};

22
commands/playlist/list.js Normal file
View File

@ -0,0 +1,22 @@
module.exports = {
name: 'list',
async execute(message, args, client, Discord, prefix) {
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);
}
};

51
commands/playlist/play.js Normal file
View File

@ -0,0 +1,51 @@
module.exports = {
name: 'play',
async execute(message, args, client, Discord, prefix) {
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 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!')
}
};

View File

@ -0,0 +1,14 @@
module.exports = {
name: 'remove',
async execute(message, args, client, Discord, prefix) {
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!');
}
};

13
commands/playlist/save.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
name: 'save',
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!');
client.global.db.playlists[message.guild.id] = {
songs: serverQueue.songs,
firstSong: serverQueue.songs[0],
saved: true,
};
message.channel.send(":white_check_mark: Queue saved!");
}
};

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
name: 'queue', name: 'queue',
description: 'Queue command.', description: 'Queue command.',
alias: 'q',
cooldown: 5, cooldown: 5,
async execute(message, args, client, Discord, prefix) { async execute(message, args, client, Discord, prefix) {
const serverQueue = client.queue.get(message.guild.id); const serverQueue = client.queue.get(message.guild.id);

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
name: 'remove', name: 'remove',
description: 'Remove command.', description: 'Remove command.',
alias: 'rm',
cooldown: 5, cooldown: 5,
execute(message, args, client, Discord, prefix) { execute(message, args, client, Discord, prefix) {
const { voiceChannel } = message.member; const { voiceChannel } = message.member;
@ -12,7 +13,7 @@ module.exports = {
if (isNaN(pos)) return message.channel.send(':x: You need to enter a number!'); 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 === 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 (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 (message.author.id !== client.global.devId) {
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 (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 (client.global.db.guilds[message.guild.id].dj) {
if (serverQueue.songs[pos].author !== message.author) { if (serverQueue.songs[pos].author !== message.author) {

View File

@ -1,13 +1,14 @@
module.exports = { module.exports = {
name: 'resume', name: 'resume',
description: 'Resume command.', description: 'Resume command.',
alias: 'resume',
cooldown: 5, cooldown: 5,
execute(message, args, client, Discord, prefix) { execute(message, args, client, Discord, prefix) {
const serverQueue = client.queue.get(message.guild.id); const serverQueue = client.queue.get(message.guild.id);
const permissions = message.channel.permissionsFor(message.author); const permissions = message.channel.permissionsFor(message.author);
const { voiceChannel } = message.member; const { voiceChannel } = message.member;
if (serverQueue && !serverQueue.playing) { if (serverQueue && !serverQueue.playing) {
if (message.author.id !== '360363051792203779') { if (message.author.id !== client.global.devId) {
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 (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 (client.global.db.guilds[message.guild.id].permissions === true) {
if (client.global.db.guilds[message.guild.id].dj) { if (client.global.db.guilds[message.guild.id].dj) {

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
name: 'seek', name: 'seek',
description: 'seek command.', description: 'seek command.',
alias: 'seek',
cooldown: 10, cooldown: 10,
async execute(message, args, client, Discord, prefix) { async execute(message, args, client, Discord, prefix) {
const ytdl = require('ytdl-core'); const ytdl = require('ytdl-core');
@ -9,7 +10,7 @@ module.exports = {
const { voiceChannel } = message.member; const { voiceChannel } = message.member;
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url)); let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
if (serverQueue) { if (serverQueue) {
if (message.author.id !== '360363051792203779') { if (message.author.id !== client.global.devId) {
return message.channel.send(':x: This command is currently disabled!'); 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 voice channel 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 (client.global.db.guilds[message.guild.id].permissions === true) {

View File

@ -2,106 +2,39 @@ module.exports = {
name: 'settings', name: 'settings',
usage: '[setting]', usage: '[setting]',
description: 'Change the settings', description: 'Change the settings',
alias: 'settings',
cooldown: 10, cooldown: 10,
async execute(message, args, client, Discord, prefix) { async execute(message, args, client, Discord, prefix) {
const embed = new Discord.RichEmbed()
.setTitle('Guild settings for Musix')
.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')
const permissions = message.channel.permissionsFor(message.author); const permissions = message.channel.permissionsFor(message.author);
if (message.author.id !== '360363051792203779') { if (message.author.id !== client.config.devId) {
if (!permissions.has('MANAGE_GUILD')) return message.channel.send(':x: You need the `MANAGE_SERVER` permission to change the settings!'); 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[1]) {
if (!args[2]) return message.channel.send(`<:thonk:461691390972264449> Current prefix: \`${client.global.db.guilds[message.guild.id].prefix}\``); const optionName = args[1].toLowerCase();
client.global.db.guilds[message.guild.id].prefix = args[2]; const option = client.settingCmd.get(optionName) || client.settingCmd.find(cmd => cmd.aliases && cmd.aliases.includes(optionName));
message.channel.send(`:white_check_mark: New prefix set to: \`${args[2]}\``); if (!option) return message.channel.send(embed);
} else if (args[1] === 'volume') { try {
if (!args[2]) return message.channel.send(`:speaker: Current default volume is: \`${client.global.db.guilds[message.guild.id].defaultVolume}\``); option.execute(message, args, client, Discord, prefix);
if (isNaN(args[2])) return message.channel.send(':x: I\'m sorry, But the default volume needs to be a valid __number__.'); } catch (error) {
if (args[2].length > 2) return message.channel.send(':x: The default volume must be below `100` for quality and safety resons.'); message.reply(`:x: there was an error trying to execute that option! Please contact support with \`${prefix}bug\`!`);
client.global.db.guilds[message.guild.id].defaultVolume = args[2]; const embed = new Discord.RichEmbed()
message.channel.send(`:white_check_mark: Default volume set to: \`${args[2]}\``); .setTitle(`Musix ${error.toString()}`)
} else if (args[1] === 'permissions') { .setDescription(error.stack.replace(/at /g, '**at **'))
if (!args[2]) return message.channel.send(`🔒 Permission requirement: \`${client.global.db.guilds[message.guild.id].permissions}\``); .setColor('#b50002');
if (args[2] === 'true') { client.fetchUser(client.config.devId).then(user => user.send(embed)).catch(console.error);
if (!client.global.db.guilds[message.guild.id].permissions) { client.channels.get('634718645188034560').send(embed);
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) {
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 { } else {
const embed = new Discord.RichEmbed()
.setTitle('Guild settings for Musix')
.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')
return message.channel.send(embed); return message.channel.send(embed);
} }
}, },

View File

@ -0,0 +1,12 @@
module.exports = {
name: 'announcesongs',
async execute(message, args, client, Discord, prefix) {
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`!');
}
}
};

View File

@ -0,0 +1,17 @@
module.exports = {
name: 'permissions',
async execute(message, args, client, Discord, prefix) {
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) {
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) {
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)');
}
};

View File

@ -0,0 +1,8 @@
module.exports = {
name: 'prefix',
async execute(message, args, client, Discord, prefix) {
if (!args[2]) return message.channel.send(`Current prefix: \`${client.global.db.guilds[message.guild.id].prefix}\``);
client.global.db.guilds[message.guild.id].prefix = args[2];
message.channel.send(`:white_check_mark: New prefix set to: \`${args[2]}\``);
}
};

View File

@ -0,0 +1,27 @@
module.exports = {
name: 'setdj',
async execute(message, args, client, Discord, prefix) {
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`');
}
}
};

View File

@ -0,0 +1,34 @@
module.exports = {
name: 'setpremium',
async execute(message, args, client, Discord, prefix) {
if (message.author.id !== client.config.devId) return;
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!")
}
}
}
};

View File

@ -0,0 +1,10 @@
module.exports = {
name: 'volume',
async execute(message, args, client, Discord, prefix) {
if (!args[2]) return message.channel.send(`:speaker: Current default volume is: \`${client.global.db.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.guilds[message.guild.id].defaultVolume = args[2];
message.channel.send(`:white_check_mark: Default volume set to: \`${args[2]}\``);
}
};

View File

@ -1,13 +1,14 @@
module.exports = { module.exports = {
name: 'skip', name: 'skip',
description: 'Skip command.', description: 'Skip command.',
alias: 'skip',
cooldown: 5, cooldown: 5,
execute(message, args, client, Discord, prefix) { execute(message, args, client, Discord, prefix) {
const { voiceChannel } = message.member; const { voiceChannel } = message.member;
const serverQueue = client.queue.get(message.guild.id); const serverQueue = client.queue.get(message.guild.id);
const permissions = message.channel.permissionsFor(message.author); 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 (!serverQueue) return message.channel.send(':x: There is nothing playing that I could skip for you.');
if (message.author.id !== '360363051792203779') { if (message.author.id !== client.config.devId) {
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 (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 (client.global.db.guilds[message.guild.id].permissions === true) {
if (client.global.db.guilds[message.guild.id].dj) { if (client.global.db.guilds[message.guild.id].dj) {

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
name: 'status', name: 'status',
description: 'Status command.', description: 'Status command.',
alias: 'status',
cooldown: 5, cooldown: 5,
execute(message, args, client, Discord, prefix) { execute(message, args, client, Discord, prefix) {
let rawUptime = client.uptime; let rawUptime = client.uptime;

View File

@ -1,12 +1,13 @@
module.exports = { module.exports = {
name: 'stop', name: 'stop',
description: 'Stop command.', description: 'Stop command.',
alias: 'stop',
cooldown: 5, cooldown: 5,
execute(message, args, client, Discord, prefix) { execute(message, args, client, Discord, prefix) {
const { voiceChannel } = message.member; const { voiceChannel } = message.member;
const serverQueue = client.queue.get(message.guild.id); const serverQueue = client.queue.get(message.guild.id);
const permissions = message.channel.permissionsFor(message.author); const permissions = message.channel.permissionsFor(message.author);
if (message.author.id !== '360363051792203779') { if (message.author.id !== client.config.devId) {
if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could stop for you.'); 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 (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 (client.global.db.guilds[message.guild.id].permissions === true) {

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
name: 'volume', name: 'volume',
description: 'Volume command.', description: 'Volume command.',
alias: 'volume',
cooldown: 5, cooldown: 5,
execute(message, args, client, Discord, prefix) { execute(message, args, client, Discord, prefix) {
const { voiceChannel } = message.member; const { voiceChannel } = message.member;
@ -10,7 +11,7 @@ module.exports = {
if (!serverQueue) return message.channel.send(':x: There is nothing playing.'); 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 (!args[1]) return message.channel.send(`:loud_sound: The current volume is: **${serverQueue.volume}**`);
const volume = parseFloat(args[1]); const volume = parseFloat(args[1]);
if (message.author.id !== '360363051792203779') { if (message.author.id !== client.config.devId) {
if (!voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in a voice channel to change the 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 (client.global.db.guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].permissions === true) {
if (client.global.db.guilds[message.guild.id].dj) { if (client.global.db.guilds[message.guild.id].dj) {

View File

@ -2,66 +2,47 @@ module.exports = {
name: 'message', name: 'message',
async execute(client, message, Discord) { async execute(client, message, Discord) {
if (message.author.bot || !message.guild) return; if (message.author.bot || !message.guild) return;
if (message.content === '->reset' && message.author.id === '360363051792203779') { if (message.content === '->reset' && message.author.id === client.global.devId) {
client.guilds.forEach(guild => { client.guilds.forEach(guild => {
client.global.db.guilds[guild.id] = { client.global.db.guilds[guild.id] = {
prefix: ">", prefix: client.config.prefix,
defaultVolume: 5, defaultVolume: 5,
permissions: false, permissions: false,
premium: false, premium: false,
dj: false, dj: false,
djrole: null djrole: null
}; };
return message.channel.send(':white_check_mark: Reset all guild settings for __all__ guilds!');
}); });
return message.channel.send(':white_check_mark: Reset all guild settings!') return message.channel.send(':white_check_mark: Reset all guild settings!')
} else if (message.content === '->resetguildsettings' && message.author.id === '360363051792203779') { } else if (message.content === '->resetguildsettings' && message.author.id === client.global.devId) {
client.global.db.guilds[message.guild.id] = { client.global.db.guilds[message.guild.id] = {
prefix: ">", prefix: client.config.prefix,
defaultVolume: 5, defaultVolume: 5,
permissions: false, permissions: false,
premium: false, premium: false,
dj: false, dj: false,
djrole: null djrole: null
}; };
return message.channel.send(':white_check_mark: Reset all guild settings for this guild!');
} }
let prefix = client.global.db.guilds[message.guild.id].prefix; let prefix = client.global.db.guilds[message.guild.id].prefix;
const args = message.content.slice(prefix.length).split(' '); const args = message.content.slice(prefix.length).split(' ');
let commandName;
if (message.mentions.users.first()) { if (message.mentions.users.first()) {
if (message.mentions.users.first().id === '607266889537945605' && args[1] === 'help') return client.commands.get('help').execute(message, args, client, Discord, prefix, client); if (message.mentions.users.first().id === client.config.botId) {
if (message.mentions.users.first().id === '607266889537945605' && args[1] === 'prefix') return message.channel.send(`My prefix here is: \`${prefix}\`.`); if (!args[1]) return;
if (args[1] === 'prefix') return message.channel.send(`My prefix here is: \`${prefix}\`.`);
commandName = args[1].toLowerCase();
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName);
client.funcs.exe(message, args, client, Discord, prefix, command);
}
} }
if (!message.content.startsWith(prefix)) return; if (!message.content.startsWith(prefix)) return;
if (!args[0]) return; if (!args[0]) return;
let commandName = args[0].toLowerCase(); commandName = args[0].toLowerCase();
if (commandName === `p`) { const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName);
commandName = 'play';
}
if (commandName === 'q') {
commandName = 'queue';
}
if (commandName === 's') {
commandName = 'skip';
}
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!');
if (!command && message.content !== `${prefix}`) return; if (!command && message.content !== `${prefix}`) return;
try { client.funcs.exe(message, args, client, Discord, prefix, command);
command.execute(message, args, client, Discord, prefix);
} catch (error) {
message.reply(`:x: there was an error trying to execute that command! Please contact support with \`${prefix}bug\`!`);
const embed = new Discord.RichEmbed()
.setTitle(`Musix ${error.toString()}`)
.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);
}
} }
} }

15
funcs/exe.js Normal file
View File

@ -0,0 +1,15 @@
module.exports = function (message, args, client, Discord, prefix, command) {
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!');
try {
command.execute(message, args, client, Discord, prefix);
} catch (error) {
message.reply(`:x: there was an error trying to execute that command! Please contact support with \`${prefix}bug\`!`);
const embed = new Discord.RichEmbed()
.setTitle(`Musix ${error.toString()}`)
.setDescription(error.stack.replace(/at /g, '**at **'))
.setColor('#b50002');
client.fetchUser(client.global.devId).then(user => user.send(embed)).catch(console.error);
client.channels.get('634718645188034560').send(embed);
}
};

View File

@ -23,6 +23,9 @@ client.global = {
}; };
client.commands = new Discord.Collection(); client.commands = new Discord.Collection();
client.commandAliases = new Discord.Collection();
client.playlistCmd = new Discord.Collection();
client.settingCmd = new Discord.Collection();
client.events = new Discord.Collection(); client.events = new Discord.Collection();
client.cooldowns = new Discord.Collection(); client.cooldowns = new Discord.Collection();
client.queue = new Map(); client.queue = new Map();
@ -32,17 +35,21 @@ client.funcs.handleVideo = require('./funcs/handleVideo.js');
client.funcs.play = require('./funcs/play.js'); client.funcs.play = require('./funcs/play.js');
client.funcs.msToTime = require('./funcs/msToTime.js'); client.funcs.msToTime = require('./funcs/msToTime.js');
client.funcs.dbget = require('./funcs/dbget.js'); client.funcs.dbget = require('./funcs/dbget.js');
client.funcs.exe = require('./funcs/exe.js');
client.config = { client.config = {
token: process.env.TOKEN, token: process.env.TOKEN,
apikey: process.env.API_KEY, apikey: process.env.API_KEY,
botId: "607266889537945605",
devId: "360363051792203779",
prefix: '>', prefix: '>',
test: 'success',
}; };
const commandFiles = fs.readdirSync('./commands/').filter(f => f.endsWith('.js')); const commandFiles = fs.readdirSync('./commands/').filter(f => f.endsWith('.js'));
for (const file of commandFiles) { for (const file of commandFiles) {
const command = require(`./commands/${file}`); const command = require(`./commands/${file}`);
client.commands.set(command.name, command); client.commands.set(command.name, command);
client.commandAliases.set(command.alias, command);
} }
const eventFiles = fs.readdirSync('./events/').filter(f => f.endsWith('.js')); const eventFiles = fs.readdirSync('./events/').filter(f => f.endsWith('.js'));
for (const file of eventFiles) { for (const file of eventFiles) {
@ -50,6 +57,18 @@ for (const file of eventFiles) {
client.events.set(event.name, event); client.events.set(event.name, event);
} }
const playlistFiles = fs.readdirSync('./commands/playlist/').filter(f => f.endsWith('.js'));
for (const file of playlistFiles) {
const option = require(`./commands/playlist/${file}`);
client.playlistCmd.set(option.name, option);
}
const settingFiles = fs.readdirSync('./commands/settings/').filter(f => f.endsWith('.js'));
for (const file of settingFiles) {
const option = require(`./commands/settings/${file}`);
client.settingCmd.set(option.name, option);
}
client.on('ready', async () => { client.on('ready', async () => {
const eventName = 'ready'; const eventName = 'ready';
const event = client.events.get(eventName) || client.events.find(ent => ent.aliases && ent.aliases.includes(eventName)); const event = client.events.get(eventName) || client.events.find(ent => ent.aliases && ent.aliases.includes(eventName));