diff --git a/lib/Client/Client.js b/lib/Client/Client.js index 9f9f0841e..1973ef03b 100644 --- a/lib/Client/Client.js +++ b/lib/Client/Client.js @@ -44,7 +44,7 @@ var Client = (function (_EventEmitter) { }; /* - + def logout */ return Client; diff --git a/lib/Client/InternalClient.js b/lib/Client/InternalClient.js index dc16615c7..7d461d958 100644 --- a/lib/Client/InternalClient.js +++ b/lib/Client/InternalClient.js @@ -18,7 +18,8 @@ var User = require("../Structures/User.js"), TextChannel = require("../Structures/TextChannel.js"), VoiceChannel = require("../Structures/VoiceChannel.js"), PMChannel = require("../Structures/PMChannel.js"), - Server = require("../Structures/Server.js"); + Server = require("../Structures/Server.js"), + Message = require("../Structures/Message.js"); var zlib; @@ -41,6 +42,8 @@ var InternalClient = (function () { this.private_channels = new Cache(); } + // def login + InternalClient.prototype.login = function login(email, password) { var self = this; var client = self.client; @@ -60,6 +63,8 @@ var InternalClient = (function () { var token = res.body.token; self.state = ConnectionState.LOGGED_IN; self.token = token; + self.email = email; + self.password = password; self.getGateway().then(function (url) { @@ -78,6 +83,37 @@ var InternalClient = (function () { }); }; + InternalClient.prototype.logout = function logout() { + var _this = this; + + var self = this; + return new Promise(function (resolve, reject) { + + if (self.state === ConnectionState.DISCONNECTED || self.state === ConnectionState.IDLE) { + reject(new Error("Client is not logged in!")); + return; + } + + request.post(Endpoints.LOGOUT).set("authorization", self.token).end(function (err, res) { + if (err) { + reject(new Error(err.response.text)); + } else { + if (_this.websocket) { + _this.websocket.close(); + _this.websocket = null; + } + self.token = null; + self.email = null; + self.password = null; + self.state = ConnectionState.DISCONNECTED; + resolve(); + } + }); + }); + }; + + // def getGateway + InternalClient.prototype.getGateway = function getGateway() { var self = this; return new Promise(function (resolve, reject) { @@ -146,12 +182,34 @@ var InternalClient = (function () { switch (packet.t) { case PacketType.READY: - + var startTime = Date.now(); self.users.add(new User(data.user, client)); - data.guilds.forEach(function (server) { self.servers.add(new Server(server, client)); }); + data.private_channels.forEach(function (pm) { + self.private_channels.add(new PMChannel(pm, client)); + }); + self.state = ConnectionState.READY; + + setInterval(function () { + return self.sendWS({ op: 1, d: Date.now() }); + }, data.heartbeat_interval); + + client.emit("ready"); + client.emit("debug", "ready packet took " + (Date.now() - startTime) + "ms to process"); + client.emit("debug", "ready with " + self.servers.length + " servers, " + self.channels.length + " channels and " + self.users.length + " users cached."); + break; + + case PacketType.MESSAGE_CREATE: + // format: https://discordapi.readthedocs.org/en/latest/reference/channels/messages.html#message-format + var channel = self.channels.get("id", data.channel_id); + if (channel) { + + channel.messages.add(new Message(data, channel, client)); + } else { + client.emit("warn", "message created but channel is not cached"); + } break; diff --git a/lib/Constants.js b/lib/Constants.js index 88469eefb..35e948c93 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -96,7 +96,8 @@ var Permissions = { }; var PacketType = { - READY: "READY" + READY: "READY", + MESSAGE_CREATE: "MESSAGE_CREATE" }; exports.API_ENDPOINT = API; diff --git a/lib/Structures/Channel.js b/lib/Structures/Channel.js index 64086a57f..f8a141584 100644 --- a/lib/Structures/Channel.js +++ b/lib/Structures/Channel.js @@ -5,6 +5,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Equality = require("../Util/Equality.js"); +var Cache = require("../Util/Cache.js"); +var PermissionOverwrite = require("./PermissionOverwrite.js"); var Channel = (function (_Equality) { _inherits(Channel, _Equality); @@ -13,7 +15,6 @@ var Channel = (function (_Equality) { _classCallCheck(this, Channel); _Equality.call(this); - this.type = data.type || "text"; this.id = data.id; this.client = client; } diff --git a/lib/Structures/Message.js b/lib/Structures/Message.js new file mode 100644 index 000000000..1632efba4 --- /dev/null +++ b/lib/Structures/Message.js @@ -0,0 +1,38 @@ +"use strict"; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Cache = require("../Util/Cache.js"); +var User = require("./User.js"); + +var Message = function Message(data, channel, client) { + var _this = this; + + _classCallCheck(this, Message); + + this.channel = channel; + this.client = client; + + this.nonce = data.nonce; + this.attachments = data.attachments; + this.tts = data.tts; + this.embeds = data.embeds; + this.timestamp = Date.parse(data.timestamp); + this.everyoneMentioned = data.mention_everyone; + this.id = data.id; + + if (data.edited_timestamp) this.editedTimestamp = Date.parse(data.edited_timestamp); + this.author = client.internal.users.add(new User(data.author, client)); + this.content = data.content; + this.mentions = new Cache(); + + data.mentions.forEach(function (mention) { + // this is .add and not .get because it allows the bot to cache + // users from messages from logs who may have left the server and were + // not previously cached. + console.log(mention); + _this.mentions.add(client.internal.users.add(new User(mention, client))); + }); +}; + +module.exports = Message; \ No newline at end of file diff --git a/lib/Structures/PMChannel.js b/lib/Structures/PMChannel.js index 337a3cc79..73a047b23 100644 --- a/lib/Structures/PMChannel.js +++ b/lib/Structures/PMChannel.js @@ -1,5 +1,7 @@ "use strict"; +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } @@ -7,16 +9,31 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" var Channel = require("./Channel.js"); var Equality = require("../Util/Equality.js"); -var PMChannel = (function (_Channel) { - _inherits(PMChannel, _Channel); +var PMChannel = (function (_Equality) { + _inherits(PMChannel, _Equality); function PMChannel(data, client) { _classCallCheck(this, PMChannel); - _Channel.call(this, data, client); + _Equality.call(this); + this.client = client; + + this.type = data.type || "text"; + this.id = data.id; + this.lastMessageId = data.last_message_id; + this.recipient = this.client.internal.users.add(data.recipient); } + /* warning! may return null */ + + _createClass(PMChannel, [{ + key: "lastMessage", + get: function get() { + return this.messages.get("id", this.lastMessageID); + } + }]); + return PMChannel; -})(Channel); +})(Equality); module.exports = PMChannel; \ No newline at end of file diff --git a/lib/Structures/Server.js b/lib/Structures/Server.js index 7827a2b39..16acb6b09 100644 --- a/lib/Structures/Server.js +++ b/lib/Structures/Server.js @@ -10,7 +10,6 @@ var Equality = require("../Util/Equality.js"); var Endpoints = require("../Constants.js").Endpoints; var Cache = require("../Util/Cache.js"); var User = require("./User.js"); -var Member = require("./Member.js"); var TextChannel = require("./TextChannel.js"); var VoiceChannel = require("./VoiceChannel.js"); var Role = require("./Role.js"); @@ -38,10 +37,17 @@ var Server = (function (_Equality) { this.icon = data.icon; this.afkTimeout = data.afkTimeout; this.afkChannelID = data.afk_channel_id; + this.memberMap = {}; data.members.forEach(function (dataUser) { - var user = client.internal.users.add(new User(dataUser, client)); - _this.members.add(new Member(dataUser, client, self)); + _this.memberMap[dataUser.user.id] = { + roles: dataUser.roles, + mute: dataUser.mute, + deaf: dataUser.deaf, + joinedAt: Date.parse(dataUser.joined_at) + }; + var user = client.internal.users.add(new User(dataUser.user, client)); + _this.members.add(user); }); data.channels.forEach(function (dataChannel) { diff --git a/lib/Structures/ServerChannel.js b/lib/Structures/ServerChannel.js new file mode 100644 index 000000000..87f5472f7 --- /dev/null +++ b/lib/Structures/ServerChannel.js @@ -0,0 +1,30 @@ +"use strict"; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var Channel = require("./Channel.js"); +var Cache = require("../Util/Cache.js"); +var PermissionOverwrite = require("./PermissionOverwrite.js"); + +var ServerChannel = (function (_Channel) { + _inherits(ServerChannel, _Channel); + + function ServerChannel(data, client) { + var _this = this; + + _classCallCheck(this, ServerChannel); + + _Channel.call(this, data, client); + this.type = data.type; + this.permissionOverwrites = new Cache(); + data.permission_overwrites.forEach(function (permission) { + _this.permissionOverwrites.add(new PermissionOverwrite(permission)); + }); + } + + return ServerChannel; +})(Channel); + +module.exports = ServerChannel; \ No newline at end of file diff --git a/lib/Structures/TextChannel.js b/lib/Structures/TextChannel.js index 3ff7c445d..9e4e153a6 100644 --- a/lib/Structures/TextChannel.js +++ b/lib/Structures/TextChannel.js @@ -6,30 +6,22 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var Channel = require("./Channel.js"); +var ServerChannel = require("./ServerChannel.js"); var Cache = require("../Util/Cache.js"); -var PermissionOverwrite = require("./PermissionOverwrite.js"); -var TextChannel = (function (_Channel) { - _inherits(TextChannel, _Channel); +var TextChannel = (function (_ServerChannel) { + _inherits(TextChannel, _ServerChannel); function TextChannel(data, client) { - var _this = this; - _classCallCheck(this, TextChannel); - _Channel.call(this, data, client); + _ServerChannel.call(this, data, client); this.name = data.name; this.topic = data.topic; this.position = data.position; this.lastMessageID = data.last_message_id; this.messages = new Cache("id", client.options.maximumMessages); - - this.permissionOverwrites = new Cache(); - data.permission_overwrites.forEach(function (permission) { - _this.permissionOverwrites.add(new PermissionOverwrite(permission)); - }); } /* warning! may return null */ @@ -42,6 +34,6 @@ var TextChannel = (function (_Channel) { }]); return TextChannel; -})(Channel); +})(ServerChannel); module.exports = TextChannel; \ No newline at end of file diff --git a/lib/Structures/VoiceChannel.js b/lib/Structures/VoiceChannel.js index a60b3fdf0..20cf772c2 100644 --- a/lib/Structures/VoiceChannel.js +++ b/lib/Structures/VoiceChannel.js @@ -4,18 +4,18 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var Channel = require("./Channel.js"); +var ServerChannel = require("./ServerChannel.js"); -var VoiceChannel = (function (_Channel) { - _inherits(VoiceChannel, _Channel); +var VoiceChannel = (function (_ServerChannel) { + _inherits(VoiceChannel, _ServerChannel); function VoiceChannel(data, client) { _classCallCheck(this, VoiceChannel); - _Channel.call(this, data, client); + _ServerChannel.call(this, data, client); } return VoiceChannel; -})(Channel); +})(ServerChannel); module.exports = VoiceChannel; \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index ac6609b7a..b3ed7b420 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,6 +5,9 @@ module.exports = { }; var a = new module.exports.Client(); +a.on("debug", function (m) { + return console.log("[debug]", m); +}); a.login(process.env["discordEmail"], process.env["discordPass"])["catch"](function (e) { return console.log(e); }); \ No newline at end of file diff --git a/src/Client/Client.js b/src/Client/Client.js index 0ed7092d4..99948b755 100644 --- a/src/Client/Client.js +++ b/src/Client/Client.js @@ -35,7 +35,7 @@ class Client extends EventEmitter{ } /* - + def logout */ } diff --git a/src/Client/InternalClient.js b/src/Client/InternalClient.js index 57432f906..5f59db805 100644 --- a/src/Client/InternalClient.js +++ b/src/Client/InternalClient.js @@ -16,7 +16,8 @@ var User = require("../Structures/User.js"), TextChannel = require("../Structures/TextChannel.js"), VoiceChannel = require("../Structures/VoiceChannel.js"), PMChannel = require("../Structures/PMChannel.js"), - Server = require("../Structures/Server.js"); + Server = require("../Structures/Server.js"), + Message = require("../Structures/Message.js"); var zlib; @@ -36,7 +37,7 @@ class InternalClient { this.servers = new Cache(); this.private_channels = new Cache(); } - + // def login login(email, password) { var self = this; var client = self.client; @@ -59,6 +60,8 @@ class InternalClient { var token = res.body.token; self.state = ConnectionState.LOGGED_IN; self.token = token; + self.email = email; + self.password = password; self.getGateway().then((url) => { @@ -80,6 +83,38 @@ class InternalClient { }); } + logout() { + var self = this; + return new Promise((resolve, reject)=>{ + + if(self.state === ConnectionState.DISCONNECTED || self.state === ConnectionState.IDLE){ + reject(new Error("Client is not logged in!")); + return; + } + + request + .post(Endpoints.LOGOUT) + .set("authorization", self.token) + .end((err, res) => { + if(err){ + reject(new Error(err.response.text)); + }else{ + if(this.websocket){ + this.websocket.close(); + this.websocket = null; + } + self.token = null; + self.email = null; + self.password = null; + self.state = ConnectionState.DISCONNECTED; + resolve(); + } + }); + + }); + } + + // def getGateway getGateway() { var self = this; return new Promise((resolve, reject) => { @@ -156,12 +191,33 @@ class InternalClient { switch (packet.t) { case PacketType.READY: - + var startTime = Date.now(); self.users.add(new User(data.user, client)); - data.guilds.forEach((server) => { self.servers.add(new Server(server, client)); }); + data.private_channels.forEach((pm) => { + self.private_channels.add(new PMChannel(pm, client)); + }); + self.state = ConnectionState.READY; + + setInterval( ()=> self.sendWS({op : 1, d : Date.now()}), data.heartbeat_interval); + + client.emit("ready"); + client.emit("debug", `ready packet took ${Date.now() - startTime}ms to process`); + client.emit("debug", `ready with ${self.servers.length} servers, ${self.channels.length} channels and ${self.users.length} users cached.`); + break; + + case PacketType.MESSAGE_CREATE: + // format: https://discordapi.readthedocs.org/en/latest/reference/channels/messages.html#message-format + var channel = self.channels.get("id", data.channel_id); + if(channel){ + + channel.messages.add( new Message(data, channel, client) ); + + }else{ + client.emit("warn", "message created but channel is not cached"); + } break; diff --git a/src/Constants.js b/src/Constants.js index d0bf4576d..b670d8adc 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -60,7 +60,8 @@ var Permissions = { }; var PacketType = { - READY : "READY" + READY : "READY", + MESSAGE_CREATE : "MESSAGE_CREATE" } exports.API_ENDPOINT = API; diff --git a/src/Structures/Channel.js b/src/Structures/Channel.js index a91ed3f45..b36739339 100644 --- a/src/Structures/Channel.js +++ b/src/Structures/Channel.js @@ -1,14 +1,15 @@ "use strict"; var Equality = require("../Util/Equality.js"); +var Cache = require("../Util/Cache.js"); +var PermissionOverwrite = require("./PermissionOverwrite.js"); class Channel extends Equality{ constructor(data, client){ super(); - this.type = data.type || "text"; this.id = data.id; - this.client = client; + this.client = client; } } diff --git a/src/Structures/Member.js b/src/Structures/Member.js deleted file mode 100644 index 8e015ba4a..000000000 --- a/src/Structures/Member.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -var User = require("./User.js"); - -class Member extends User{ - constructor(data, client, server){ - super(data, client); - this.serverID = server; - } - - get server(){ - return this.client.internal.servers.get("id", this.serverID); - } -} - -module.exports = Member; \ No newline at end of file diff --git a/src/Structures/Message.js b/src/Structures/Message.js new file mode 100644 index 000000000..8d9a4e62d --- /dev/null +++ b/src/Structures/Message.js @@ -0,0 +1,35 @@ +"use strict"; + +var Cache = require("../Util/Cache.js"); +var User = require("./User.js"); + +class Message{ + constructor(data, channel, client){ + this.channel = channel; + this.client = client; + + this.nonce = data.nonce; + this.attachments = data.attachments; + this.tts = data.tts; + this.embeds = data.embeds; + this.timestamp = Date.parse(data.timestamp); + this.everyoneMentioned = data.mention_everyone; + this.id = data.id; + + if(data.edited_timestamp) + this.editedTimestamp = Date.parse(data.edited_timestamp); + this.author = client.internal.users.add(new User(data.author, client)); + this.content = data.content; + this.mentions = new Cache(); + + data.mentions.forEach((mention) => { + // this is .add and not .get because it allows the bot to cache + // users from messages from logs who may have left the server and were + // not previously cached. + console.log(mention); + this.mentions.add(client.internal.users.add(new User(mention, client))); + }); + } +} + +module.exports = Message; \ No newline at end of file diff --git a/src/Structures/PMChannel.js b/src/Structures/PMChannel.js index 4ed9fef5e..866e3090f 100644 --- a/src/Structures/PMChannel.js +++ b/src/Structures/PMChannel.js @@ -3,9 +3,20 @@ var Channel = require("./Channel.js"); var Equality = require("../Util/Equality.js"); -class PMChannel extends Channel{ +class PMChannel extends Equality{ constructor(data, client){ - super(data, client); + super(); + this.client = client; + + this.type = data.type || "text"; + this.id = data.id; + this.lastMessageId = data.last_message_id; + this.recipient = this.client.internal.users.add(data.recipient); + } + + /* warning! may return null */ + get lastMessage(){ + return this.messages.get("id", this.lastMessageID); } } diff --git a/src/Structures/Server.js b/src/Structures/Server.js index a2c8203d4..ba404762a 100644 --- a/src/Structures/Server.js +++ b/src/Structures/Server.js @@ -4,7 +4,6 @@ var Equality = require("../Util/Equality.js"); var Endpoints = require("../Constants.js").Endpoints; var Cache = require("../Util/Cache.js"); var User = require("./User.js"); -var Member = require("./Member.js"); var TextChannel = require("./TextChannel.js"); var VoiceChannel = require("./VoiceChannel.js"); var Role = require("./Role.js"); @@ -27,10 +26,17 @@ class Server extends Equality { this.icon = data.icon; this.afkTimeout = data.afkTimeout; this.afkChannelID = data.afk_channel_id; + this.memberMap = {}; data.members.forEach( (dataUser) => { - var user = client.internal.users.add(new User(dataUser, client)); - this.members.add( new Member(dataUser, client, self) ); + this.memberMap[dataUser.user.id] = { + roles : dataUser.roles, + mute : dataUser.mute, + deaf : dataUser.deaf, + joinedAt : Date.parse(dataUser.joined_at) + }; + var user = client.internal.users.add(new User(dataUser.user, client)); + this.members.add( user ); } ); data.channels.forEach( (dataChannel) => { diff --git a/src/Structures/ServerChannel.js b/src/Structures/ServerChannel.js new file mode 100644 index 000000000..969480c0f --- /dev/null +++ b/src/Structures/ServerChannel.js @@ -0,0 +1,18 @@ +"use strict"; + +var Channel = require("./Channel.js"); +var Cache = require("../Util/Cache.js"); +var PermissionOverwrite = require("./PermissionOverwrite.js"); + +class ServerChannel extends Channel{ + constructor(data, client){ + super(data, client); + this.type = data.type; + this.permissionOverwrites = new Cache(); + data.permission_overwrites.forEach((permission) => { + this.permissionOverwrites.add( new PermissionOverwrite(permission) ); + }); + } +} + +module.exports = ServerChannel; \ No newline at end of file diff --git a/src/Structures/TextChannel.js b/src/Structures/TextChannel.js index adbc28b31..98a1a7c92 100644 --- a/src/Structures/TextChannel.js +++ b/src/Structures/TextChannel.js @@ -1,10 +1,9 @@ "use strict"; -var Channel = require("./Channel.js"); +var ServerChannel = require("./ServerChannel.js"); var Cache = require("../Util/Cache.js"); -var PermissionOverwrite = require("./PermissionOverwrite.js"); -class TextChannel extends Channel{ +class TextChannel extends ServerChannel{ constructor(data, client){ super(data, client); @@ -13,11 +12,6 @@ class TextChannel extends Channel{ this.position = data.position; this.lastMessageID = data.last_message_id; this.messages = new Cache("id", client.options.maximumMessages); - - this.permissionOverwrites = new Cache(); - data.permission_overwrites.forEach((permission) => { - this.permissionOverwrites.add( new PermissionOverwrite(permission) ); - }); } /* warning! may return null */ diff --git a/src/Structures/VoiceChannel.js b/src/Structures/VoiceChannel.js index 9c2e12c43..fa8c1efb9 100644 --- a/src/Structures/VoiceChannel.js +++ b/src/Structures/VoiceChannel.js @@ -1,8 +1,8 @@ "use strict"; -var Channel = require("./Channel.js"); +var ServerChannel = require("./ServerChannel.js"); -class VoiceChannel extends Channel{ +class VoiceChannel extends ServerChannel{ constructor(data, client){ super(data, client); } diff --git a/src/index.js b/src/index.js index 53f306764..40d3f7e42 100644 --- a/src/index.js +++ b/src/index.js @@ -3,4 +3,5 @@ module.exports = { } var a = new module.exports.Client(); +a.on("debug", (m) => console.log("[debug]",m)); a.login(process.env["discordEmail"], process.env["discordPass"]).catch((e)=>console.log(e)); \ No newline at end of file