Coder Social home page Coder Social logo

darkopendragon / discord.js-musicbot-addon Goto Github PK

View Code? Open in Web Editor NEW
112.0 20.0 145.0 363 KB

This DOES NOT WORK any more. This repo only serves as an archive for is anyone wants to pickup my work. You may still join the discord however.

Home Page: https://discord.gg/4c8Rh7tWhv

License: ISC License

JavaScript 99.34% Shell 0.66%
discordjs discord discord-music-bot nodejs npm npm-module javascript music bot discord-bot

discord.js-musicbot-addon's Introduction

A Little Notice:

This project is NO LONGER SUPPORTED and does NOT function. Do not use this. This repo serves as an archive of my work. If anyone wishes to re-upload this project, re-do it, or use it in any way you have my full permission. I am no longer supporting or working on this or any other projects not listed on my personal Discord. You may still join the Discord by clicking here.

Discord MusicBot Addon


This module is a simple Node.js based music extension/bot for Discord.js projects using YouTube. This was originally an update of an older addon for newer versions of Discord.js but not serves as it's own module.

The commands available are: (default names)

  • musichelp [command]: Displays help text for commands by this addon, or help for a specific command.
  • play <url>|<search string>: Play audio from YouTube.
  • search <search string>: Search's for up to 10 videos from YT.
  • skip [number]: Skip a song or multi songs with skip [some number].
  • queue [position]: Display the current queue.
  • pause: Pause music playback.
  • resume: Resume music playback.
  • remove [position]: Remove a song from the queue by position.
  • volume: Adjust the playback volume between 1 and 200.
  • leave: Clears the song queue and leaves the channel.
  • clearqueue: Clears the song queue.
  • np: Show the current playing song.

Permissions:

  • If anyoneCanSkip is true, anyone can skip songs in the queue.
  • If anyoneCanAdjust is true, anyone can adjust the volume.
  • If ownerOverMember is true, the set ID of the user (ownerID) will over-ride permissions from the bot.

Installation


Pre-installation:

  1. npm install discord.js
    It is recommended to have the stable branch.

  2. ffmpeg installed correctly for your OS/env.
    Allows the bot to join voice as well as speak.

  3. npm install node-opus or npm install opusscript
    Required for voice. Discord.js prefers node-opus.

Installation:

  • npm install discord.js-musicbot-addon
    If you have troubles installing, see this link or join the discord server. Note that the NPM version will be slightly behind the GitHub version.

Examples


See this page on the repo for examples.

Options & Config.


Most options are optional and thus not needed.
The options you can pass in music.start(client, {options}) and their types is as followed:

Basic Options.

