✨ Update (v6.0.0)
This commit is contained in:
4
LICENSE
4
LICENSE
@@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
|
|||||||
the "copyright" line and a pointer to where the full notice is found.
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
A complete code to download for a Discord music bot. Using a module (discord-player).
|
A complete code to download for a Discord music bot. Using a module (discord-player).
|
||||||
Copyright (C) 2020 ZerioDev
|
Copyright (C) 2020-2021 ZerioDev
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
|
|||||||
If the program does terminal interaction, make it output a short
|
If the program does terminal interaction, make it output a short
|
||||||
notice like this when it starts in an interactive mode:
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
Music-bot Copyright (C) 2020 ZerioDev
|
Music-bot Copyright (C) 2020-2021 ZerioDev
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it
|
This is free software, and you are welcome to redistribute it
|
||||||
under certain conditions; type `show c' for details.
|
under certain conditions; type `show c' for details.
|
||||||
|
|||||||
103
README.md
103
README.md
@@ -1,91 +1,66 @@
|
|||||||
# Music-bot
|
# Music-bot
|
||||||
|
|
||||||
## Migrating to v5...
|
A complete code to download for a music bot 🎧
|
||||||
|
|
||||||
Music-Bot has not been migrated to Discord Player v5 yet! It's on the way, feel free to add a star to this repository to show your support. In the meantime, you should use **[discord-music-bot](https://github.com/Androz2091/discord-music-bot)**. Please do not spam issues here as it should have probably been resolved in the new repo. Thanks.
|
|
||||||
|
|
||||||
A complete code to download for a music bot. Using a module (discord-player) 🎧
|
|
||||||
|
|
||||||
Looking for a code for a music bot ? This fully open source code is made for your project !
|
Looking for a code for a music bot ? This fully open source code is made for your project !
|
||||||
|
|
||||||
If you need help with this project, to get support faster you can join the help server by just clicking [here](https://discord.gg/5cGSYV8ZZj).
|
If you need help with this project, to get support faster you can join the help server by just clicking [here](https://discord.gg/5cGSYV8ZZj).
|
||||||
|
|
||||||
### ⚡ Installation
|
*If you don't have any development knowledge, it is recommended to join the Discord support server to get help.*
|
||||||
|
|
||||||
Well, let's start by downloading the code.
|
### ⚡ Configuration
|
||||||
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 emojis
|
Open the configuration file located in the main folder `config.js`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
emojis: {
|
module.exports = {
|
||||||
off: ':x:',
|
app: {
|
||||||
error: ':warning:',
|
px: 'XXX',
|
||||||
queue: ':bar_chart:',
|
token: 'XXX',
|
||||||
music: ':musical_note:',
|
playing: 'by Zerio ❤️',
|
||||||
success: ':white_check_mark:',
|
},
|
||||||
|
|
||||||
|
opt: {
|
||||||
|
DJ: {
|
||||||
|
enabled: false,
|
||||||
|
roleName: 'XXX',
|
||||||
|
commands: []
|
||||||
|
},
|
||||||
|
maxVol: 100,
|
||||||
|
discordPlayer: {}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
- For configuration
|
Basic configuration
|
||||||
|
|
||||||
```js
|
- `app/px`, the prefix that will be set to use the bot
|
||||||
discord: {
|
- `app/token`, the token of the bot available on the [Discord Developers](https://discordapp.com/developers/applications) section
|
||||||
token: 'TOKEN',
|
- `app/playing`, the activity of the bot
|
||||||
prefix: 'PREFIX',
|
|
||||||
activity: 'ACTIVITY',
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
- `token`, the token of the bot available on the [Discord Developers](https://discordapp.com/developers/applications) section.
|
DJ mode configuration
|
||||||
- `prefix`, the prefix that will be set to use the bot.
|
|
||||||
- `activity`, the activity of the bot.
|
|
||||||
|
|
||||||
In the console, type `npm install` to install all dependencies.
|
- `opt/DJ/enabled`, whether the DJ mode should be activated or not
|
||||||
|
- `opt/DJ/roleName`, the name of the DJ role to be used
|
||||||
|
- `opt/DJ/commands`, the list of commands limited to members with the DJ role
|
||||||
|
|
||||||
- To start the bot :
|
Advanced configuration
|
||||||
|
|
||||||
```
|
- `opt/maxVol`, the maximum volume that users can define
|
||||||
#With Node
|
- `opt/discordPlayer`, options used by discord-player
|
||||||
node index.js
|
|
||||||
npm start #Indicated in package.json
|
|
||||||
|
|
||||||
#With pm2
|
### 📑 Installation
|
||||||
pm2 start index.js --name "MusicBot"
|
|
||||||
```
|
|
||||||
|
|
||||||
All you have to do is turn on your bot !
|
To use the project correctly you will need some tools.
|
||||||
|
|
||||||
### 🎵 Music commands
|
[FFmpeg](https://www.ffmpeg.org) to process audio
|
||||||
|
|
||||||
```
|
[Node JS](https://nodejs.org/en/) (v16) for environment
|
||||||
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.
|
|
||||||
resume, puts the current music back on.
|
|
||||||
queue, see the next songs.
|
|
||||||
clear-queue, remove music in the queue.
|
|
||||||
shuffle, to mix the queue.
|
|
||||||
nowplaying, see music in progress.
|
|
||||||
loop, to enable or disable the repeat function.
|
|
||||||
volume <1 - 100>, change the volume.
|
|
||||||
skip, skip to next music.
|
|
||||||
stop, stop all music.
|
|
||||||
filter <filter>, add / remove filter.
|
|
||||||
w-filters, see filters.
|
|
||||||
```
|
|
||||||
|
|
||||||
### 💡 General commands
|
Without forgetting of course the code editor ^^
|
||||||
|
|
||||||
```
|
Realized with ❤️ by [ZerioDev](https://github.com/ZerioDev).
|
||||||
ping, see the bot latency.
|
|
||||||
help, see the list of available commands.
|
|
||||||
debug, see number of voice connections.
|
|
||||||
```
|
|
||||||
|
|
||||||
### 🏓 Utilities (to change the code)
|
Please do not withdraw the license and keep the credits on this project.
|
||||||
|
|
||||||
Find all the functions available on the official code [right here](https://github.com/Androz2091/discord-player).
|
To have full access to the project and to be able to withdraw the credits a small donation is accepted.
|
||||||
|
|
||||||
This is used with [discord.js](https://www.npmjs.com/package/discord.js) and [discord-player](https://www.npmjs.com/package/discord-player).
|
|
||||||
@@ -1,48 +1,25 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'help',
|
name: 'help',
|
||||||
aliases: ['h'],
|
aliases: ['h'],
|
||||||
category: 'Core',
|
showHelp: false,
|
||||||
utilisation: '{prefix}help <command name>',
|
utilisation: '{prefix}help',
|
||||||
|
|
||||||
execute(client, message, args) {
|
execute(client, message, args) {
|
||||||
if (!args[0]) {
|
const embed = new MessageEmbed();
|
||||||
const infos = message.client.commands.filter(x => x.category == 'Infos').map((x) => '`' + x.name + '`').join(', ');
|
|
||||||
const music = message.client.commands.filter(x => x.category == 'Music').map((x) => '`' + x.name + '`').join(', ');
|
|
||||||
|
|
||||||
message.channel.send({
|
embed.setColor('RED');
|
||||||
embed: {
|
embed.setAuthor(client.user.username, client.user.displayAvatarURL({ size: 1024, dynamic: true }));
|
||||||
color: 'ORANGE',
|
|
||||||
author: { name: 'Help pannel' },
|
|
||||||
footer: { text: 'This bot uses a Github project made by Zerio (ZerioDev/Music-bot)' },
|
|
||||||
fields: [
|
|
||||||
{ name: 'Bot', value: infos },
|
|
||||||
{ name: 'Music', value: music },
|
|
||||||
{ name: 'Filters', value: client.filters.map((x) => '`' + x + '`').join(', ') },
|
|
||||||
],
|
|
||||||
timestamp: new Date(),
|
|
||||||
description: `To use filters, ${client.config.discord.prefix}filter (the filter). Example : ${client.config.discord.prefix}filter 8D.`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
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 !`);
|
const commands = client.commands.filter(x => x.showHelp !== false);
|
||||||
|
|
||||||
message.channel.send({
|
embed.setDescription('This code comes from a GitHub project (ZerioDev/Music-bot).\nThe use of this one is possible while keeping the credits for free.\nIf you want to remove the credits join the Discord support server.');
|
||||||
embed: {
|
embed.addField(`Enabled - ${commands.size}`, commands.map(x => `\`${x.name}${x.aliases[0] ? ` (${x.aliases.map(y => y).join(', ')})\`` : '\`'}`).join(' | '));
|
||||||
color: 'ORANGE',
|
|
||||||
author: { name: 'Help pannel' },
|
embed.setTimestamp();
|
||||||
footer: { text: 'This bot uses a Github project made by Zerio (ZerioDev/Music-bot)' },
|
embed.setFooter('Music comes first - Made with heart by Zerio ❤️', message.author.avatarURL({ dynamic: true }));
|
||||||
fields: [
|
|
||||||
{ name: 'Name', value: command.name, inline: true },
|
message.channel.send({ embeds: [embed] });
|
||||||
{ name: 'Category', value: command.category, 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.discord.prefix), inline: true },
|
|
||||||
],
|
|
||||||
timestamp: new Date(),
|
|
||||||
description: 'Find information on the command provided.\nMandatory arguments `[]`, optional arguments `<>`.',
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
11
commands/core/ping.js
Normal file
11
commands/core/ping.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
const ms = require('ms');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'ping',
|
||||||
|
aliases: [],
|
||||||
|
utilisation: '{prefix}ping',
|
||||||
|
|
||||||
|
execute(client, message) {
|
||||||
|
message.channel.send(`Last heartbeat calculated ${ms(Date.now() - client.ws.shards.first().lastPingTimestamp, { long: true })} ago **${client.ws.ping}ms** 🛰️`);
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
name: 'debug',
|
|
||||||
aliases: [],
|
|
||||||
category: 'Infos',
|
|
||||||
utilisation: '{prefix}debug',
|
|
||||||
|
|
||||||
execute(client, message) {
|
|
||||||
message.channel.send(`${client.emotes.success} - ${client.user.username} connected in **${client.voice.connections.size}** channels !`);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
name: 'ping',
|
|
||||||
aliases: [],
|
|
||||||
category: 'Infos',
|
|
||||||
utilisation: '{prefix}ping',
|
|
||||||
|
|
||||||
execute(client, message) {
|
|
||||||
message.channel.send(`${client.emotes.success} - Ping : **${client.ws.ping}ms** !`);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
18
commands/music/back.js
Normal file
18
commands/music/back.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: 'back',
|
||||||
|
aliases: ['previous'],
|
||||||
|
utilisation: '{prefix}back',
|
||||||
|
voiceChannel: true,
|
||||||
|
|
||||||
|
async execute(client, message) {
|
||||||
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
|
if (!queue || !queue.playing) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
|
if (!queue.previousTracks[1]) return message.channel.send(`There was no music played before ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
|
await queue.back();
|
||||||
|
|
||||||
|
message.channel.send(`Playing the **previous** track ✅`);
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
name: 'clear-queue',
|
|
||||||
aliases: ['cq'],
|
|
||||||
category: 'Music',
|
|
||||||
utilisation: '{prefix}clear-queue',
|
|
||||||
|
|
||||||
execute(client, message) {
|
|
||||||
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).tracks.length <= 1) return message.channel.send(`${client.emotes.error} - There is only one song in the queue.`);
|
|
||||||
|
|
||||||
client.player.clearQueue(message);
|
|
||||||
|
|
||||||
message.channel.send(`${client.emotes.success} - The queue has just been **removed** !`);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
18
commands/music/clear.js
Normal file
18
commands/music/clear.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: 'clear',
|
||||||
|
aliases: ['cq'],
|
||||||
|
utilisation: '{prefix}clear',
|
||||||
|
voiceChannel: true,
|
||||||
|
|
||||||
|
async execute(client, message) {
|
||||||
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
|
if (!queue || !queue.playing) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
|
if (!queue.tracks[0]) return message.channel.send(`No music in the queue after the current one ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
|
await queue.clear();
|
||||||
|
|
||||||
|
message.channel.send(`The queue has just been cleared 🗑️`);
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,29 +1,33 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'filter',
|
name: 'filter',
|
||||||
aliases: [],
|
aliases: [],
|
||||||
category: 'Music',
|
|
||||||
utilisation: '{prefix}filter [filter name]',
|
utilisation: '{prefix}filter [filter name]',
|
||||||
|
voiceChannel: true,
|
||||||
|
|
||||||
execute(client, message, args) {
|
async execute(client, message, args) {
|
||||||
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
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 (!queue || !queue.playing) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
|
const actualFilter = queue.getFiltersEnabled()[0];
|
||||||
|
|
||||||
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(`Please specify a valid filter to enable or disable ${message.author}... try again ? ❌\n${actualFilter ? `Filter currently active ${actualFilter} (${client.config.app.px}filter ${actualFilter} to disable it).\n` : ''}`);
|
||||||
|
|
||||||
const filterToUpdate = client.filters.find((x) => x.toLowerCase() === args[0].toLowerCase());
|
const filters = [];
|
||||||
|
|
||||||
if (!filterToUpdate) return message.channel.send(`${client.emotes.error} - This filter doesn't exist, try for example (8D, vibrato, pulsator...) !`);
|
queue.getFiltersEnabled().map(x => filters.push(x));
|
||||||
|
queue.getFiltersDisabled().map(x => filters.push(x));
|
||||||
|
|
||||||
|
const filter = filters.find((x) => x.toLowerCase() === args[0].toLowerCase());
|
||||||
|
|
||||||
|
if (!filter) return message.channel.send(`This filter doesn't exist ${message.author}... try again ? ❌\n${actualFilter ? `Filter currently active ${actualFilter}.\n` : ''}List of available filters ${filters.map(x => `**${x}**`).join(', ')}.`);
|
||||||
|
|
||||||
const filtersUpdated = {};
|
const filtersUpdated = {};
|
||||||
|
|
||||||
filtersUpdated[filterToUpdate] = client.player.getQueue(message).filters[filterToUpdate] ? false : true;
|
filtersUpdated[filter] = queue.getFiltersEnabled().includes(filter) ? false : true;
|
||||||
|
|
||||||
client.player.setFilters(message, filtersUpdated);
|
await queue.setFilters(filtersUpdated);
|
||||||
|
|
||||||
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.`);
|
message.channel.send(`The filter ${filter} is now **${queue.getFiltersEnabled().includes(filter) ? 'enabled' : 'disabled'}** ✅\n*Reminder 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.`);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1,32 +1,28 @@
|
|||||||
|
const { QueueRepeatMode } = require('discord-player');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'loop',
|
name: 'loop',
|
||||||
aliases: ['lp', 'repeat'],
|
aliases: ['lp', 'repeat'],
|
||||||
category: 'Music',
|
utilisation: '{prefix}loop <queue>',
|
||||||
utilisation: '{prefix}loop',
|
voiceChannel: true,
|
||||||
|
|
||||||
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 !`);
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
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 (!queue || !queue.playing) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
|
if (args.join('').toLowerCase() === 'queue') {
|
||||||
|
if (queue.repeatMode === 1) return message.channel.send(`You must first disable the current music in the loop mode (${client.config.app.px}loop) ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
if (args.join(" ").toLowerCase() === 'queue') {
|
const success = queue.setRepeatMode(queue.repeatMode === 0 ? QueueRepeatMode.QUEUE : QueueRepeatMode.OFF);
|
||||||
if (client.player.getQueue(message).loopMode) {
|
|
||||||
client.player.setLoopMode(message, false);
|
return message.channel.send(success ? `Repeat mode **${queue.repeatMode === 0 ? 'disabled' : 'enabled'}** the whole queue will be repeated endlessly 🔁` : `Something went wrong ${message.author}... try again ? ❌`);
|
||||||
return message.channel.send(`${client.emotes.success} - Repeat mode **disabled** !`);
|
|
||||||
} else {
|
} else {
|
||||||
client.player.setLoopMode(message, true);
|
if (queue.repeatMode === 2) return message.channel.send(`You must first disable the current queue in the loop mode (${client.config.app.px}loop queue) ${message.author}... try again ? ❌`);
|
||||||
return message.channel.send(`${client.emotes.success} - Repeat mode **enabled** the whole queue will be repeated endlessly !`);
|
|
||||||
};
|
const success = queue.setRepeatMode(queue.repeatMode === 0 ? QueueRepeatMode.TRACK : QueueRepeatMode.OFF);
|
||||||
} else {
|
|
||||||
if (client.player.getQueue(message).repeatMode) {
|
return message.channel.send(success ? `Repeat mode **${queue.repeatMode === 0 ? 'disabled' : 'enabled'}** the current music will be repeated endlessly (you can loop the queue with the <queue> option) 🔂` : `Something went wrong ${message.author}... try again ? ❌`);
|
||||||
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 !`);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1,44 +1,31 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'nowplaying',
|
name: 'nowplaying',
|
||||||
aliases: ['np'],
|
aliases: ['np'],
|
||||||
category: 'Music',
|
|
||||||
utilisation: '{prefix}nowplaying',
|
utilisation: '{prefix}nowplaying',
|
||||||
|
voiceChannel: true,
|
||||||
|
|
||||||
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 !`);
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
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 (!queue || !queue.playing) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
|
const track = queue.current;
|
||||||
|
|
||||||
const track = client.player.nowPlaying(message);
|
const embed = new MessageEmbed();
|
||||||
const filters = [];
|
|
||||||
|
|
||||||
Object.keys(client.player.getQueue(message).filters).forEach((filterName) => client.player.getQueue(message).filters[filterName]) ? filters.push(filterName) : false;
|
embed.setColor('RED');
|
||||||
|
embed.setThumbnail(track.thumbnail);
|
||||||
|
embed.setAuthor(track.title, client.user.displayAvatarURL({ size: 1024, dynamic: true }));
|
||||||
|
|
||||||
message.channel.send({
|
const methods = ['disabled', 'track', 'queue'];
|
||||||
embed: {
|
|
||||||
color: 'RED',
|
|
||||||
author: { name: track.title },
|
|
||||||
footer: { text: 'This bot uses a Github project made by Zerio (ZerioDev/Music-bot)' },
|
|
||||||
fields: [
|
|
||||||
{ name: 'Channel', value: track.author, inline: true },
|
|
||||||
{ name: 'Requested by', value: track.requestedBy.username, inline: true },
|
|
||||||
{ name: 'From playlist', value: track.fromPlaylist ? 'Yes' : 'No', inline: true },
|
|
||||||
|
|
||||||
{ name: 'Views', value: track.views, inline: true },
|
embed.setDescription(`Volume **${queue.volume}**%\nDuration **${track.duration}**\nLoop mode **${methods[queue.repeatMode]}**\nRequested by ${track.requestedBy}`);
|
||||||
{ name: 'Duration', value: track.duration, inline: true },
|
|
||||||
{ name: 'Filters activated', value: filters.length + '/' + client.filters.length, inline: true },
|
|
||||||
|
|
||||||
{ name: 'Volume', value: client.player.getQueue(message).volume, inline: true },
|
embed.setTimestamp();
|
||||||
{ name: 'Repeat mode', value: client.player.getQueue(message).repeatMode ? 'Yes' : 'No', inline: true },
|
embed.setFooter('Music comes first - Made with heart by Zerio ❤️', message.author.avatarURL({ dynamic: true }));
|
||||||
{ name: 'Currently paused', value: client.player.getQueue(message).paused ? 'Yes' : 'No', inline: true },
|
|
||||||
|
|
||||||
{ name: 'Progress bar', value: client.player.createProgressBar(message, { timecodes: true }), inline: true }
|
message.channel.send({ embeds: [embed] });
|
||||||
],
|
|
||||||
thumbnail: { url: track.thumbnail },
|
|
||||||
timestamp: new Date(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1,20 +1,16 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'pause',
|
name: 'pause',
|
||||||
aliases: [],
|
aliases: [],
|
||||||
category: 'Music',
|
|
||||||
utilisation: '{prefix}pause',
|
utilisation: '{prefix}pause',
|
||||||
|
voiceChannel: true,
|
||||||
|
|
||||||
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 !`);
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
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 (!queue) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
|
const success = queue.setPaused(true);
|
||||||
|
|
||||||
if (client.player.getQueue(message).paused) return message.channel.send(`${client.emotes.error} - The music is already paused !`);
|
return message.channel.send(success ? `Current music ${queue.current.title} paused ✅` : `Something went wrong ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
const success = client.player.pause(message);
|
|
||||||
|
|
||||||
if (success) message.channel.send(`${client.emotes.success} - Song ${client.player.getQueue(message).playing.title} paused !`);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1,16 +1,36 @@
|
|||||||
|
const { QueryType } = require('discord-player');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'play',
|
name: 'play',
|
||||||
aliases: ['p'],
|
aliases: ['p'],
|
||||||
category: 'Music',
|
utilisation: '{prefix}play [song name/URL]',
|
||||||
utilisation: '{prefix}play [name/URL]',
|
voiceChannel: true,
|
||||||
|
|
||||||
execute(client, message, args) {
|
async execute(client, message, args) {
|
||||||
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
|
if (!args[0]) return message.channel.send(`Please enter a valid search ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
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 res = await player.search(args.join(' '), {
|
||||||
|
requestedBy: message.member,
|
||||||
|
searchEngine: QueryType.AUTO
|
||||||
|
});
|
||||||
|
|
||||||
if (!args[0]) return message.channel.send(`${client.emotes.error} - Please indicate the title of a song !`);
|
if (!res || !res.tracks.length) return message.channel.send(`No results found ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
client.player.play(message, args.join(" "), { firstResult: true });
|
const queue = await player.createQueue(message.guild, {
|
||||||
|
metadata: message.channel
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!queue.connection) await queue.connect(message.member.voice.channel);
|
||||||
|
} catch {
|
||||||
|
await player.deleteQueue(message.guild.id);
|
||||||
|
return message.channel.send(`I can't join the voice channel ${message.author}... try again ? ❌`);
|
||||||
|
}
|
||||||
|
|
||||||
|
await message.channel.send(`Loading your ${res.playlist ? 'playlist' : 'track'}... 🎧`);
|
||||||
|
|
||||||
|
res.playlist ? queue.addTracks(res.tracks) : queue.addTrack(res.tracks[0]);
|
||||||
|
|
||||||
|
if (!queue.playing) await queue.play();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1,20 +1,35 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'queue',
|
name: 'queue',
|
||||||
aliases: [],
|
aliases: ['q'],
|
||||||
category: 'Music',
|
|
||||||
utilisation: '{prefix}queue',
|
utilisation: '{prefix}queue',
|
||||||
|
voiceChannel: true,
|
||||||
|
|
||||||
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 !`);
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
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 (!queue) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
const queue = client.player.getQueue(message);
|
if (!queue.tracks[0]) return message.channel.send(`No music in the queue after the current one ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No songs currently playing !`);
|
const embed = new MessageEmbed();
|
||||||
|
const methods = ['', '🔁', '🔂'];
|
||||||
|
|
||||||
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) => {
|
embed.setColor('RED');
|
||||||
return `**#${i + 1}** - ${track.title} | ${track.author} (requested by : ${track.requestedBy.username})`
|
embed.setThumbnail(message.guild.iconURL({ size: 2048, dynamic: true }));
|
||||||
}).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)...`}`));
|
embed.setAuthor(`Server queue - ${message.guild.name} ${methods[queue.repeatMode]}`, client.user.displayAvatarURL({ size: 1024, dynamic: true }));
|
||||||
|
|
||||||
|
const tracks = queue.tracks.map((track, i) => `**${i + 1}** - ${track.title} | ${track.author} (requested by : ${track.requestedBy.username})`);
|
||||||
|
|
||||||
|
const songs = queue.tracks.length;
|
||||||
|
const nextSongs = songs > 5 ? `And **${songs - 5}** other song(s)...` : `In the playlist **${songs}** song(s)...`;
|
||||||
|
|
||||||
|
embed.setDescription(`Current ${queue.current.title}\n\n${tracks.slice(0, 5).join('\n')}\n\n${nextSongs}`);
|
||||||
|
|
||||||
|
embed.setTimestamp();
|
||||||
|
embed.setFooter('Music comes first - Made with heart by Zerio ❤️', message.author.avatarURL({ dynamic: true }));
|
||||||
|
|
||||||
|
message.channel.send({ embeds: [embed] });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1,20 +1,16 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'resume',
|
name: 'resume',
|
||||||
aliases: [],
|
aliases: ['rs'],
|
||||||
category: 'Music',
|
|
||||||
utilisation: '{prefix}resume',
|
utilisation: '{prefix}resume',
|
||||||
|
voiceChannel: true,
|
||||||
|
|
||||||
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 !`);
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
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 (!queue) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
|
const success = queue.setPaused(false);
|
||||||
|
|
||||||
if (!client.player.getQueue(message).paused) return message.channel.send(`${client.emotes.error} - The music is already playing !`);
|
return message.channel.send(success ? `Current music ${queue.current.title} resumed ✅` : `Something went wrong ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
const success = client.player.resume(message);
|
|
||||||
|
|
||||||
if (success) message.channel.send(`${client.emotes.success} - Song ${client.player.getQueue(message).playing.title} resumed !`);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
18
commands/music/save.js
Normal file
18
commands/music/save.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: 'save',
|
||||||
|
aliases: ['sv'],
|
||||||
|
utilisation: '{prefix}save',
|
||||||
|
voiceChannel: true,
|
||||||
|
|
||||||
|
async execute(client, message) {
|
||||||
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
|
if (!queue || !queue.playing) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
|
message.author.send(`You saved the track ${queue.current.title} | ${queue.current.author} from the server ${message.guild.name} ✅`).then(() => {
|
||||||
|
message.channel.send(`I have sent you the title of the music by private messages ✅`);
|
||||||
|
}).catch(error => {
|
||||||
|
message.channel.send(`Unable to send you a private message ${message.author}... try again ? ❌`);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
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(" "));
|
|
||||||
},
|
|
||||||
};
|
|
||||||
22
commands/music/seek.js
Normal file
22
commands/music/seek.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
const ms = require('ms');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'seek',
|
||||||
|
aliases: [],
|
||||||
|
utilisation: '{prefix}seek [time]',
|
||||||
|
voiceChannel: true,
|
||||||
|
|
||||||
|
async execute(client, message, args) {
|
||||||
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
|
if (!queue || !queue.playing) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
|
const timeToMS = ms(args.join(' '));
|
||||||
|
|
||||||
|
if (timeToMS >= queue.current.durationMS) return message.channel.send(`The indicated time is higher than the total time of the current song ${message.author}... try again ? ❌\n*Try for example a valid time like **5s, 10s, 20 seconds, 1m**...*`);
|
||||||
|
|
||||||
|
await queue.seek(timeToMS);
|
||||||
|
|
||||||
|
message.channel.send(`Time set on the current song **${ms(timeToMS, { long: true })}** ✅`);
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'shuffle',
|
name: 'shuffle',
|
||||||
aliases: ['sh'],
|
aliases: ['sh'],
|
||||||
category: 'Music',
|
|
||||||
utilisation: '{prefix}shuffle',
|
utilisation: '{prefix}shuffle',
|
||||||
|
voiceChannel: true,
|
||||||
|
|
||||||
execute(client, message) {
|
async execute(client, message) {
|
||||||
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
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 (!queue || !queue.playing) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
|
if (!queue.tracks[0]) return message.channel.send(`No music in the queue after the current one ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
const success = client.player.shuffle(message);
|
await queue.shuffle();
|
||||||
|
|
||||||
if (success) message.channel.send(`${client.emotes.success} - Queue shuffled **${client.player.getQueue(message).tracks.length}** song(s) !`);
|
return message.channel.send(`Queue shuffled **${queue.tracks.length}** song(s) ! ✅`);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1,18 +1,16 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'skip',
|
name: 'skip',
|
||||||
aliases: ['sk'],
|
aliases: ['sk'],
|
||||||
category: 'Music',
|
|
||||||
utilisation: '{prefix}skip',
|
utilisation: '{prefix}skip',
|
||||||
|
voiceChannel: true,
|
||||||
|
|
||||||
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 !`);
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
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 (!queue || !queue.playing) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
|
const success = queue.skip();
|
||||||
|
|
||||||
const success = client.player.skip(message);
|
return message.channel.send(success ? `Current music ${queue.current.title} skipped ✅` : `Something went wrong ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
if (success) message.channel.send(`${client.emotes.success} - The current music has just been **skipped** !`);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1,19 +1,16 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'stop',
|
name: 'stop',
|
||||||
aliases: ['dc'],
|
aliases: ['dc'],
|
||||||
category: 'Music',
|
|
||||||
utilisation: '{prefix}stop',
|
utilisation: '{prefix}stop',
|
||||||
|
voiceChannel: true,
|
||||||
|
|
||||||
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 !`);
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
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 (!queue || !queue.playing) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
|
queue.destroy();
|
||||||
|
|
||||||
client.player.setRepeatMode(message, false);
|
message.channel.send(`Music stopped into this server, see you next time ✅`);
|
||||||
const success = client.player.stop(message);
|
|
||||||
|
|
||||||
if (success) message.channel.send(`${client.emotes.success} - Music **stopped** into this server !`);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1,22 +1,26 @@
|
|||||||
|
const maxVol = client.config.opt.maxVol;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'volume',
|
name: 'volume',
|
||||||
aliases: [],
|
aliases: ['vol'],
|
||||||
category: 'Music',
|
utilisation: `{prefix}volume [1-${maxVol}]`,
|
||||||
utilisation: '{prefix}volume [1-100]',
|
voiceChannel: true,
|
||||||
|
|
||||||
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 !`);
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
|
||||||
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 (!queue || !queue.playing) return message.channel.send(`No music currently playing ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
if (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`);
|
const vol = parseInt(args[0]);
|
||||||
|
|
||||||
if (!args[0] || isNaN(args[0]) || args[0] === 'Infinity') return message.channel.send(`${client.emotes.error} - Please enter a valid number !`);
|
if (!vol) return message.channel.send(`The current volume is ${queue.volume} 🔊\n*To change the volume enter a valid number between **1** and **${maxVol}**.*`);
|
||||||
|
|
||||||
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 (queue.volume === vol) return message.channel.send(`The volume you want to change is already the current one ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
const success = client.player.setVolume(message, parseInt(args[0]));
|
if (vol < 0 || vol > maxVol) return message.channel.send(`The specified number is not valid. Enter a number between **1** and **${maxVol}** ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
if (success) message.channel.send(`${client.emotes.success} - Volume set to **${parseInt(args[0])}%** !`);
|
const success = queue.setVolume(vol);
|
||||||
|
|
||||||
|
return message.channel.send(success ? `The volume has been modified to **${vol}**/**${maxVol}**% 🔊` : `Something went wrong ${message.author}... try again ? ❌`);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
name: 'w-filters',
|
|
||||||
aliases: ['filters'],
|
|
||||||
category: 'Music',
|
|
||||||
utilisation: '{prefix}w-filters',
|
|
||||||
|
|
||||||
execute(client, message) {
|
|
||||||
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 !`);
|
|
||||||
|
|
||||||
const filtersStatuses = [[], []];
|
|
||||||
|
|
||||||
client.filters.forEach((filterName) => {
|
|
||||||
const array = filtersStatuses[0].length > filtersStatuses[1].length ? filtersStatuses[1] : filtersStatuses[0];
|
|
||||||
array.push(filterName.charAt(0).toUpperCase() + filterName.slice(1) + " : " + (client.player.getQueue(message).filters[filterName] ? client.emotes.success : client.emotes.off));
|
|
||||||
});
|
|
||||||
|
|
||||||
message.channel.send({
|
|
||||||
embed: {
|
|
||||||
color: 'ORANGE',
|
|
||||||
footer: { text: 'This bot uses a Github project made by Zerio (ZerioDev/Music-bot)' },
|
|
||||||
fields: [
|
|
||||||
{ name: 'Filters', value: filtersStatuses[0].join('\n'), inline: true },
|
|
||||||
{ name: '** **', value: filtersStatuses[1].join('\n'), inline: true },
|
|
||||||
],
|
|
||||||
timestamp: new Date(),
|
|
||||||
description: `List of all filters enabled or disabled.\nUse \`${client.config.discord.prefix}filter\` to add a filter to a song.`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
17
config.js
Normal file
17
config.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
module.exports = {
|
||||||
|
app: {
|
||||||
|
px: 'XXX',
|
||||||
|
token: 'XXX',
|
||||||
|
playing: 'by Zerio ❤️',
|
||||||
|
},
|
||||||
|
|
||||||
|
opt: {
|
||||||
|
DJ: {
|
||||||
|
enabled: false,
|
||||||
|
roleName: 'DJ',
|
||||||
|
commands: ['back', 'clear', 'filter', 'loop', 'pause', 'resume', 'seek', 'shuffle', 'skip', 'stop', 'volume']
|
||||||
|
},
|
||||||
|
maxVol: 100,
|
||||||
|
discordPlayer: {}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
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'],
|
|
||||||
};
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
module.exports = (client, message) => {
|
|
||||||
if (message.author.bot || message.channel.type === 'dm') return;
|
|
||||||
|
|
||||||
const prefix = client.config.discord.prefix;
|
|
||||||
|
|
||||||
if (message.content.indexOf(prefix) !== 0) return;
|
|
||||||
|
|
||||||
const args = message.content.slice(prefix.length).trim().split(/ +/g);
|
|
||||||
const command = args.shift().toLowerCase();
|
|
||||||
|
|
||||||
const cmd = client.commands.get(command) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(command));
|
|
||||||
|
|
||||||
if (cmd) cmd.execute(client, message, args);
|
|
||||||
};
|
|
||||||
30
events/messageCreate.js
Normal file
30
events/messageCreate.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
module.exports = (client, message) => {
|
||||||
|
if (message.author.bot || message.channel.type === 'dm') return;
|
||||||
|
|
||||||
|
const prefix = client.config.app.px;
|
||||||
|
|
||||||
|
if (message.content.indexOf(prefix) !== 0) return;
|
||||||
|
|
||||||
|
const args = message.content.slice(prefix.length).trim().split(/ +/g);
|
||||||
|
const command = args.shift().toLowerCase();
|
||||||
|
|
||||||
|
const cmd = client.commands.get(command) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(command));
|
||||||
|
|
||||||
|
const DJ = client.config.opt.DJ;
|
||||||
|
|
||||||
|
if (cmd && DJ.enabled && DJ.commands.includes(cmd.name)) {
|
||||||
|
const roleDJ = message.guild.roles.cache.find(x => x.name === DJ.roleName);
|
||||||
|
|
||||||
|
if (!message.member._roles.includes(roleDJ.id)) {
|
||||||
|
return message.channel.send(`This command is reserved for members with the ${DJ.roleName} role on the server ${message.author}... try again ? ❌`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd && cmd.voiceChannel) {
|
||||||
|
if (!message.member.voice.channel) return message.channel.send(`You're not in a voice channel ${message.author}... try again ? ❌`);
|
||||||
|
|
||||||
|
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`You are not in the same voice channel ${message.author}... try again ? ❌`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd) cmd.execute(client, message, args);
|
||||||
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
module.exports = async (client) => {
|
module.exports = async (client) => {
|
||||||
console.log(`Logged in as ${client.user.username}. Ready on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users`);
|
console.log(`Logged to the client ${client.user.username}\n-> Ready on ${client.guilds.cache.size} servers for a total of ${client.users.cache.size} users`);
|
||||||
|
|
||||||
client.user.setActivity(client.config.discord.activity);
|
client.user.setActivity(client.config.app.playing);
|
||||||
};
|
};
|
||||||
39
index.js
39
index.js
@@ -1,39 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const discord = require('discord.js');
|
|
||||||
|
|
||||||
const client = new discord.Client({ disableMentions: 'everyone' });
|
|
||||||
|
|
||||||
const { Player } = require('discord-player');
|
|
||||||
|
|
||||||
client.player = new Player(client);
|
|
||||||
client.config = require('./config/bot');
|
|
||||||
client.emotes = client.config.emojis;
|
|
||||||
client.filters = client.config.filters;
|
|
||||||
client.commands = new discord.Collection();
|
|
||||||
|
|
||||||
fs.readdirSync('./commands').forEach(dirs => {
|
|
||||||
const commands = fs.readdirSync(`./commands/${dirs}`).filter(files => files.endsWith('.js'));
|
|
||||||
|
|
||||||
for (const file of commands) {
|
|
||||||
const command = require(`./commands/${dirs}/${file}`);
|
|
||||||
console.log(`Loading command ${file}`);
|
|
||||||
client.commands.set(command.name.toLowerCase(), command);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const events = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
|
|
||||||
const player = fs.readdirSync('./player').filter(file => file.endsWith('.js'));
|
|
||||||
|
|
||||||
for (const file of events) {
|
|
||||||
console.log(`Loading discord.js event ${file}`);
|
|
||||||
const event = require(`./events/${file}`);
|
|
||||||
client.on(file.split(".")[0], event.bind(null, client));
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const file of player) {
|
|
||||||
console.log(`Loading discord-player event ${file}`);
|
|
||||||
const event = require(`./player/${file}`);
|
|
||||||
client.player.on(file.split(".")[0], event.bind(null, client));
|
|
||||||
};
|
|
||||||
|
|
||||||
client.login(client.config.discord.token);
|
|
||||||
21
main.js
Normal file
21
main.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
const { Player } = require('discord-player');
|
||||||
|
const { Client, Intents } = require('discord.js');
|
||||||
|
|
||||||
|
global.client = new Client({
|
||||||
|
intents: [
|
||||||
|
Intents.FLAGS.GUILDS,
|
||||||
|
Intents.FLAGS.GUILD_MEMBERS,
|
||||||
|
Intents.FLAGS.GUILD_MESSAGES,
|
||||||
|
Intents.FLAGS.GUILD_VOICE_STATES
|
||||||
|
],
|
||||||
|
disableMentions: 'everyone',
|
||||||
|
});
|
||||||
|
|
||||||
|
client.config = require('./config');
|
||||||
|
|
||||||
|
global.player = new Player(client, client.config.opt.discordPlayer);
|
||||||
|
|
||||||
|
require('./src/loader');
|
||||||
|
require('./src/events');
|
||||||
|
|
||||||
|
client.login(client.config.app.token);
|
||||||
16
package.json
16
package.json
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "music-bot",
|
"name": "music-bot",
|
||||||
"main": "index.js",
|
"main": "main.js",
|
||||||
"author": "ZerioDev",
|
"author": "ZerioDev",
|
||||||
"version": "5.0.0",
|
"version": "6.0.0",
|
||||||
"repository": "https://github.com/ZerioDev/Music-bot.git",
|
"repository": "https://github.com/ZerioDev/Music-bot.git",
|
||||||
"description": "A complete code to download for a music bot. Using a module (discord-player).",
|
"description": "A complete code to download for a cool Discord music bot.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node index.js"
|
"start": "node main.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/opus": "^0.3.3",
|
"discord-player": "^5.1.0",
|
||||||
"discord-player": "^3.3.2",
|
"discord.js": "^13.1.0",
|
||||||
"discord.js": "^12.5.1",
|
"ffmpeg-static": "^4.4.0",
|
||||||
"ffmpeg-static": "^4.2.7"
|
"ms": "^3.0.0-canary.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
module.exports = (client, message, queue) => {
|
|
||||||
message.channel.send(`${client.emotes.error} - Music stopped as i have been disconnected from the channel !`);
|
|
||||||
};
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
module.exports = (client, message, queue) => {
|
|
||||||
message.channel.send(`${client.emotes.error} - Music stopped as there is no more member in the voice channel !`);
|
|
||||||
};
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
module.exports = (client, error, message, ...args) => {
|
|
||||||
switch (error) {
|
|
||||||
case 'NotPlaying':
|
|
||||||
message.channel.send(`${client.emotes.error} - There is no music being played on this server !`);
|
|
||||||
break;
|
|
||||||
case 'NotConnected':
|
|
||||||
message.channel.send(`${client.emotes.error} - You are not connected in any voice channel !`);
|
|
||||||
break;
|
|
||||||
case 'UnableToJoin':
|
|
||||||
message.channel.send(`${client.emotes.error} - I am not able to join your voice channel, please check my permissions !`);
|
|
||||||
break;
|
|
||||||
case 'VideoUnavailable':
|
|
||||||
message.channel.send(`${client.emotes.error} - ${args[0].title} is not available in your country! Skipping...`);
|
|
||||||
break;
|
|
||||||
case 'MusicStarting':
|
|
||||||
message.channel.send(`The music is starting... please wait and retry!`);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
message.channel.send(`${client.emotes.error} - Something went wrong ... Error : ${error}`);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
module.exports = (client, message, query) => {
|
|
||||||
message.channel.send(`${client.emotes.error} - No results found on YouTube for ${query} !`);
|
|
||||||
};
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
module.exports = (client, message, queue, playlist) => {
|
|
||||||
message.channel.send(`${client.emotes.music} - ${playlist.title} has been added to the queue (**${playlist.tracks.length}** songs) !`);
|
|
||||||
};
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
module.exports = (client, message, queue) => {
|
|
||||||
message.channel.send(`${client.emotes.error} - Music stopped as there is no more music in the queue !`);
|
|
||||||
};
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
module.exports = (client, message, query, tracks) => {
|
|
||||||
message.channel.send(`${client.emotes.error} - You did not provide a valid response ... Please send the command again !`);
|
|
||||||
};
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
module.exports = (client, message, query, tracks, content, collector) => {
|
|
||||||
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}** !`);
|
|
||||||
};
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
module.exports = (client, message, query, tracks) => {
|
|
||||||
message.channel.send({
|
|
||||||
embed: {
|
|
||||||
color: 'BLUE',
|
|
||||||
author: { name: `Here are your search results for ${query}` },
|
|
||||||
footer: { text: 'This bot uses a Github project made by Zerio (ZerioDev/Music-bot)' },
|
|
||||||
timestamp: new Date(),
|
|
||||||
description: `${tracks.map((t, i) => `**${i + 1}** - ${t.title}`).join('\n')}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
module.exports = (client, message, queue, track) => {
|
|
||||||
message.channel.send(`${client.emotes.music} - ${track.title} has been added to the queue !`);
|
|
||||||
};
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
module.exports = (client, message, track) => {
|
|
||||||
message.channel.send(`${client.emotes.music} - Now playing ${track.title} into ${message.member.voice.channel.name} ...`);
|
|
||||||
};
|
|
||||||
27
src/events.js
Normal file
27
src/events.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
player.on('error', (queue, error) => {
|
||||||
|
console.log(`Error emitted from the queue ${error.message}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
player.on('connectionError', (queue, error) => {
|
||||||
|
console.log(`Error emitted from the connection ${error.message}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
player.on('trackStart', (queue, track) => {
|
||||||
|
queue.metadata.send(`Started playing ${track.title} in **${queue.connection.channel.name}** 🎧`);
|
||||||
|
});
|
||||||
|
|
||||||
|
player.on('trackAdd', (queue, track) => {
|
||||||
|
queue.metadata.send(`Track ${track.title} added in the queue ✅`);
|
||||||
|
});
|
||||||
|
|
||||||
|
player.on('botDisconnect', (queue) => {
|
||||||
|
queue.metadata.send('I was manually disconnected from the voice channel, clearing queue... ❌');
|
||||||
|
});
|
||||||
|
|
||||||
|
player.on('channelEmpty', (queue) => {
|
||||||
|
queue.metadata.send('Nobody is in the voice channel, leaving the voice channel... ❌');
|
||||||
|
});
|
||||||
|
|
||||||
|
player.on('queueEnd', (queue) => {
|
||||||
|
queue.metadata.send('I finished reading the whole queue ✅');
|
||||||
|
});
|
||||||
28
src/loader.js
Normal file
28
src/loader.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
const { readdirSync } = require('fs');
|
||||||
|
const { Collection } = require('discord.js');
|
||||||
|
|
||||||
|
client.commands = new Collection();
|
||||||
|
|
||||||
|
const events = readdirSync('./events/').filter(file => file.endsWith('.js'));
|
||||||
|
|
||||||
|
console.log(`Loading events...`);
|
||||||
|
|
||||||
|
for (const file of events) {
|
||||||
|
const event = require(`../events/${file}`);
|
||||||
|
console.log(`-> Loaded event ${file.split('.')[0]}`);
|
||||||
|
client.on(file.split('.')[0], event.bind(null, client));
|
||||||
|
delete require.cache[require.resolve(`../events/${file}`)];
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(`Loading commands...`);
|
||||||
|
|
||||||
|
readdirSync('./commands/').forEach(dirs => {
|
||||||
|
const commands = readdirSync(`./commands/${dirs}`).filter(files => files.endsWith('.js'));
|
||||||
|
|
||||||
|
for (const file of commands) {
|
||||||
|
const command = require(`../commands/${dirs}/${file}`);
|
||||||
|
console.log(`-> Loaded command ${command.name.toLowerCase()}`);
|
||||||
|
client.commands.set(command.name.toLowerCase(), command);
|
||||||
|
delete require.cache[require.resolve(`../commands/${dirs}/${file}`)];
|
||||||
|
};
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user