✨ Bug fixes & update (v4.0.0)
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,2 @@
|
|||||||
# Node
|
# Node
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
44
README.md
44
README.md
@@ -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 `bot.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` in the same folder.
|
|
||||||
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
|
||||||
@@ -81,4 +81,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).
|
||||||
@@ -20,7 +20,7 @@ module.exports = {
|
|||||||
{ name: 'Filters', value: '`bassboost`, `8D`, `vaporwave`, `nightcore`, `phaser`, `tremolo`, `vibrato`, `reverse`, `treble`, `normalizer`, `surrounding`, `pulsator`, `subboost`, `karaoke`, `flanger`, `gate`, `haas`, `mcompand`' },
|
{ name: 'Filters', value: '`bassboost`, `8D`, `vaporwave`, `nightcore`, `phaser`, `tremolo`, `vibrato`, `reverse`, `treble`, `normalizer`, `surrounding`, `pulsator`, `subboost`, `karaoke`, `flanger`, `gate`, `haas`, `mcompand`' },
|
||||||
],
|
],
|
||||||
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 {
|
||||||
@@ -37,7 +37,7 @@ module.exports = {
|
|||||||
{ 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('\n'), 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 `<>`.',
|
||||||
|
|||||||
@@ -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 !`);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -13,18 +13,17 @@ module.exports = {
|
|||||||
|
|
||||||
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.`);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -14,9 +14,7 @@ module.exports = {
|
|||||||
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: {
|
||||||
@@ -30,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 },
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ module.exports = {
|
|||||||
|
|
||||||
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 !`);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -15,6 +15,6 @@ module.exports = {
|
|||||||
|
|
||||||
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 !`);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -11,14 +11,11 @@ module.exports = {
|
|||||||
|
|
||||||
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 disabledEmoji = client.emotes.error;
|
|
||||||
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({
|
||||||
@@ -30,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
17
config/bot.js
Normal 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'],
|
||||||
|
};
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"game": "GAME",
|
|
||||||
"prefix": "PREFIX",
|
|
||||||
"token_bot": "TOKEN"
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"music": ":musical_note:",
|
|
||||||
"queue": ":bar_chart:",
|
|
||||||
"error": ":x:",
|
|
||||||
"success": ":white_check_mark:"
|
|
||||||
}
|
|
||||||
@@ -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"
|
|
||||||
}
|
|
||||||
@@ -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);
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -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);
|
||||||
|
|
||||||
};
|
};
|
||||||
36
index.js
36
index.js
@@ -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);
|
||||||
12
package.json
12
package.json
@@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"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",
|
"version": "4.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.0.3",
|
||||||
"discord.js": "^12.2.0",
|
"discord.js": "^12.5.1",
|
||||||
"ffmpeg-static": "^4.2.7"
|
"ffmpeg-static": "^4.2.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user