Option Type Description Default
youtubeKey String A YouTube Data API3 key. Required to run. NaN
botPrefix String The prefix of the bot. Defaults to "!". Can also be a Map of prefix's. !
messageNewSong Boolean Whether or not to send a message when a new song starts playing. true
bigPicture Boolean Whether to use a large (true) image or small (false) for embeds. false
maxQueueSize Number Max queue size allowed. Defaults 100. Set to 0 for unlimited. 50
defVolume Number The default volume of music. 1 - 200. 50
anyoneCanSkip Boolean Whether or not anyone can skip. false
messageHelp Boolean Whether to message the user on help command usage. If it can't, it will send it in the channel like normal. false
botAdmins Object/Array An array of Discord user ID's to be admins as the bot. They will ignore permissions for the bot. [ ]
anyoneCanAdjust Boolean Whether anyone can adjust volume. false
ownerOverMember Boolean Whether the owner over-rides CanAdjust and CanSkip. false
anyoneCanLeave Boolean Whether anyone can make the bot leave the currently connected channel. false
ownerID String The ID of the Discord user to be seen as the owner. Required if using ownerOverMember. NaN
logging Boolean Some extra none needed logging (such as caught errors that didn't crash the bot, etc). true
requesterName Boolean Whether or not to display the username of the song requester. true
inlineEmbeds Boolean Whether or not to make embed fields inline (help command and some fields are excluded). false
musicPresence Boolean Whether or not to make the bot set its presence to currently playing music. false
clearPresence Boolean Whether or not to clear the presence instead of setting it to "nothing" false
insertMusic Boolean Whether or not to insert the music bot data into <Client>.music on start. false
channelWhitelist Object/Array Sets a list of ID's allow when running messages. [ ]
channelBlacklist Object/Array Sets a list of ID's ignore when running messages. [ ]
bitRate String Sets the preferred bitRate for the Discord.js stream to use. "120000"
nextPresence PresenceData PresenceData to set after instead of clearing it (clearPresence). null

Multi-Prefix Option Example

<Client>.guilds.forEach
<Music>.start(<Client>, {
  youtubeKey: "Data Key",
  botPrefix: <MapObject>
});

// Exmaple Map Structure
{serverID: { prefix: "!" } }

See examples for more info.

Cooldown

Option Type Description Default
cooldown Object The main cooldown object
cooldown.enabled Boolean Whether or not cooldowns are enabled. true
cooldown.timer Number Time in MS that cooldowns last. 10000
cooldown.exclude Object/Array Array of command names to exclude. Uses default names, not set names ["volume","queue","pause","resume","np"]

Command Options.

Commands pass a bit different. Each command follows the same format as below. Valid entries are play, remove, help, np, queue, volume, pause, resume, skip, clearqueue, loop, leave, shuffle, deletequeue.

music.start(client, {
  <command>: {
    enabled: false,                    // True/False statement.
    alt: ["name1","name2","name3"],    // Array of alt names (aliases).
    help: "Help text.",                // String of help text.
    name: "play"                       // Name of the command.
    usage: "{{prefix}}play bad memes", // Usage text. {{prefix}} will insert the bots prefix.
    exclude: false                     // Excludes the command from the help command.
  }
});

discord.js-musicbot-addon's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discord.js-musicbot-addon's Issues

Bot crash when trying to play

When trying to play a song the bot crashes

Error:

/home/doom/Desktop/Ghost-nodejs/node_modules/fluent-ffmpeg/lib/utils.js:433
          return lines.join('\n');
                       ^

RangeError: Maximum call stack size exceeded
    at Array.join (native)
    at Object.get (/home/doom/Desktop/Ghost-nodejs/node_modules/fluent-ffmpeg/lib/utils.js:433:24)
    at DestroyableTransform.<anonymous> (/home/doom/Desktop/Ghost-nodejs/node_modules/fluent-ffmpeg/lib/processor.js:500:48)
    at DestroyableTransform.emit (events.js:165:20)
    at DestroyableTransform.emit (events.js:165:20)
    at DestroyableTransform.emit (events.js:165:20)
    at DestroyableTransform.emit (events.js:165:20)
    at DestroyableTransform.emit (events.js:165:20)
    at DestroyableTransform.emit (events.js:165:20)
    at DestroyableTransform.emit (events.js:165:20)

And sometimes this:

function message(key, args) {
                ^

RangeError: Maximum call stack size exceeded
    at message (internal/errors.js:103:17)
    at new NodeError (internal/errors.js:25:13)
    at writeAfterEnd (_stream_writable.js:237:12)
    at PassThrough.Writable.write (_stream_writable.js:287:5)
    at PassThrough.Writable.end (_stream_writable.js:573:10)
    at DestroyableTransform.emit (events.js:165:20)
    at DestroyableTransform.emit (events.js:165:20)
    at DestroyableTransform.emit (events.js:165:20)
    at DestroyableTransform.emit (events.js:165:20)
    at DestroyableTransform.emit (events.js:165:20)```

ffmpeg version: ``` ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-shared --enable-version3 --enable-omx
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile} ```

TypeError: Cannot read property 'playStream' of undefined

When I try to play music, I get this error:
TypeError: Cannot read property 'playStream' of undefined
at Promise.then.connection (/home/magic/purpleRewrite/node_modules/discord.js-musicbot-addon/index.js:1881:39)
at
at process._tickCallback (internal/process/next_tick.js:118:7)

I tried to modify from playStream to play, but it didn't work.
this error is in the executeQueue function

remove command

Is your feature request related to a problem? Please describe.
It's really annoying when you only wanna remove one song that you accidentally added but you already have like 20 songs on there, so you have to clear the ENTIRE queue.

Describe the solution you'd like
remove (no. in queue) command, which removes 1 specific song.

async function play() SnytaxError: Unexpected token function

After (I assume) your latest update, I can't start my bot with this addon, as it gives me this error. is there a way to fix it?

    async function play(msg, suffix) {
          ^^^^^^^^

SyntaxError: Unexpected token function
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/critzlez/Documents/bot/bot.js:8:15)

leave and clear Cmd don't work

When I call any of these commands to clear the queue or stop the bot, it gives me error and the bot needs restarting.

clearCmd:
image

LeaveCmd:
image

Feature: Time Queued

One of the features suggested in the Discord was to have an option for the queue command to also log how long a video has been in the queue. I think this might be a cool option to have.

v13 not working for me?

None of the commands working for v13 for me. Is there something I have to update in my code?

Prefix

Okay so when I for example do t!set prefix m! it sets it for the current session, but then it reverts to the old prefix t! when i restart the bot. Fix?

Playlist

is normal, if i add a playlist, his skip all?

Null error on leave

I get this error:

Bot > TypeError: Cannot read property 'player' of null
Bot >     at Timeout.setTimeout [as _onTimeout] (/home/usr/code/Discord_bot/node_modules/discord.js-musicbot-addon/index.js:1891:17)
Bot >     at ontimeout (timers.js:498:11)
Bot >     at tryOnTimeout (timers.js:323:5)
Bot >     at Timer.listOnTimeout (timers.js:290:5)

This happens when i use the leave command when the bot is playing music.

os:Ubuntu18.04
module version: 12.0.6
Discord,js version:11.3.2
Node.js version: 8.11.3

client.on is not a function

Trying to run this code:

const Discord = require('discord.js');
class Bot extends Discord.Client {
  constructor(options) {
    super(options);
    this.music = require("discord.js-musicbot-addon");
  }
}
const client = new Bot();
client.music.start({
  youtubeKey: "token"
});
client.login("token");

But I have got an error:

C:\Users\Antoni\node_modules\discord.js-musicbot-addon\index.js:284
  client.on("ready", (client) => {
         ^

TypeError: client.on is not a function
    at Object.exports.start (C:\Users\Antoni\node_modules\discord.js-musicbot-addon\index.js:284:10)
    at Object.<anonymous> (C:\Users\Antoni\Desktop\testmuza\bot.js:11:14)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:266:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)

C:\Users\Antoni\Desktop\testmuza>

FFMPEG, Opusscript, Discord.js installed. Node - 10.9.0. NPM - 6.2.0.

npCmd Error

`

[npCmd] TypeError: Cannot read property 'title' of undefined

at Music.musicbot.np (/rbd/pnpm-volume/96e8c2aa-1ff3-4c52-96ab-833b158db2f6/node_modules/.registry.npmjs.org/discord.js-musicbot-addon/12.0.6/node_modules/discord.js-musicbot-addon/index.js:1811:34)

at musicbot.setLast.then (/rbd/pnpm-volume/96e8c2aa-1ff3-4c52-96ab-833b158db2f6/node_modules/.registry.npmjs.org/discord.js-musicbot-addon/12.0.6/node_modules/discord.js-musicbot-addon/index.js:2139:64)

at <anonymous>

at process._tickCallback (internal/process/next_tick.js:189:7)`

I got this. I fixed it by downloading a node-uuid package. I have no idea why it's necessary or why it fixed it but yeah xD

Bot crashed when requesting music

When I request a song it just says searching then the bot crashes

Here is the music part of the code

Music.start(client, {
prefix: 's!m', // Prefix for the commands.
global: true, // Non-server-specific queues.
maxQueueSize: 255, // Maximum queue size of 25.
clearInvoker: true, // If permissions applicable, allow the bot to delete the messages that invoke it.
helpCmd: 'help', // Sets the name for the help command.
playCmd: 'play', // Sets the name for the 'play' command.
volumeCmd: 'vol', // Sets the name for the 'volume' command.
leaveCmd: 'leave', // Sets the name for the 'leave' command.
enableQueueStat: true,
youtubeKey: config.ytapi,
});

Here is what the console spat out when it crashed

------- SeedBot -------
Version: 12.0.6
Extra Logging: false.
Using Global Queue: true.
Node.js Version: v8.11.3
------- SeedBot -------
(node:9292) UnhandledPromiseRejectionWarning: Error code: 400
(node:9292) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:9292) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

And here the modules that I have imported

// Load up the discord.js library
const Discord = require("discord.js");

//custom modules
const Music = require('discord.js-musicbot-addon');
const ffmpeg = require('@ffmpeg-installer/ffmpeg');
console.log(ffmpeg.path, ffmpeg.version);

Blank Testing Request

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Cannot read property 'playStream' of undefined

When I try to play music, I get this error:
TypeError: Cannot read property 'playStream' of undefined
at Promise.then.connection (/home/magic/purpleRewrite/node_modules/discord.js-musicbot-addon/index.js:1881:39)
at
at process._tickCallback (internal/process/next_tick.js:118:7)

I tried to modify from playStream to play, but it didn't work.
this error is in the executeQueue function

Arabic language error

Yep, I pretty much in love with this bot because it saves me alot of work. I hope you fix the error in arabic language that is inversing the text.

Bot crashed after playing a song.

Whenever I request a song through !play (with search feature or link) it crashes the bot.
It does provide me 8 songs to choose from first, I select the right song. The bot joins the voicechannel and in the textchannel it says: 🎵 | Queued Don Diablo & Steve Aoki x Lush & Simon - What We Started ft. BullySongs (Official Music Video) (so I think it fails when starting to play the song)

Error:

events.js:183
      throw er; // Unhandled 'error' event
      ^

TypeError: Invalid non-string/buffer chunk
    at validChunk (_stream_writable.js:254:10)
    at PassThrough.Writable.write (_stream_writable.js:288:21)
    at PassThrough.Writable.end (_stream_writable.js:553:10)
    at emitThree (events.js:141:20)
    at DestroyableTransform.emit (events.js:217:7)
    at emitThree (events.js:136:13)
    at FfmpegCommand.emit (events.js:217:7)
    at emitEnd (D:\Projects\Freetime\Discord Bots\AA Projects\MusicMaistro_New\node_modules\fluent-ffmpeg\lib\processor.js:424:16)
    at D:\Projects\Freetime\Discord Bots\AA Projects\MusicMaistro_New\node_modules\fluent-ffmpeg\lib\processor.js:433:16
    at D:\Projects\Freetime\Discord Bots\AA Projects\MusicMaistro_New\node_modules\async\dist\async.js:473:16
[nodemon] app crashed - waiting for file changes before starting...

TypeError: Cannot read property 'voiceChannel' of undefined

Sorry for opening another issue report, but I keep getting an error while using version 13.0.1 of the library installed using npm, and I'm using the examples from version 13. I've also made sure to use the command I was given to start the module in my last issue report.

I've gotten to the point of getting my bot into my server, but when I do the play command, the bot crashes and I get an error saying:

 if (msg.member.voiceChannel === undefined) return msg.channel.send(musicbot.note('fail', `You're not in a voice channel.`));
                   ^

TypeError: Cannot read property 'voiceChannel' of undefined
    at Music.musicbot.playFunction (C:\Users\Eric\node_modules\discord.js-musicbot-addon\index.js:316:20)

I have made sure that I am in a voice channel.
Here is my code, it is using the exmaple from version 13 of bot_basic.js, and to execute the command I'm using the example command from version 13 of callingCommand.js:

class Bot extends Discord.Client {
  constructor(options) {
    super(options);
    this.music = require("discord.js-musicbot-addon");
  }
}

const client = new Bot();

let ytapikeyRawdata = fs.readFileSync("ytapikey.json");
let ytapikey = JSON.parse(authRawdata);


else if(command == "PLAY") {
      client.music.bot.playFunction(args, message);
    }

All of my code can be found here: https://pastebin.com/UfsBNR0H

Versions

  • Version 11.4.2 of Discord.js
  • Version 8.11.4 of Node.js
  • Version 13.0.1 of discord.js-musicbot-addon

Thanks for taking the time to go throught this, any help is greatly appreciated!

TypeError: Music is not a constructor

When I try to run the example code in release 1.6 I get the error TypeError: Music is not a constructor on the line const music = new Music(bot, {. I have made sure to install the discord.js-musicbot-addon package with npm, and I declare const Music right above the line that declares const music.

I've tried copying the code from advancedMusicBot.js into my code, I got the error, and I have tried running basicMusicBot.js with the same error. I haven't made any changes to the code.

Version 11.4.2 of Discord.js
Version 8.11.4 of Node.js

Help command improve

Add a way to exempt a command from the help menu or change up the help menu for that command

How can i fix this :(

Describe the bug
if i adding music or use different commend
occurs error in node.js

Error: Dispatcher SetLast: no server queue
at musicbot.setLast.then.catch (C:\Users\user\node_modules\discord.js-musicbot-addon\index.js:2142:36)
at
at process._tickCallback (internal/process/next_tick.js:188:7)

Screenshots

Versions
windows10 pro
Discord.js Version : 11.3.2
Node.js version : 8.11.2

k-003

Error: spawn UNKNOWN

I'm getting this error in the console anytime I try to play/search for anything:

{ Error: spawn UNKNOWN at _errnoException (util.js:1041:11) at ChildProcess.spawn (internal/child_process.js:325:11) at exports.spawn (child_process.js:493:9) at exports.execFile (child_process.js:208:15) at call (C:\discord.js\node_modules\youtube-dl\lib\youtube-dl.js:163:5) at Function.getInfo (C:\discord.js\node_modules\youtube-dl\lib\youtube-dl.js:285:5) at msg.channel.send.then.response (C:\discord.js\node_modules\discord.js-musicbot-addon\index.js:255:14) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) code: 'UNKNOWN', errno: 'UNKNOWN', syscall: 'spawn' }

pause cmd when no music playing crashes

if (dispatcher.paused) return msg.channel.send(musicbot.note(fail, Music already paused!));

2018-06-22T22:51:20.320364+00:00 app[worker.1]: ^

2018-06-22T22:51:20.320366+00:00 app[worker.1]:

2018-06-22T22:51:20.320368+00:00 app[worker.1]: TypeError: Cannot read property 'paused' of undefined

^^missing npm module?

Playing url

When putting in a URL as the song name it searches for the URL. Could the URL just be added to the queue?

Features: commandCooldown & disablePlaylists & maxPerUser

1.) Make a commandCooldown option so each user can only do a music command every X seconds so that people can't spam songs.

2.) Make an option to disable playlists so people can't fill up the queue.

3.) Maybe, if possible, add an options to have a max amount requested by one user in the playlist at any given time. (So if the max queue size is 20, you can set the maxPerUser to 5 so that each person can only have 5 of their songs in the queue at any time)

