Git Product home page Git Product logo

discordjs / discord.js Goto Github PK

View Code? Open in Web Editor NEW
24.8K 24.8K 3.9K 47.9 MB

A powerful JavaScript library for interacting with the Discord API

Home Page: https://discord.js.org

License: Apache License 2.0

JavaScript 35.12% TypeScript 61.55% CSS 0.05% Dockerfile 0.02% Lua 0.01% MDX 3.17% Handlebars 0.08%
bot discord discord-api discord-bot discord-server discordjs hacktoberfest nodejs voice-support

discord.js's People

Contributors

abalabahaha avatar advaith1 avatar aemino avatar almeidx avatar almostsouji avatar amishshah avatar appellation avatar bdistin avatar ckohen avatar devsnek avatar didinele avatar gawdl3y avatar icrawl avatar imranbarbhuiya avatar imrodry avatar ishibi avatar izexi avatar jaw0r3k avatar jiralite avatar kyranet avatar lewdcario avatar meew0 avatar monbrey avatar muchnameless avatar notsugden avatar qjuh avatar spaceeec avatar suneettipirneni avatar vaporoxx avatar vladfrangu avatar

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  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

discord.js's Issues

getBans() users returns null/undefined

if (message.channel.server.id === '102588320181125120' && message.author.id === '102529479179509760') {
        if (message.content === '!command bans') {
            console.log('This test function worked');
            bot.getBans(message.channel.server, function (error, users) {
                console.log('RANS');
                if (error) {
                    console.log('ERRORED');
                    bot.reply(message, 'I do not have the necessary permissions');
                    return;
                }
                console.error('users: ' + users);
                console.error('error: ' + error);
                console.log('users: ' + users);
                console.log('error: ' + error);
                bot.reply(message, 'bans: ' + users.toString());
            });
        }
    }
console.log('users: ' + users);  undefined
console.log('error: ' + error);  undefined
console.error('users: ' + users);   null
console.error('error: ' + error);   null

This makes me unable to get the ban list of a server even when I have perms.

(indev branch) entrypoint.js crashes on older node versions

In entrypoint.js it has a message saying that it is not supported by versions < 0.12.7. But even on version 0.12.7, it crashes on this file as it uses the new ES6 template literal for the multiline string. Requiring 'lib/index.js' manually still works as intended as it is all compiled into ES5 past that point.

