-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bbe381a
Showing
37 changed files
with
2,698 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Node | ||
node_modules/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Music-bot | ||
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 ! | ||
|
||
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 | ||
|
||
Well, let's start by downloading the code. | ||
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 | ||
|
||
```js | ||
emojis: { | ||
off: ':x:', | ||
error: ':warning:', | ||
queue: ':bar_chart:', | ||
music: ':musical_note:', | ||
success: ':white_check_mark:', | ||
} | ||
``` | ||
|
||
- For configuration | ||
|
||
```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. | ||
- `activity`, the activity of the bot. | ||
|
||
In the console, type `npm install` to install all dependencies. | ||
|
||
- To start the bot : | ||
|
||
``` | ||
#With Node | ||
node index.js | ||
npm start #Indicated in package.json | ||
#With pm2 | ||
pm2 start index.js --name "MusicBot" | ||
``` | ||
|
||
All you have to do is turn on your bot ! | ||
|
||
### 🎵 Music commands | ||
|
||
``` | ||
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 | ||
|
||
``` | ||
ping, see the bot latency. | ||
help, see the list of available commands. | ||
debug, see number of voice connections. | ||
``` | ||
|
||
### 🏓 Utilities (to change the code) | ||
|
||
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module.exports = { | ||
name: 'help', | ||
aliases: ['h'], | ||
category: 'Core', | ||
utilisation: '{prefix}help <command name>', | ||
|
||
execute(client, message, args) { | ||
if (!args[0]) { | ||
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: { | ||
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 !`); | ||
|
||
message.channel.send({ | ||
embed: { | ||
color: 'ORANGE', | ||
author: { name: 'Help pannel' }, | ||
footer: { text: 'This bot uses a Github project made by Zerio (ZerioDev/Music-bot)' }, | ||
fields: [ | ||
{ name: 'Name', value: command.name, inline: true }, | ||
{ 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 `<>`.', | ||
} | ||
}); | ||
}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
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 !`); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
name: 'ping', | ||
aliases: [], | ||
category: 'Infos', | ||
utilisation: '{prefix}ping', | ||
|
||
execute(client, message) { | ||
message.channel.send(`${client.emotes.success} - Ping : **${client.ws.ping}ms** !`); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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** !`); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module.exports = { | ||
name: 'filter', | ||
aliases: [], | ||
category: 'Music', | ||
utilisation: '{prefix}filter [filter name]', | ||
|
||
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 (!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 !`); | ||
|
||
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, try for example (8D, vibrato, pulsator...) !`); | ||
|
||
const filtersUpdated = {}; | ||
|
||
filtersUpdated[filterToUpdate] = client.player.getQueue(message).filters[filterToUpdate] ? false : true; | ||
|
||
client.player.setFilters(message, 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.`); | ||
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.`); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module.exports = { | ||
name: 'loop', | ||
aliases: ['lp', 'repeat'], | ||
category: 'Music', | ||
utilisation: '{prefix}loop', | ||
|
||
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 (!client.player.getQueue(message)) return message.channel.send(`${client.emotes.error} - No music currently playing !`); | ||
|
||
if (args.join(" ").toLowerCase() === 'queue') { | ||
if (client.player.getQueue(message).loopMode) { | ||
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 { | ||
if (client.player.getQueue(message).repeatMode) { | ||
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 !`); | ||
}; | ||
}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module.exports = { | ||
name: 'nowplaying', | ||
aliases: ['np'], | ||
category: 'Music', | ||
utilisation: '{prefix}nowplaying', | ||
|
||
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 track = client.player.nowPlaying(message); | ||
const filters = []; | ||
|
||
Object.keys(client.player.getQueue(message).filters).forEach((filterName) => client.player.getQueue(message).filters[filterName]) ? filters.push(filterName) : false; | ||
|
||
message.channel.send({ | ||
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 }, | ||
{ 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 }, | ||
{ name: 'Repeat mode', value: client.player.getQueue(message).repeatMode ? 'Yes' : 'No', inline: 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 } | ||
], | ||
thumbnail: { url: track.thumbnail }, | ||
timestamp: new Date(), | ||
}, | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = { | ||
name: 'pause', | ||
aliases: [], | ||
category: 'Music', | ||
utilisation: '{prefix}pause', | ||
|
||
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).paused) return message.channel.send(`${client.emotes.error} - The music is already paused !`); | ||
|
||
const success = client.player.pause(message); | ||
|
||
if (success) message.channel.send(`${client.emotes.success} - Song ${client.player.getQueue(message).playing.title} paused !`); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
name: 'play', | ||
aliases: ['p'], | ||
category: 'Music', | ||
utilisation: '{prefix}play [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(" "), { firstResult: true }); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = { | ||
name: 'queue', | ||
aliases: [], | ||
category: 'Music', | ||
utilisation: '{prefix}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 !`); | ||
|
||
const queue = client.player.getQueue(message); | ||
|
||
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} ${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})` | ||
}).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)...`}`)); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = { | ||
name: 'resume', | ||
aliases: [], | ||
category: 'Music', | ||
utilisation: '{prefix}resume', | ||
|
||
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).paused) return message.channel.send(`${client.emotes.error} - The music is already playing !`); | ||
|
||
const success = client.player.resume(message); | ||
|
||
if (success) message.channel.send(`${client.emotes.success} - Song ${client.player.getQueue(message).playing.title} resumed !`); | ||
}, | ||
}; |
Oops, something went wrong.