Merge branch 'master' into master

This commit is contained in:
Cecemel_PvP
2020-12-27 14:22:43 +01:00
committed by GitHub
28 changed files with 157 additions and 135 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,2 @@
# Node # Node
node_modules/ node_modules/

View File

@@ -8,38 +8,38 @@ If you need help with this project, to get support faster you can join the help
### ⚡ Installation ### ⚡ Installation
Well, let's start by downloading the code. Well, let's start by downloading the code.
Go to the folder `config` then the file `config.json`. Go to the folder `config` then the file `bot.js`.
For the bot to be able to start, please complete the file with your credentials as follows : For the bot to be able to start, please complete the file with your credentials as follows :
- For emojis
```js ```js
{ emojis: {
"game": "GAME", off: ':x:',
"prefix": "PREFIX", error: ':warning:',
"token_bot": "TOKEN" queue: ':bar_chart:',
music: ':musical_note:',
success: ':white_check_mark:',
} }
``` ```
Reminder : - For configuration
- `game`, the status of the bot. ```js
discord: {
token: 'TOKEN',
prefix: 'PREFIX',
activity: 'ACTIVITY',
}
```
- `token`, the token of the bot available on the [Discord Developers](https://discordapp.com/developers/applications) section.
- `prefix`, the prefix that will be set to use the bot. - `prefix`, the prefix that will be set to use the bot.
- `token_bot`, the token of the bot available on the [Discord Developers](https://discordapp.com/developers/applications) section. - `activity`, the activity of the bot.
To customize the emojis go to the file `emojis.json`.
Emojis are already defined by default but you can modify them if you wish.
```js
{
"music": ":musical_note:",
"queue": ":bar_chart:",
"error": ":x:",
"success": ":white_check_mark:"
}
```
In the console, type `npm install` to install all dependencies. In the console, type `npm install` to install all dependencies.
To start the bot : - To start the bot :
``` ```
#With Node #With Node
@@ -55,11 +55,12 @@ All you have to do is turn on your bot !
### 🎵 Music commands ### 🎵 Music commands
``` ```
play <name>, play music in a voice channel. play <name/URL>, play music in a voice channel.
search <name>, open a panel to choose a music and then play it.
pause, pause the current music. pause, pause the current music.
resume, puts the current music back on. resume, puts the current music back on.
queue, see the next songs. queue, see the next songs.
clear-queue, delete the next music. clear-queue, remove music in the queue.
shuffle, to mix the queue. shuffle, to mix the queue.
nowplaying, see music in progress. nowplaying, see music in progress.
loop, to enable or disable the repeat function. loop, to enable or disable the repeat function.
@@ -82,4 +83,4 @@ debug, see number of voice connections.
Find all the functions available on the official code [right here](https://github.com/Androz2091/discord-player). Find all the functions available on the official code [right here](https://github.com/Androz2091/discord-player).
This is used with [discord.js](https://www.npmjs.com/package/discord.js) and [discord-player](https://www.npmjs.com/package/discord-player). This is used with [discord.js](https://www.npmjs.com/package/discord.js) and [discord-player](https://www.npmjs.com/package/discord-player).

View File

@@ -6,8 +6,8 @@ module.exports = {
execute(client, message, args) { execute(client, message, args) {
if (!args[0]) { if (!args[0]) {
const infos = message.client.commands.filter(c => c.category == 'Infos').map((c) => '`' + c.name + '`').join(', '); const infos = message.client.commands.filter(x => x.category == 'Infos').map((x) => '`' + x.name + '`').join(', ');
const music = message.client.commands.filter(c => c.category == 'Music').map((c) => '`' + c.name + '`').join(', '); const music = message.client.commands.filter(x => x.category == 'Music').map((x) => '`' + x.name + '`').join(', ');
message.channel.send({ message.channel.send({
embed: { embed: {
@@ -17,14 +17,14 @@ module.exports = {
fields: [ fields: [
{ name: 'Bot', value: infos }, { name: 'Bot', value: infos },
{ name: 'Music', value: music }, { name: 'Music', value: music },
{ name: 'Filters', value: '`bassboost`, `8D`, `vaporwave`, `nightcore`, `phaser`, `tremolo`, `vibrato`, `reverse`, `treble`, `normalizer`, `surrounding`, `pulsator`, `subboost`, `karaoke`, `flanger`, `gate`, `haas`, `mcompand`' }, { name: 'Filters', value: client.filters.map((x) => '`' + x + '`').join(', ') },
], ],
timestamp: new Date(), timestamp: new Date(),
description: `To use filters, ${client.config.prefix}filter (the filter). Example : ${client.config.prefix}filter 8D.`, description: `To use filters, ${client.config.discord.prefix}filter (the filter). Example : ${client.config.discord.prefix}filter 8D.`,
}, },
}); });
} else { } else {
const command = message.client.commands.get(args.join(" ").toLowerCase()) || message.client.commands.find(c => c.aliases && c.aliases.includes(args.join(" ").toLowerCase())); const command = message.client.commands.get(args.join(" ").toLowerCase()) || message.client.commands.find(x => x.aliases && x.aliases.includes(args.join(" ").toLowerCase()));
if (!command) return message.channel.send(`${client.emotes.error} - I did not find this command !`); if (!command) return message.channel.send(`${client.emotes.error} - I did not find this command !`);
@@ -36,8 +36,8 @@ module.exports = {
fields: [ fields: [
{ name: 'Name', value: command.name, inline: true }, { name: 'Name', value: command.name, inline: true },
{ name: 'Category', value: command.category, inline: true }, { name: 'Category', value: command.category, inline: true },
{ name: 'Aliase(s)', value: command.aliases.length < 1 ? 'None' : command.aliases.join('\n'), inline: true }, { name: 'Aliase(s)', value: command.aliases.length < 1 ? 'None' : command.aliases.join(', '), inline: true },
{ name: 'Utilisation', value: command.utilisation.replace('{prefix}', client.config.prefix), inline: true }, { name: 'Utilisation', value: command.utilisation.replace('{prefix}', client.config.discord.prefix), inline: true },
], ],
timestamp: new Date(), timestamp: new Date(),
description: 'Find information on the command provided.\nMandatory arguments `[]`, optional arguments `<>`.', description: 'Find information on the command provided.\nMandatory arguments `[]`, optional arguments `<>`.',

View File

@@ -5,6 +5,6 @@ module.exports = {
utilisation: '{prefix}debug', utilisation: '{prefix}debug',
execute(client, message) { execute(client, message) {
message.channel.send(`${client.emotes.success} - Robot connected in **${client.voice.connections.size}** channels !`); message.channel.send(`${client.emotes.success} - ${client.user.username} connected in **${client.voice.connections.size}** channels !`);
}, },
}; };

View File

@@ -7,8 +7,12 @@ module.exports = {
execute(client, message) { execute(client, message) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`); if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`); if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
if (client.player.getQueue(message).tracks.length <= 1) return message.channel.send(`${client.emotes.error} - There is only one song in the queue.`);
client.player.clearQueue(message); client.player.clearQueue(message);
message.channel.send(`${client.emotes.success} - The queue has just been **removed** !`); message.channel.send(`${client.emotes.success} - The queue has just been **removed** !`);

View File

@@ -7,22 +7,23 @@ module.exports = {
execute(client, message, args) { execute(client, message, args) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`); if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`); if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
if (!args[0]) return message.channel.send(`${client.emotes.error} - Please specify a valid filter to enable or disable !`); if (!args[0]) return message.channel.send(`${client.emotes.error} - Please specify a valid filter to enable or disable !`);
const filterToUpdate = Object.values(client.filters).find((f) => f.toLowerCase() === args[0].toLowerCase()); const filterToUpdate = client.filters.find((x) => x.toLowerCase() === args[0].toLowerCase());
if (!filterToUpdate) return message.channel.send(`${client.emotes.error} - This filter doesn't exist !`); if (!filterToUpdate) return message.channel.send(`${client.emotes.error} - This filter doesn't exist, try for example (8D, vibrato, pulsator...) !`);
const filterRealName = Object.keys(client.filters).find((f) => client.filters[f] === filterToUpdate);
const queueFilters = client.player.getQueue(message).filters;
const filtersUpdated = {}; const filtersUpdated = {};
filtersUpdated[filterRealName] = queueFilters[filterRealName] ? false : true;
filtersUpdated[filterToUpdate] = client.player.getQueue(message).filters[filterToUpdate] ? false : true;
client.player.setFilters(message, filtersUpdated); client.player.setFilters(message, filtersUpdated);
if (filtersUpdated[filterRealName]) message.channel.send(`${client.emotes.music} - I'm **adding** the filter to the music, please wait... Note : the longer the music is, the longer this will take.`); if (filtersUpdated[filterToUpdate]) message.channel.send(`${client.emotes.music} - I'm **adding** the filter to the music, please wait... Note : the longer the music is, the longer this will take.`);
else message.channel.send(`${client.emotes.music} - I'm **disabling** the filter on the music, please wait... Note : the longer the music is playing, the longer this will take.`); else message.channel.send(`${client.emotes.music} - I'm **disabling** the filter on the music, please wait... Note : the longer the music is playing, the longer this will take.`);
}, },
}; };

View File

@@ -1,20 +1,32 @@
module.exports = { module.exports = {
name: 'loop', name: 'loop',
aliases: ['lp'], aliases: ['lp', 'repeat'],
category: 'Music', category: 'Music',
utilisation: '{prefix}loop', utilisation: '{prefix}loop',
execute(client, message) { execute(client, message, args) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`); if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`); if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
if (client.player.getQueue(message).repeatMode) { if (args.join(" ").toLowerCase() === 'queue') {
client.player.setRepeatMode(message, false); if (client.player.getQueue(message).loopMode) {
return message.channel.send(`${client.emotes.success} - Repeat mode **disabled** !`); client.player.setLoopMode(message, false);
return message.channel.send(`${client.emotes.success} - Repeat mode **disabled** !`);
} else {
client.player.setLoopMode(message, true);
return message.channel.send(`${client.emotes.success} - Repeat mode **enabled** the whole queue will be repeated endlessly !`);
};
} else { } else {
client.player.setRepeatMode(message, true); if (client.player.getQueue(message).repeatMode) {
return message.channel.send(`${client.emotes.success} - Repeat mode **enabled** !`); client.player.setRepeatMode(message, false);
return message.channel.send(`${client.emotes.success} - Repeat mode **disabled** !`);
} else {
client.player.setRepeatMode(message, true);
return message.channel.send(`${client.emotes.success} - Repeat mode **enabled** the current music will be repeated endlessly !`);
};
}; };
}, },
}; };

View File

@@ -7,14 +7,14 @@ module.exports = {
execute(client, message) { execute(client, message) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`); if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`); if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
const track = client.player.nowPlaying(message); const track = client.player.nowPlaying(message);
const filters = []; const filters = [];
Object.keys(client.player.getQueue(message).filters).forEach((filterName) => { Object.keys(client.player.getQueue(message).filters).forEach((filterName) => client.player.getQueue(message).filters[filterName]) ? filters.push(filterName) : false;
if (client.player.getQueue(message).filters[filterName]) filters.push(filterName);
});
message.channel.send({ message.channel.send({
embed: { embed: {
@@ -28,7 +28,7 @@ module.exports = {
{ name: 'Views', value: track.views, inline: true }, { name: 'Views', value: track.views, inline: true },
{ name: 'Duration', value: track.duration, inline: true }, { name: 'Duration', value: track.duration, inline: true },
{ name: 'Filters activated', value: filters.length, inline: true }, { name: 'Filters activated', value: filters.length + '/' + client.filters.length, inline: true },
{ name: 'Volume', value: client.player.getQueue(message).volume, inline: true }, { name: 'Volume', value: client.player.getQueue(message).volume, inline: true },
{ name: 'Repeat mode', value: client.player.getQueue(message).repeatMode ? 'Yes' : 'No', inline: true }, { name: 'Repeat mode', value: client.player.getQueue(message).repeatMode ? 'Yes' : 'No', inline: true },

View File

@@ -7,12 +7,14 @@ module.exports = {
execute(client, message) { execute(client, message) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`); if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`); if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
if (client.player.getQueue(message).paused) return message.channel.send(`${client.emotes.error} - The music is already paused !`); if (client.player.getQueue(message).paused) return message.channel.send(`${client.emotes.error} - The music is already paused !`);
client.player.pause(message); client.player.pause(message);
message.channel.send(`${client.emotes.success} - Song ${client.player.getQueue(message).playing.title} **paused** !`); message.channel.send(`${client.emotes.success} - Song ${client.player.getQueue(message).playing.title} paused !`);
}, },
}; };

View File

@@ -7,8 +7,10 @@ module.exports = {
execute(client, message, args) { execute(client, message, args) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`); if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
if (!args[0]) return message.channel.send(`${client.emotes.error} - Please indicate the title of a song !`); if (!args[0]) return message.channel.send(`${client.emotes.error} - Please indicate the title of a song !`);
client.player.play(message, args.join(" ")); client.player.play(message, args.join(" "), { firstResult: true });
}, },
}; };

View File

@@ -7,11 +7,13 @@ module.exports = {
execute(client, message) { execute(client, message) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`); if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
const queue = client.player.getQueue(message); const queue = client.player.getQueue(message);
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No songs currently playing !`); if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No songs currently playing !`);
message.channel.send(`**Server queue - ${message.guild.name} ${client.emotes.queue}**\nCurrent : ${queue.playing.title} | ${queue.playing.author}\n\n` + (queue.tracks.map((track, i) => { message.channel.send(`**Server queue - ${message.guild.name} ${client.emotes.queue} ${client.player.getQueue(message).loopMode ? '(looped)' : ''}**\nCurrent : ${queue.playing.title} | ${queue.playing.author}\n\n` + (queue.tracks.map((track, i) => {
return `**#${i + 1}** - ${track.title} | ${track.author} (requested by : ${track.requestedBy.username})` return `**#${i + 1}** - ${track.title} | ${track.author} (requested by : ${track.requestedBy.username})`
}).slice(0, 5).join('\n') + `\n\n${queue.tracks.length > 5 ? `And **${queue.tracks.length - 5}** other songs...` : `In the playlist **${queue.tracks.length}** song(s)...`}`)); }).slice(0, 5).join('\n') + `\n\n${queue.tracks.length > 5 ? `And **${queue.tracks.length - 5}** other songs...` : `In the playlist **${queue.tracks.length}** song(s)...`}`));
}, },

View File

@@ -7,12 +7,14 @@ module.exports = {
execute(client, message) { execute(client, message) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`); if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`); if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
if (!client.player.getQueue(message).paused) return message.channel.send(`${client.emotes.error} - The music is already playing !`); if (!client.player.getQueue(message).paused) return message.channel.send(`${client.emotes.error} - The music is already playing !`);
client.player.resume(message); client.player.resume(message);
message.channel.send(`${client.emotes.success} - Song ${client.player.getQueue(message).playing.title} **resumed** !`); message.channel.send(`${client.emotes.success} - Song ${client.player.getQueue(message).playing.title} resumed !`);
}, },
}; };

16
commands/music/search.js Normal file
View File

@@ -0,0 +1,16 @@
module.exports = {
name: 'search',
aliases: ['sr'],
category: 'Music',
utilisation: '{prefix}search [name/URL]',
execute(client, message, args) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
if (!args[0]) return message.channel.send(`${client.emotes.error} - Please indicate the title of a song !`);
client.player.play(message, args.join(" "));
},
};

View File

@@ -7,6 +7,8 @@ module.exports = {
execute(client, message) { execute(client, message) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`); if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`); if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
client.player.shuffle(message); client.player.shuffle(message);

View File

@@ -7,6 +7,8 @@ module.exports = {
execute(client, message) { execute(client, message) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`); if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`); if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
client.player.skip(message); client.player.skip(message);

View File

@@ -1,12 +1,14 @@
module.exports = { module.exports = {
name: 'stop', name: 'stop',
aliases: [], aliases: ['dc'],
category: 'Music', category: 'Music',
utilisation: '{prefix}stop', utilisation: '{prefix}stop',
execute(client, message) { execute(client, message) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`); if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`); if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
client.player.setRepeatMode(message, false); client.player.setRepeatMode(message, false);

View File

@@ -7,13 +7,15 @@ module.exports = {
execute(client, message, args) { execute(client, message, args) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`); if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`); if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
if (!args[0] || isNaN(args[0])) return message.channel.send(`${client.emotes.error} - Please enter a valid number !`); if (!args[0] || isNaN(args[0]) || args[0] === 'Infinity') return message.channel.send(`${client.emotes.error} - Please enter a valid number !`);
if (Math.round(parseInt(args[0])) < 1 || Math.round(parseInt(args[0])) > 100) return message.channel.send(`${client.emotes.error} - Please enter a valid number (between 1 and 100) !`); if (Math.round(parseInt(args[0])) < 1 || Math.round(parseInt(args[0])) > 100) return message.channel.send(`${client.emotes.error} - Please enter a valid number (between 1 and 100) !`);
client.player.setVolume(message, args[0]); client.player.setVolume(message, parseInt(args[0]));
message.channel.send(`${client.emotes.success} - Volume set to **${parseInt(args[0])}%** !`); message.channel.send(`${client.emotes.success} - Volume set to **${parseInt(args[0])}%** !`);
}, },

View File

@@ -7,16 +7,15 @@ module.exports = {
execute(client, message) { execute(client, message) {
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`); if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`); if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
const disabledEmoji = client.emotes.error; if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
const enabledEmoji = client.emotes.success;
const filtersStatuses = [[], []]; const filtersStatuses = [[], []];
Object.keys(client.filters).forEach((filterName) => { client.filters.forEach((filterName) => {
const array = filtersStatuses[0].length > filtersStatuses[1].length ? filtersStatuses[1] : filtersStatuses[0]; const array = filtersStatuses[0].length > filtersStatuses[1].length ? filtersStatuses[1] : filtersStatuses[0];
array.push(client.filters[filterName] + " : " + (client.player.getQueue(message).filters[filterName] ? enabledEmoji : disabledEmoji)); array.push(filterName.charAt(0).toUpperCase() + filterName.slice(1) + " : " + (client.player.getQueue(message).filters[filterName] ? client.emotes.success : client.emotes.off));
}); });
message.channel.send({ message.channel.send({
@@ -28,7 +27,7 @@ module.exports = {
{ name: '** **', value: filtersStatuses[1].join('\n'), inline: true }, { name: '** **', value: filtersStatuses[1].join('\n'), inline: true },
], ],
timestamp: new Date(), timestamp: new Date(),
description: `List of all filters enabled or disabled.\nUse \`${client.config.prefix}filter\` to add a filter to a song.`, description: `List of all filters enabled or disabled.\nUse \`${client.config.discord.prefix}filter\` to add a filter to a song.`,
}, },
}); });
}, },

17
config/bot.js Normal file
View File

@@ -0,0 +1,17 @@
module.exports = {
emojis: {
off: ':x:',
error: ':warning:',
queue: ':bar_chart:',
music: ':musical_note:',
success: ':white_check_mark:',
},
discord: {
token: 'TOKEN',
prefix: 'PREFIX',
activity: 'ACTIVITY',
},
filters: ['8D', 'gate', 'haas', 'phaser', 'treble', 'tremolo', 'vibrato', 'reverse', 'karaoke', 'flanger', 'mcompand', 'pulsator', 'subboost', 'bassboost', 'vaporwave', 'nightcore', 'normalizer', 'surrounding'],
};

View File

@@ -1,5 +0,0 @@
{
"game": "GAME",
"prefix": "PREFIX",
"token_bot": "TOKEN"
}

View File

@@ -1,6 +0,0 @@
{
"music": ":musical_note:",
"queue": ":bar_chart:",
"error": ":x:",
"success": ":white_check_mark:"
}

View File

@@ -1,20 +0,0 @@
{
"bassboost": "Bassboost",
"8D": "8D",
"vaporwave": "Vaporwave",
"nightcore": "Nightcore",
"phaser": "Phaser",
"tremolo": "Tremolo",
"vibrato": "Vibrato",
"reverse": "Reverse",
"treble": "Treble",
"normalizer": "Normalizer",
"surrounding": "Surrounding",
"pulsator": "Pulsator",
"subboost": "Subboost",
"karaoke": "Karaoke",
"flanger": "Flanger",
"gate": "Gate",
"haas": "Haas",
"mcompand": "Mcompand"
}

View File

@@ -1,8 +1,7 @@
module.exports = (client, message) => { module.exports = (client, message) => {
if (message.author.bot || message.channel.type === 'dm') return;
if (message.author.bot) return; const prefix = client.config.discord.prefix;
const prefix = client.config.prefix;
if (message.content.indexOf(prefix) !== 0) return; if (message.content.indexOf(prefix) !== 0) return;
@@ -12,5 +11,4 @@ module.exports = (client, message) => {
const cmd = client.commands.get(command) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(command)); const cmd = client.commands.get(command) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(command));
if (cmd) cmd.execute(client, message, args); if (cmd) cmd.execute(client, message, args);
}; };

View File

@@ -1,7 +1,5 @@
module.exports = async (client) => { module.exports = async (client) => {
console.log(`Ready on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users`); console.log(`Ready on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users`);
client.user.setActivity(client.config.game); client.user.setActivity(client.config.discord.activity);
}; };

View File

@@ -6,32 +6,20 @@ const client = new discord.Client({ disableMentions: 'everyone' });
const { Player } = require('discord-player'); const { Player } = require('discord-player');
client.player = new Player(client); client.player = new Player(client);
client.config = require('./config/bot.json'); client.config = require('./config/bot');
client.emotes = require('./config/emojis.json'); client.emotes = client.config.emojis;
client.filters = require('./config/filters.json'); client.filters = client.config.filters;
client.commands = new discord.Collection(); client.commands = new discord.Collection();
const core = fs.readdirSync('./commands/core').filter(file => file.endsWith('.js')); fs.readdirSync('./commands').forEach(dirs => {
const infos = fs.readdirSync('./commands/infos').filter(file => file.endsWith('.js')); const commands = fs.readdirSync(`./commands/${dirs}`).filter(files => files.endsWith('.js'));
const music = fs.readdirSync('./commands/music').filter(file => file.endsWith('.js'));
for (const file of core) { for (const file of commands) {
console.log(`Loading command ${file}`); const command = require(`./commands/${dirs}/${file}`);
const command = require(`./commands/core/${file}`); console.log(`Loading command ${file}`);
client.commands.set(command.name.toLowerCase(), command); client.commands.set(command.name.toLowerCase(), command);
}; };
});
for (const file of infos) {
console.log(`Loading command ${file}`);
const command = require(`./commands/infos/${file}`);
client.commands.set(command.name.toLowerCase(), command);
};
for (const file of music) {
console.log(`Loading command ${file}`);
const command = require(`./commands/music/${file}`);
client.commands.set(command.name.toLowerCase(), command);
};
const events = fs.readdirSync('./events').filter(file => file.endsWith('.js')); const events = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
const player = fs.readdirSync('./player').filter(file => file.endsWith('.js')); const player = fs.readdirSync('./player').filter(file => file.endsWith('.js'));
@@ -48,4 +36,4 @@ for (const file of player) {
client.player.on(file.split(".")[0], event.bind(null, client)); client.player.on(file.split(".")[0], event.bind(null, client));
}; };
client.login(client.config.token_bot); client.login(client.config.discord.token);

View File

@@ -1,17 +1,18 @@
{ {
"name": "music-bot", "name": "music-bot",
"version": "3.0.0",
"main": "index.js", "main": "index.js",
"repository": "https://github.com/ZerioDev/Music-bot.git",
"author": "ZerioDev", "author": "ZerioDev",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"start": "node index.js", "start": "node index.js",
}, },
"version": "5.0.0",
"repository": "https://github.com/ZerioDev/Music-bot.git",
"description": "A complete code to download for a music bot. Using a module (discord-player).",
"dependencies": { "dependencies": {
"@discordjs/opus": "^0.3.2", "@discordjs/opus": "^0.3.3",
"discord-player": "^3.0.2", "discord-player": "^3.2.0",
"discord.js": "^12.2.0", "discord.js": "^12.5.1",
"ffmpeg-static": "^4.2.7" "ffmpeg-static": "^4.2.7"
} }
} }

View File

@@ -1,3 +1,3 @@
module.exports = (client, message, playlist) => { module.exports = (client, message, queue, playlist) => {
message.channel.send(`${client.emotes.music} - ${playlist.title} has been added to the queue (**${playlist.items.length}** songs) !`); message.channel.send(`${client.emotes.music} - ${playlist.title} has been added to the queue (**${playlist.tracks.length}** songs) !`);
}; };

View File

@@ -1,3 +1,6 @@
module.exports = (client, message, query, tracks, content, collector) => { module.exports = (client, message, query, tracks, content, collector) => {
message.channel.send(`${client.emotes.error} - You must send a valid number between **1** and **${tracks.length}** !`); if (content === 'cancel') {
collector.stop();
return message.channel.send(`${client.emotes.success} - The selection has been **cancelled** !`);
} else message.channel.send(`${client.emotes.error} - You must send a valid number between **1** and **${tracks.length}** !`);
}; };