(audio playback doesn't work properly for me on node >=v4, so I have to stick to 0.12.x)

Stream returned by playRawStream does not terminate properly

The problem roots from here: https://github.com/hydrabolt/discord.js/blob/master/src/Voice/VoiceConnection.js#L99

When the stream ended stream.read will always return null, therefor it will keep calling the send function via setTimeout.

Furthermore the condition buffer.length !== 1920 will never be satisfied as stream.read will return null if the request amount of bytes was not supplied.

Instead you may want to listen to the end event of the input stream and terminate your stream accordingly.

Generally it might be worth simply attaching a data listener to the input stream rather than manually polling the input stream.

Channel Mention

Embedding a Channel Object in a message produces the channel name as a string, not a ChannelMention.

Todays update has made it so bots can't login

Hey, so my bot was working fine, and since the update to discord this morning, my bot is unable to login. I get the following issue :

Alexs-iMac:Kanye-Bot alextrott$  node index.js
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: unable to verify the first certificate
    at Error (native)
    at TLSSocket.<anonymous> (_tls_wrap.js:929:36)
    at TLSSocket.emit (events.js:104:17)
    at TLSSocket._finishInit (_tls_wrap.js:460:8)

Is there a quick fix for this?

Listing users currently in a voice channel.

I'm trying to get a list of users that are currently in a voice channel, but there doesn't seem to be a way to do this. For text channels you can get a list of members of the server and check the permissions of each one, but this doesn't work for voice channels.

updateRole clears out all permissions

Doing some fairly simple code:

hexcode_ = contentsplit[contentlength - 1].toString();
hexcode= parseInt(hexcode_, 16)
bot.updateRole(role1, {
     color: hexcode,
 })

Sets all permissions for that role to false. Name and hoist are unaffected, color is changed as supposed

banMember not working

Can't ban a user and delete history for 1 day. It says 404 Error Not Found

mybot.banMember("xxx", "xxx", 1, function(err) {
              console.log(err);
            })
{ [Error: Not Found]
  original: null,
  response: 
   Response {
     domain: null,
     _events: {},
     _eventsCount: 0,
     _maxListeners: undefined,
     res: 
      IncomingMessage {
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 4,
        _maxListeners: undefined,
        socket: [Object],
        connection: [Object],
        httpVersionMajor: 1,
        httpVersionMinor: 1,
        httpVersion: '1.1',
        complete: true,
        headers: [Object],
        rawHeaders: [Object],
        trailers: {},
        rawTrailers: [],
        upgrade: false,
        url: '',
        method: null,
        statusCode: 404,
        statusMessage: 'NOT FOUND',
        client: [Object],
        _consuming: true,
        _dumped: false,
        req: [Object],
        text: '{"message": ""}',
        read: [Function],
        body: [Object] },
     request: 
      Request {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        _agent: false,
        _formData: null,
        method: 'PUT',
        header: {},
        writable: true,
        _redirects: 0,
        _maxRedirects: 5,
        cookies: '',
        qs: [Object],
        qsRaw: [],
        _redirectList: [],
        req: [Object],
        protocol: 'https:',
        host: 'discordapp.com',
        _callback: [Function],
        res: [Object],
        response: [Circular],
        _timeout: 0,
        called: true },
     req: 
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 3,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 297,
        writable: true,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedHeader: {},
        _contentLength: 0,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Object],
        connection: [Object],
        _headers: [Object],
        _headerNames: [Object],
        _onPendingData: null,
        agent: [Object],
        socketPath: undefined,
        method: 'PUT',
        parser: null,
        res: [Object] },
     links: {},
     text: '{"message": ""}',
     body: { message: '' },
     files: {},
     buffered: true,
     headers: 
      { server: 'cloudflare-nginx',
        date: 'Sun, 22 Nov 2015 14:49:00 GMT',
        'content-type': 'application/json',
        'content-length': '15',
        connection: 'close',
        'set-cookie': [Object],
        'cf-railgun': '28c13d1e3f stream 0.000000 0200 3350',
        'cf-ray': '2495703ed81031c8-SIN' },
     header: 
      { server: 'cloudflare-nginx',
        date: 'Sun, 22 Nov 2015 14:49:00 GMT',
        'content-type': 'application/json',
        'content-length': '15',
        connection: 'close',
        'set-cookie': [Object],
        'cf-railgun': '28c13d1e3f stream 0.000000 0200 3350',
        'cf-ray': '2495703ed81031c8-SIN' },
     statusCode: 404,
     status: 404,
     statusType: 4,
     info: false,
     ok: false,
     redirect: false,
     clientError: true,
     serverError: false,
     error: 
        status: 404,
        text: '{"message": ""}',
        method: 'PUT',
     accepted: false,
     noContent: false,
     badRequest: false,
     unauthorized: false,
     notAcceptable: false,
     forbidden: false,
     notFound: true,
     type: 'application/json',
     setEncoding: [Function: bound ],
     redirects: [] },
  status: 404 }
