izy521 / discord.io

A small, single-file library for creating DiscordApp clients from Node.js or the browser
https://discord.gg/0MvHMfHcTKVVmIGP
MIT License
535 stars 155 forks source link

Discord.Client() throws error #286

Closed egtoney closed 6 years ago

egtoney commented 6 years ago

Not sure what's going on but doesn't seem to be working. Let me know if you need anything else :+1:

node version: v10.9.0

error:

TypeError: Cannot read property 'bind' of undefined
    at Object.DiscordClient [as Client] (/Users/.../node_modules/discord.io/lib/index.js:64:30)

code:

const Discord = require('discord.io')

const bot = Discord.Client({
    token: "${secret_token}",
    autorun: true
})

attempted versions:

npm install discord.io
npm install izy521/discord.io
npm install Woor/discord.io#gateway_v6
Peacerekam commented 6 years ago

assuming secret_token is defined, replace " with ` when using template literals actually turns out you are missing "new" before "Discord.Client"

var secret_token = "1111111111111"
const bot = new Discord.Client({
    token: `${secret_token}`,
    autorun: true
})

or

var secret_token = "1111111111111"
const bot = new Discord.Client({
    token: secret_token,
    autorun: true
})

or just

const bot = new Discord.Client({
    token: "1111111111111",
    autorun: true
})
egtoney commented 6 years ago

Rofl yeah that worked. Thanks! Sorry, can't believe I missed that 😂