Loop Bug + Feature Request

Is your feature request related to a problem? Please describe.
Yeah, basically if you type the loop command 3 or more times, afterwards it'll just keep saying that loop is disabled.

Describe the solution you'd like
change the command to this.
loop all - loops all of the queue.
loop one - loops one.
loop off - turns off loop.

Describe alternatives you've considered
maybe after the 3rd answer of how loop is disabled, make loop enable for 1 single song at 4th time and 5th be loop all, then 6th be loop disabled again. idk if you get what i mean

Command aliases dont get mapped properly?

When using e.g. helpAlt: ['mh'], the process crashes when trying to use the command alias (mh).
Error is:

node_modules/discord.js-musicbot-addon/index.js:756
        if (!aCmd.disabled) return musicbot[aCmd.run](msg, suffix, args);
                  ^

TypeError: Cannot read property 'disabled' of undefined

Edit: with logging enabled, it prints out
[MUSIC] Mapping aliase for musichelp, mh

TypeError: Music is not a constructor

The issue
I get the error :

const music = new Music(bot, {
               ^
TypeError: Music is not a constructor

i think that mean that i don't have to put the "new" before the constant content ... but ... it's not a function ... and in your example for module there is the "new"
PS: sorry for my bad english

Code

const Discord = require("discord.js");
const Music = require('discord.js-musicbot-addon');
const bot = new Discord.Client();
// some other required module
const music = new Music(bot, {
    prefix: "-",
    ownerOverMember: true,
    botOwner: "269557086667538433",
    botAdmins: ["269557086667538433"],
    maxQueueSize: "50",
    defVolume: 100,
    anyoneCanSkip: true,
    disableLoop: true,
    youtubeKey: process.env.YT_API_KEY
});
// some variables and constants
bot.login(token);

Versions

  • OS/Env/Hosting Service: heroku / linux
  • Module version: 12.0.6
  • Discord.js version: 11.3.2
  • Node.js version: 8.11.3

Prefix not working

const music = new Music(client, {
botPrefix: "?",
...
});

^ not working, prefix is still "!" and only that.

Error when requesting or searching for music

Describe the bug
When I run my bot, it show this error:
_(node:4404) UnhandledPromiseRejectionWarning: Error: Error code: 403
at ClientRequest.response (C:\Users\Student\Downloads\discord music bot\node
_modules\ytsearcher\lib\struct\YTSearch.js:92:23)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:544:21
)
at HTTPParser.parserOnHeadersComplete (_http_common.js:117:17)
at TLSSocket.socketOnData (_http_client.js:440:20)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at addChunk (stream_readable.js:263:12)
(node:4404) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This
error originated either by throwing inside of an async function without a catch
block, or by rejecting a promise which was not handled with .catch(). (rejection
id: 1)
(node:4404) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre
cated. In the future, promise rejections that are not handled will terminate the
Node.js process with a non-zero exit code.

My index.js code:

// @ts-nocheck
const Discord = require("discord.js"); // Require the Discord.js library.
const token = process.env.token;
//const youtubeapikeyyay = process.env.youtube-api-key
//const ffmpeg = require("./ffmpeg.exe")

class Bot extends Discord.Client {
constructor(options) {
super(options);
this.music = require("discord.js-musicbot-addon");
}
}
const client = new Bot();

client.music.start(client, {
botPrefix: "??",
youtubeKey: "AIzaSyCvCZFaboMS0n-YmT9I2aO5JnNnxgEyQOw" // Set the api key used for YouTube.
});

client.login(token); // Connect the bot.

(Technically your example script.)

Do you know what is wrong?

Expected behavior
I expected it to play music.

Versions

  • OS: Windows 7/Heroku
  • Module version: 13.0.1
  • Discord.js version: 11.4.2
  • Node.js version: 8.12.0

Additional context
I have ffmpeg added to my PATH.

Crashes on Search and Play

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'type' of undefined
2018-06-25T06:25:24.821018+00:00 app[worker.1]: at exports.determineType.type (/app/node_modules/ytsearcher/lib/deps/determineType.js:11:57)

Help

Repetitive Messages

Describe the bug
When I use >play musicname, it send multiple messages that it was queued.

To Reproduce
I dont know if this happens only to me... But I use it normally and it just repeats the messages..

Expected behavior
Play Music normally.

Screenshots
Uploading image.png…

Versions

  • Windows 8.1/Glitch.com Hosting.
  • "discord.js-music-v11": "^1.3.4",
  • "discord.js": "^11.3.2",
  • "node": "10.x"

Additional context
You can DM me at Alphi#9839 (discord). For more info.

Crashing when requesting music

I've (hopefully) installed the bot correctly. After a bit of tinkering with the code to load the bot, I got it to load without crashing and join the discord server. When I typed in the music command and requested a song, the bot joined the channel and promptly crashed, here's the logs:

(node:7480) ExperimentalWarning: The http2 module is an experimental API.
[Start] Mon Nov 06 2017 20:55:55 GMT-0500 (Eastern Standard Time)
events.js:183
throw er; // Unhandled 'error' event
^

TypeError: Invalid non-string/buffer chunk
at validChunk (_stream_writable.js:254:10)
at PassThrough.Writable.write (_stream_writable.js:288:21)
at PassThrough.Writable.end (_stream_writable.js:553:10)
at emitThree (events.js:141:20)
at DestroyableTransform.emit (events.js:217:7)
at emitThree (events.js:136:13)
at FfmpegCommand.emit (events.js:217:7)
at emitEnd (C:\Users\Erin\Desktop\Bot ideas\MuffinBot™\node_modules\fluent-ffmpeg\lib\processor.js:424:16)
at C:\Users\Erin\Desktop\Bot ideas\MuffinBot™\node_modules\fluent-ffmpeg\lib\processor.js:433:16
at C:\Users\Erin\Desktop\Bot ideas\MuffinBot™\node_modules\async\dist\async.js:421:16

(P.S. the TM is a joke and the bot is meant for a private server)

I'm getting errors. What version of Node and other environments are you running?

events.js:182
throw er; // Unhandled 'error' event
^

TypeError: Invalid non-string/buffer chunk
at validChunk (_stream_writable.js:254:10)
at PassThrough.Writable.write (_stream_writable.js:288:21)
at PassThrough.Writable.end (_stream_writable.js:553:10)
at emitThree (events.js:140:20)
at DestroyableTransform.emit (events.js:216:7)
at emitThree (events.js:135:13)
at FfmpegCommand.emit (events.js:216:7)
at emitEnd (/home/luis/Haruhi Bot/node_modules/fluent-ffmpeg/lib/processor.js:424:16)
at /home/luis/Haruhi Bot/node_modules/fluent-ffmpeg/lib/processor.js:433:16
at /home/luis/Haruhi Bot/node_modules/async/dist/async.js:421:16

Crash involving the skip command.

The bot crashed when skipping. I get this to happen every time by having it play a playlist (I think if you queue a few songs yourself it will still work) and then spamming the skip command a few times. Here is the error it spits out into my terminal:

/home/erikr/Workspace/Winston/node_modules/discord.js-musicbot-addon/index.js:488
dispatcher.end();
^

TypeError: Cannot read property 'end' of undefined
at skip (/home/erikr/Workspace/Winston/node_modules/discord.js-musicbot-addon/index.js:488:13)
at CommandoClient.client.on.msg (/home/erikr/Workspace/Winston/node_modules/discord.js-musicbot-addon/index.js:219:13)
at emitOne (events.js:120:20)
at CommandoClient.emit (events.js:210:7)
at MessageCreateHandler.handle (/home/erikr/Workspace/Winston/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/erikr/Workspace/Winston/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (/home/erikr/Workspace/Winston/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:330:35)
at WebSocketConnection.onMessage (/home/erikr/Workspace/Winston/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:293:17)
at WebSocket.onMessage (/home/erikr/Workspace/Winston/node_modules/ws/lib/EventTarget.js:99:16)
at emitOne (events.js:115:13)

(My bot is named Winston) For now, I've just told people to just use the clearqueue command, but I know some people will still spam that. :/ I'll see about looking into this myself during my free time. Anyways, here's my bug report.

TypeError: Cannot read property 'url' of undefined

Whenever I typed the play command followed by a song name or URL,
I get this error:

Error: Dispatcher SetLast: no server queue
    at musicbot.setLast.then.catch (C:\Discord\node_modules\discord.js-musicbot-addon\index.js:2141:36)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

TypeError: Cannot read property 'url' of undefined
    at Promise.then.connection (C:\Discord\node_modules\discord.js-musicbot-addon\index.js:2150:61)
    at <anonymous>

Error: Dispatcher SetLast: no server queue
    at musicbot.setLast.then.catch (C:\Discord\node_modules\discord.js-musicbot-addon\index.js:2141:36)
    at <anonymous>

Screenshot: http://prntscr.com/koi4g0

Playlist Support

It would be great of this had support for queueing an entire Youtube playlist. I don't have a lot of experience with JS or the YouTube API, but I'll see about adding this myself if I can find the free time. Thanks for this addon though, it has helped me a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.