Da King--1
{ [Error: Not Found]
  original: null,
  response: 
   Response {
     domain: null,
     _events: {},
     _eventsCount: 0,
     _maxListeners: undefined,
     res: 
      IncomingMessage {
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 4,
        _maxListeners: undefined,
        socket: [Object],
        connection: [Object],
        httpVersionMajor: 1,
        httpVersionMinor: 1,
        httpVersion: '1.1',
        complete: true,
        headers: [Object],
        rawHeaders: [Object],
        trailers: {},
        rawTrailers: [],
        upgrade: false,
        url: '',
        method: null,
        statusCode: 404,
        statusMessage: 'NOT FOUND',
        client: [Object],
        _consuming: true,
        _dumped: false,
        req: [Object],
        text: '{"message": ""}',
        read: [Function],
        body: [Object] },
     request: 
      Request {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        _agent: false,
        _formData: null,
        method: 'PUT',
        header: {},
        writable: true,
        _redirects: 0,
        _maxRedirects: 5,
        cookies: '',
        qs: [Object],
        qsRaw: [],
        _redirectList: [],
        req: [Object],
        protocol: 'https:',
        host: 'discordapp.com',
        _callback: [Function],
        res: [Object],
        response: [Circular],
        _timeout: 0,
        called: true },
     req: 
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 3,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 297,
        writable: true,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedHeader: {},
        _contentLength: 0,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Object],
        connection: [Object],
        _headers: [Object],
        _headerNames: [Object],
        _onPendingData: null,
        agent: [Object],
        socketPath: undefined,
        method: 'PUT',
        parser: null,
        res: [Object] },
     links: {},
     text: '{"message": ""}',
     body: { message: '' },
     files: {},
     buffered: true,
     headers: 
      { server: 'cloudflare-nginx',
        date: 'Sun, 22 Nov 2015 14:53:36 GMT',
        'content-type': 'application/json',
        'content-length': '15',
        connection: 'close',
        'set-cookie': [Object],
        'cf-railgun': '2360287199 stream 0.000000 0200 3350',
        'cf-ray': '249576fefec71141-SIN' },
     header: 
      { server: 'cloudflare-nginx',
        date: 'Sun, 22 Nov 2015 14:53:36 GMT',
        'content-type': 'application/json',
        'content-length': '15',
        connection: 'close',
        'set-cookie': [Object],
        'cf-railgun': '2360287199 stream 0.000000 0200 3350',
        'cf-ray': '249576fefec71141-SIN' },
     statusCode: 404,
     status: 404,
     statusType: 4,
     info: false,
     ok: false,
     redirect: false,
     clientError: true,
     serverError: false,
     error: 
        status: 404,
        text: '{"message": ""}',
        method: 'PUT',
     accepted: false,
     noContent: false,
     badRequest: false,
     unauthorized: false,
     notAcceptable: false,
     forbidden: false,
     notFound: true,
     type: 'application/json',
     setEncoding: [Function: bound ],
     redirects: [] },
  status: 404 }

CheckQueue

Noticed you removed the CheckQueue function from the client scripts, but are still calling it in updateMessage, sendFile and sendMessage functions. This breaks these functions. Is there a solution to this other than manually copying the old checkqueue function back in the client scripts?

Browser?

How do you get this in the browser like the website?

Type Error when requiring discord.js

I have tried install discord.js from npm install discord.js and I have cloned the repo in both cases I am never able to run a bot. I have python 2.7.6 installed and this is on Linux.

I followed this tutorial after install via npm and receive the below error.
http://discordjs.readthedocs.org/en/latest/create_simple_bot.html

