1 | # Discord.js Music Bot Addon
|
2 | [![npm package](https://nodei.co/npm/discord.js-musicbot-addon.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/discord.js-musicbot-addon/)
|
3 | [![Discord Server](https://discordapp.com/api/guilds/360519133219127297/embed.png)](https://discord.gg/cADwxKs) [![Downlaods](https://img.shields.io/npm/dt/discord.js-musicbot-addon.svg?maxAge=3600)](https://www.npmjs.com/package/discord.js-musicbot-addon) [![Version](https://img.shields.io/npm/v/discord.js-musicbot-addon.svg?maxAge=3600)](https://www.npmjs.com/package/discord.js-musicbot-addon)
|
4 | ***
|
5 | This module may be buggy and need some fine tuning. Feel free to let me know what problems you encounter by opening an issue on the repo.
|
6 | This was originally an update of the original bot from [ruiqimao](https://github.com/ruiqimao/discord.js-music) by [nexu-dev](https://www.npmjs.com/package/discord.js-music-v11), but is now a updated version for [Discord.js](https://discord.js.org/)'s version 11.2^. Fixes deprecated warnings, video playback issues, along with various other add-ons and tweaks to the priors.
|
7 |
|
8 | _Note: the 1.3.x+ update(S) requires a code change from 1.2.0, see the examples/notes below._
|
9 |
|
10 | __The commands available are: (default names)__
|
11 | * `musichelp [command]`: Displays help text for commands by this addon, or help for a specific command.
|
12 | * `play <url>|<search string>`: Play audio from YouTube.
|
13 | * `skip [number]`: Skip a song or multi songs with skip [some number],
|
14 | * `queue`: Display the current queue.
|
15 | * `pause`: Pause music playback. (requires music manager).
|
16 | * `resume`: Resume music playback. (requires music manager).
|
17 | * `volume`: Adjust the playback volume between 1 and 200 (requires music manager).
|
18 | * `leave`: Clears the song queue and leaves the channel.
|
19 | * `clearqueue`: Clears the song queue.
|
20 |
|
21 | __Permissions:__
|
22 | * If `anyoneCanSkip` is false then only admins and the user that requested the song can skip it.
|
23 | * If `anyoneCanAdjust` is true, anyone can adjust the volume. False is only admins.
|
24 | * If `ownerOverMember` is true, the set ID of the user (your ID) will over-ride CanAjust and CanSkip.
|
25 |
|
26 | ***
|
27 | # Installation
|
28 | ***
|
29 | __Pre-installation:__
|
30 | 1. `npm install discord.js`
|
31 | It is recommended to have the stable over dev branch.
|
32 |
|
33 | 2. `npm install ffmpeg-binaries` or `ffmpeg installed`
|
34 | Allows the bot to join voice as well as speak.
|
35 |
|
36 | 3. `npm install node-opus` or `npm install opusscript`
|
37 | Required for voice. Discord _prefers_ node-opus, but it is your choice.
|
38 |
|
39 | __Installation:__
|
40 | * `npm install discord.js-musicbot-addon`
|
41 |
|
42 | __Common installation issues:__
|
43 | __Issue:__ FFMPEG was not found on your system, so audio cannot be played. Please make sure FFMPEG is installed and in your PATH.
|
44 | __Fix:__ `npm install ffmpeg-binaries`
|
45 |
|
46 | __Issue:__ Couldn't find an Opus engine.
|
47 | __Fix:__ `npm install node-opus` or `npm install opusscript`
|
48 |
|
49 | __Issue:__ [NPM] ERR Cannot read property '0' of undefined
|
50 | __Fix:__ `npm i -g npm@4.6.1` or another lower version of npm.
|
51 |
|
52 | __Issue:__ Any node-gyp errors. (build fail, missing cl.exe, etc.)
|
53 | __Fix:__ This one is a little more complicated.
|
54 | 1. Download and install [Visual Studio 2015](https://www.visualstudio.com/downloads/)
|
55 | 2. New project -> Visual C++
|
56 | 3. Install Visual C++
|
57 |
|
58 | If that doesn't fix your issue;
|
59 | 1. Download and install the [Windows 8.1 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-8-1-sdk)
|
60 |
|
61 | ***
|
62 | # Examples & Options
|
63 | ***
|
64 | This addon is easy to use, and doesn't require any configuration.
|
65 | More examples can be found on the repo in `examples` or once downloaded.
|
66 |
|
67 | __Example basic code, standalone:__
|
68 | ```javascript
|
69 | const Discord = require('discord.js');
|
70 | const Music = require('discord.js-musicbot-addon');
|
71 | const <client> = new Discord.Client();
|
72 |
|
73 | const music = new Music(<client>,
|
74 | youtubeKey: 'sum-key_hhereas'
|
75 | );
|
76 | <client>.login(token);
|
77 | ```
|
78 |
|
79 | __Most options are optional and thus not needed.__
|
80 | The options you can pass in music(client, options) is as followed:
|
81 | * prefix: Prefix to set for commands.
|
82 | * global: true/false. If set to true, will use global queues, false will use server. (default false)
|
83 | * maxQueueSize: Max size of queues.
|
84 | * anyoneCanSkip: Whether or not anyone can skip, true/false. Defaults false.
|
85 | * anyoneCanAdjust: Whether or not anyone can set volume. Defaults false.
|
86 | * clearInvoker: Whether or not to clear the command message.
|
87 | * volume: Default volume. Anywhere from 1 to 200, default is 50.
|
88 | * helpCmd: Name of the help command.
|
89 | * playCmd: Sets the play command name.
|
90 | * skipCmd: Sets the skip command name.
|
91 | * queueCmd: Sets the queue command name.
|
92 | * pauseCmd: Sets the name for the pause command.
|
93 | * resumeCmd: Sets the name for the resume command.
|
94 | * volumeCmd: Sets the name for the volume command.
|
95 | * leaveCmd: Sets the name for the leave command.
|
96 | * clearCmd: Sets the name for the clearqueue command.
|
97 | * enableQueueStat: Disables or enables queue status (useful to prevent errors sometimes, defaults true).
|
98 | * ownerOverMember: Makes it so you bypass restrictions from the bot.
|
99 | * botOwner: ID of your account, required if using ownerOverMember.
|
100 | * logging: Disable/enable some extra, none need logging. Defaults to true. Useful but not needed.
|
101 | * __youtubeKey:__ This is __REQUIRED__. Something [like this article](https://elfsight.com/help/how-to-get-youtube-api-key/) should help with that, or google how to get a YouTube API3 key.
|
102 |
|
103 | An example of a few custom commands would be:
|
104 | ```javascript
|
105 | const music = new Music(client, {
|
106 | prefix: ">",
|
107 | maxQueueSize: "10",
|
108 | anyoneCanSkip: false,
|
109 | helpCmd: 'mhelp',
|
110 | playCmd: 'music',
|
111 | leaveCmd: 'begone',
|
112 | ownerOverMember: true,
|
113 | botOwner: '1234567890',
|
114 | youtubeKey: 'some-key_here'
|
115 | });
|
116 | ```
|
117 |
|
118 | Again if you have any issues, feel free to open one on the repo, or join my [Discord server](https://discord.gg/cADwxKs) for personal help.
|
119 |
|
120 | ***
|
121 | # Changelog
|
122 | ***
|
123 |
|
124 | ## 1.4.0
|
125 | * Added wrapping.
|
126 | * Added owner over member options.
|
127 | * Fixed errors.
|
128 | * Reworked the the playing music method.
|
129 | * Fixed (probably) UnknownSpawn errors.
|
130 | * Bot now requires your own YouTube Data API3 key for searching.
|
131 | * Music is less likely yo cut out now.
|
132 | * Volume works again (again).
|
133 |
|
134 | ## 1.3.1 - 1.3.6
|
135 | * These were testing updates to just see how it would work on different platforms, which code still needed to be fixed, error testing, etc.
|
136 |
|
137 | ## 1.3.0:
|
138 | * Added errors.
|
139 | * Fixed volume crashing the bot (thanks TheTimmaeh).
|
140 | * Added future support for events.
|
141 | * Minor bug fixes.
|
142 |
|
143 | ## 1.2.0:
|
144 | * Marked "stable".
|
145 | * Finished module for full public access.
|
146 |
|
147 | ## 1.1.0 and lower:
|
148 | * No idea.
|