*/node_modules/discord.js/lib/Client.js:2
){if(typeof superClass !== "function" && superClass !== null){throw new TypeEr
                                                                    ^
TypeError: Super expression must either be null or a function, not object
    at _inherits (*/node_modules/discord.js/lib/Client.js:2:789)
    at */node_modules/discord.js/lib/Client.js:3:153
    at Object.<anonymous> (*/node_modules/discord.js/lib/Client.js:79:1927)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (*/node_modules/discord.js/lib/index.js:1:161)

Playing sound files

I want to have a file that upon command, plays through my VLC. Any ideas?

unbanMember() uses error callback even when successful

if (mSplit[1] === 'unban') {
                bot.unbanMember(cleanID(mSplit[2]), message.channel.server.id, function (error) {
                    if (error) {
                        bot.reply(message, error);
                        return;
                    }
                    bot.reply(message, "I've unbanned: " + mSplit[2] + " from: " + message.channel.server.id);
                });
            }

On error bot replies with [object object]
On success bot replies with [object object] as it uses the error callback instead of success

Image of chat

"Connections" such as Twitch and future services

are any of the new 'Connections' features that Discord just implemented coming thru the API as of yet? as of right now, only Twitch is supported, but others will be made available in the future.

I hope to tie our Twitch IRC bot into Discord as well using Discord.js, and am rewriting the bot to make use of both independently, as well as a user manager. I am going to add in a way for users to in effect link their accounts at the bot level, but if any of the Twitch information is passed along via their API, and thru Discord.js, that could save quite a bit of time.

User VoiceConnection from Message is Null

It seems when I get a user from a message, who is connected to a voice channel, I get null when using:

message.author.voiceConnection

I was going to fork and see if I can find out why, but figured I would submit a bug first to see if it is just me.

Improve the Discord.JS docs

Hello,
This is an enhancement request for discord.js. As the title says, I think the docs need a little bit more improvment, mostly on how to start writing your bot and fixing common errors (I know most of you will say that everyone can do that, but most people are noobs at programming, but they may want to create their own bot too. Try to help them)

[Question] VoiceChannel Stream

I am attempting to now stream to the discord server. After connecting to the Voice Channel, I can use 'connection' to do 'playStream(stream)' but what is it wanting exactly? I used 'playRawStream(stream, callback)' but it did not seem to start speaking on the server. Is there something I am missing?

Here is a snippet of my current code:

          myBot.joinVoiceChannel(myBot.channels[channelId], function (err, connection) {
            if(err) console.error("Error joining Voice Channel:\n   " + err);

            console.log("Starting Radio");
            Icy.get(settings.radioCast, function (res) {
  //            console.error(res.headers);

              res.on('metadata', function (metadata) {
                var parsed = Icy.parse(metadata);
                console.info(parsed);
              });

//              var dec = res.pipe(new Lame.Decoder()).pipe(connection.playRawStream());
              connection.playStream(res, function(err, str){console.log(err); console.log(str)});

I apologize if this is annoying. There is no documentation on this and I would like to get it working sooner rather then later.

Message author sometimes null

This will be fixed in version 5.0.0, where caching and other things are heavily improved. It is also a breaking change so I do not recommend updating to it immediately when it is released.

Error on trying to log in

/Users/aaron/Projects/discord-server-list/js-bot/node_modules/discord.js/lib/Client.js:67
nce=_ref13;var user=self.getUser("id",presence.user.id);user.status = presence
                                                                    ^
TypeError: Cannot set property 'status' of null
    at Client.addServer (/Users/aaron/Projects/discord-server-list/js-bot/node_modules/discord.js/lib/Client.js:67:1249)
    at WebSocket.websocket.onmessage (/Users/aaron/Projects/discord-server-list/js-bot/node_modules/discord.js/lib/Client.js:41:425)
    at WebSocket.onMessage (/Users/aaron/Projects/discord-server-list/js-bot/node_modules/ws/lib/WebSocket.js:414:14)
    at WebSocket.emit (events.js:110:17)
    at Receiver.ontext (/Users/aaron/Projects/discord-server-list/js-bot/node_modules/ws/lib/WebSocket.js:797:10)
    at /Users/aaron/Projects/discord-server-list/js-bot/node_modules/ws/lib/Receiver.js:473:18
    at Receiver.applyExtensions (/Users/aaron/Projects/discord-server-list/js-bot/node_modules/ws/lib/Receiver.js:360:5)
    at /Users/aaron/Projects/discord-server-list/js-bot/node_modules/ws/lib/Receiver.js:462:14
    at Receiver.flush (/Users/aaron/Projects/discord-server-list/js-bot/node_modules/ws/lib/Receiver.js:336:3)
    at Receiver.opcodes.1.finish (/Users/aaron/Projects/discord-server-list/js-bot/node_modules/ws/lib/Receiver.js:478:12)

Not sure what's happening

Using stopPlaying() while a video directly streamed from ytdl is playing causes a crash

The crash report:

/home/miras/Projects/lethe/node_modules/discord.js/lib/Voice/VoiceConnection.js:71
            this.instream.destroy();
                          ^

TypeError: this.instream.destroy is not a function
    at VoiceConnection.stopPlaying (/home/miras/Projects/lethe/node_modules/discord.js/lib/Voice/VoiceConnection.js:71:18)
    at playStopped (/home/miras/Projects/lethe/lethe.js:303:72)
    at Client.<anonymous> (/home/miras/Projects/lethe/lethe.js:71:5)
    at emitOne (events.js:77:13)
    at Client.emit (events.js:169:7)
    at WebSocket.websocket.onmessage (/home/miras/Projects/lethe/node_modules/discord.js/lib/Client/InternalClient.js:1056:14)
    at WebSocket.onMessage (/home/miras/Projects/lethe/node_modules/ws/lib/WebSocket.js:414:14)
    at emitTwo (events.js:92:20)
    at WebSocket.emit (events.js:172:7)
    at Receiver.ontext (/home/miras/Projects/lethe/node_modules/ws/lib/WebSocket.js:797:10)

Offending lines of code:
https://github.com/meew0/Lethe/blob/adcf966759bc685e9d38ddf6a57af49b3bb34685/lethe.js#L303 (stream is stopped)
https://github.com/meew0/Lethe/blob/adcf966759bc685e9d38ddf6a57af49b3bb34685/lib/youtube-stream.js#L11 (stream is requested)
https://github.com/fent/node-ytdl-core/blob/master/lib/index.js#L26 (stream is created)

Volume setting for voice encoding

Would like to request for a volume setting for ffmpeg/avconv encoding for the voice section. By default it can be very loud, so a volume setting could be nice so new members to a voice chat don't get their ears blasted. I've located a volume=1 and this could be changed to allow a variable setting in a func such as setVolume().

Edit: https://github.com/hydrabolt/discord.js/blob/master/src/Voice/AudioEncoder.js#L51 location of code
Edit2: https://github.com/hydrabolt/discord.js/blob/master/src/Voice/AudioEncoder.js#L90 oh and of course the encodeFile

(indev branch) Voice stopPlaying() seems to crash

So on the indev branch, when I try to do voiceConnection.stopPlaying() it crashes with a Error: write EPIPE on my computer - Windows 10 x64, node.js v0.12.9. However this only happens with the new 'fix' that was implemented in the indev branch to kill the ffmpeg/avconv processes when they were done. But this 'fix' only broke my ability to use the stopPlaying(). Upon commenting out this line it fixes the issue, but as you know it can leave ffmpeg running as a child process.

I'm still trying to find a fix for it, I'll keep this posted if I do find one. I suspect it may be because of the SIGINT being sent that is not handled properly on Windows? Just commenting out that line still crashes it, I have to comment out the whole block to allow it to run normally. That's not good as ffmpeg.exe does keep running in the background.

The line(s) causing it in the new indev update is here - https://github.com/hydrabolt/discord.js/blob/indev/lib/Voice/VoiceConnection.js#L94-L98

The full error stack I encountered is below:

Error: write EPIPE
  at exports._errnoException (util.js:746:11)
  at Socket._writeGeneric (net.js:692:26)
  at Socket._write (net.js:711:8)
  at doWrite (_stream_writable.js:301:12)
  at writeOrBuffer (_stream_writable.js:288:5)
  at Socket.Writable.write (_stream_writable.js:217:11)
  at Socket.write (net.js:636:40)
  at ReadStream.ondata (_stream_readable.js:540:20)
  at ReadStream.emit (events.js:107:17)
  at ReadStream.Readable.read (_stream_readable.js:373:10)
  at flow (_stream_readable.js:750:26)
  at Socket.<anonymous> (_stream_readable.js:607:7)
  at Socket.emit (events.js:104:17)
  at onwriteDrain (_stream_writable.js:371:12)
  at afterWrite (_stream_writable.js:359:5)
  at onwrite (_stream_writable.js:352:7)
  at Socket.WritableState.onwrite (_stream_writable.js:105:5)
  at WriteWrap.afterWrite (net.js:789:12)

Update: It also happens when I run it on an Ubuntu VM

'presence' event not firing on join/leave game

Howdy. Not sure if the Client's 'presence' event is firing properly.

client.on('presence', (user, status, gameId) => {
  console.log('presence', user, status, gameId);
});

This event fires when a user logs in, but does not seem to fire when joining or leaving a game.

If I manually log the 'raw' event when joining or leaving a game, I do see a 'PRESENCE_UPDATE' value in the message:

client.on('raw', (thing) => {
  console.log(thing);
});

Both script and test user both running from same machine, using Win10 with the nov 6th release of Discord (not sure how to find version info with the app?) and Node v5.1.0

message should include Server object

If a message is sent over a text channel in a server it should include the server object. This would really simplify using server permissions for things like custom commands.

SSL Certificate issue

I'm aware that there is an issue for some users on connecting, I'm looking into it

[indev] Cannot read property 'error' of undefined (in InternalClient.js)

I'm randomly getting this error sometimes:

C:\Users\MadScripter\Desktop\#PROGRAMMING\NodeJS\Projects\Discord_Bot\node_modules\discord.js\lib\Client\InternalClient.js:135
                    error.response.error.status = 429;
                                  ^

TypeError: Cannot read property 'error' of undefined
    at C:\Users\MadScripter\Desktop\#PROGRAMMING\NodeJS\Projects\Discord_Bot\node_modules\discord.js\lib\Client\InternalClient.js:135:20
    at Request.callback (C:\Users\MadScripter\Desktop\#PROGRAMMING\NodeJS\Projects\Discord_Bot\node_modules\superagent\lib\node\index.js:784:12)
    at ClientRequest.<anonymous> (C:\Users\MadScripter\Desktop\#PROGRAMMING\NodeJS\Projects\Discord_Bot\node_modules\superagent\lib\node\index.js:738:10)
    at emitOne (events.js:78:13)
    at ClientRequest.emit (events.js:170:7)
    at TLSSocket.socketErrorListener (_http_client.js:266:9)
    at emitOne (events.js:78:13)
    at TLSSocket.emit (events.js:170:7)
    at connectErrorNT (net.js:999:8)
    at nextTickCallbackWith2Args (node.js:455:9)

Stream playback is slow

I am streaming music to the room but the BPM is like 10. Is that because of my decoding or because how Discord.js is putting out to the server?

Here is the code:

            Icy.get(settings.radioCast, function (res) {

              var dec = res.pipe(new Lame.Decoder());
              room.playStream(dec, function(err, str) {
                if(err) console.log(err);
                console.log(str)
              });

            });

Crash receiving private messages

It seems there's none server when receiving private messages and this causes an error.

first message's error log:

./node_modules/discord.js/lib/channel.js:43
                    throw _iteratorError;
                    ^

TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined
    at new Channel (./node_modules/discord.js/lib/channel.js:26:60)
    at Client.addChannel (./node_modules/discord.js/lib/Client.js:1189:28)
    at WebSocket.websocket.onmessage (./node_modules/discord.js/lib/Client.js:1016:25)
    at WebSocket.onMessage (./node_modules/ws/lib/WebSocket.js:414:14)
    at emitTwo (events.js:87:13)
    at WebSocket.emit (events.js:172:7)
    at Receiver.ontext (./node_modules/ws/lib/WebSocket.js:797:10)
    at ./node_modules/ws/lib/Receiver.js:473:18
    at Receiver.applyExtensions (./node_modules/ws/lib/Receiver.js:360:5)
    at ./node_modules/ws/lib/Receiver.js:462:14

second and after error log:

./node_modules/discord.js/lib/message.js:23
        this.author = this.channel.server.getMember("id", author.id);
                                         ^

TypeError: Cannot read property 'getMember' of undefined
    at new Message (./node_modules/discord.js/lib/message.js:23:36)
    at WebSocket.websocket.onmessage (./node_modules/discord.js/lib/Client.js:876:37)
    at WebSocket.onMessage (./node_modules/ws/lib/WebSocket.js:414:14)
    at emitTwo (events.js:87:13)
    at WebSocket.emit (events.js:172:7)
    at Receiver.ontext (./node_modules/ws/lib/WebSocket.js:797:10)
    at ./node_modules/ws/lib/Receiver.js:473:18
    at Receiver.applyExtensions (./node_modules/ws/lib/Receiver.js:360:5)
    at ./node_modules/ws/lib/Receiver.js:462:14
    at Receiver.flush (./node_modules/ws/lib/Receiver.js:336:3)

User objects sometimes not storing avatar

As reported by some users and having experienced it myself, it's pretty annoying.

The User object sometimes does not give an avatar, and a simple relog can fix this. I'm having a look at it.

Issue streaming audio

Hello.

For the last week I've tried my best getting any kind of sound to be transmitted over a voice channel with this node module.

I've tried both with Windows, 32-bit and 64-bit and also with Ubuntu on my Raspberry Pi 2. Both Node v4 and v0.12.
I had some errors when running npm install on my Windows machine that I never got past, so that's why I switched to Ubuntu. But I still experience problems.

I have avconv and opus installed (I think..) ffmpeg seems to be impossible to install on Ubuntu 14.03, or at least for me.

I've tried the playFile and playRawStream, trying both an MP3 file and a different WAV file. The avatar on my bot lights up green for a brief moment, as if audio is sent, but it disappears before I can hear anything.
Then I tried with a Shoutcast stream instead, to see if it was just some problems with the files. With the Shoutcast stream I get maybe half a second of really loud white noise before it just goes quiet again.

So, what am I missing? I feel really stupid because I've waited for someone else to report the same kind of problems that I'm experiencing, but I haven't seen anyone with the same issue as me.

Problem with user status updates.

I was having an issue with users Online/Offline status not being updated in the member's cache. I added the following line in InternalClient.js under case PacketType.PRESENCE_UPDATE and it seems to have fixed the issue.

data.user.status = data.user.status || user.status;

I'm not sure if this was the correct way to go about fixing it.

I can't Install Discord.js

//Sorry for my English i am French

The server said:
npm WARN ENOENT ENOENT: no such file or directory, open '/root/package.json'
npm WARN EPACKAGEJSON root No description
npm WARN EPACKAGEJSON root No repository field.
npm WARN EPACKAGEJSON root No README data
npm WARN EPACKAGEJSON root No license field.

http://i.imgur.com/G4QxK3a.png

CentOS Issue

When running Discord.js in CentOS I get this error

/home/server/myuser/node_modules/discord.js/lib/Voice/StreamIntent.js:9
f (typeof superClass !== "function" && superClass !== null) { throw new TypeEr
                                                                    ^
TypeError: Super expression must either be null or a function, not object
    at _inherits (/home/server/myuser/node_modules/discord.js/lib/Voice/StreamIntent.js:9:113)
    at /home/server/myuser/node_modules/discord.js/lib/Voice/StreamIntent.js:16:2
    at Object.<anonymous> (/home/server/myuser/node_modules/discord.js/lib/Voice/StreamIntent.js:25:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/server/myuser/node_modules/discord.js/lib/Voice/VoiceConnection.js:38:21)

banMember() uses error callback even when successful

if (mSplit[1] === 'ban') {
                bot.banMember(cleanID(mSplit[2]), message.channel.server.id,  mSplit[3], function (error) {
                    console.log('error: ' + error);
                    if (error) {
                        bot.reply(message, error);
                        return;
                    }
                    bot.reply(message, "I've banned: " + mSplit[2] + " from: " + message.channel.server.id);
                });
            }

On error bot replies with [object object]
On success bot replies with [object object] as it uses the error callback instead of success

Image of chat

channel of channelList

I'm not sure if it's a bug in the code from a Discord update or Azure, but I'm getting this error when I try to run any of the examples/etc.

D:\home\site\wwwroot\index.js:243
        for ( channel of channelList ) {
                      ^^
SyntaxError: Unexpected identifier
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

Client.login callback not working

Callback seems to be broken. Logs nothing.

var Discord = require('discord.js');
var bot = new Discord.Client();
bot.login('email', 'password', function(err, token) {
  if (err) {
    console.log(err);
  }
  console.log('Token below');
  console.log(token);
});

Roadmap

As Discord's V3 API is out, it makes sense to begin updating the API with support for that. In this process, I will also add member online/offline features and fix some bugs.

Because the API is brand new and without documentation, this may take some time.

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.