mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
Fixed smallish bugs
This commit is contained in:
@@ -57,13 +57,13 @@ var InternalClient = (function () {
|
||||
var channel = self.resolver.resolveVoiceChannel(chann);
|
||||
|
||||
if (channel) {
|
||||
if (self.voiceConnections[channel]) {
|
||||
if (!self.voiceConnections[channel]) {
|
||||
|
||||
self.voiceConnections[channel] = {};
|
||||
|
||||
var session,
|
||||
token,
|
||||
serverID,
|
||||
server = channel.server,
|
||||
endpoint,
|
||||
fired = 0;
|
||||
|
||||
@@ -72,14 +72,12 @@ var InternalClient = (function () {
|
||||
|
||||
if (data.t === "VOICE_STATE_UPDATE") {
|
||||
session = data.d.session_id;
|
||||
fired++;
|
||||
} else if (data.t === "VOICE_SERVER_UPDATE") {
|
||||
token = data.d.token;
|
||||
serverID = data.d.guild_id;
|
||||
endpoint = data.d.endpoint;
|
||||
fired++;
|
||||
}
|
||||
|
||||
self.voiceConnections[channel] = new VoiceConnection(channel, self.client, session, token, server, endpoint);
|
||||
}
|
||||
if (fired >= 2) {
|
||||
self.websocket.removeListener('message', check);
|
||||
}
|
||||
@@ -89,7 +87,7 @@ var InternalClient = (function () {
|
||||
self.sendWS({
|
||||
op: 4,
|
||||
d: {
|
||||
"guild_id": serverID,
|
||||
"guild_id": server.id,
|
||||
"channel_id": channel.id,
|
||||
"self_mute": false,
|
||||
"self_deaf": false
|
||||
|
||||
@@ -2,8 +2,19 @@
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var VoiceConnection = function VoiceConnection() {
|
||||
var WebSocket = require("ws");
|
||||
var dgram = require("dgram");
|
||||
|
||||
var VoiceConnection = function VoiceConnection(channel, client, session, token, server, endpoint) {
|
||||
_classCallCheck(this, VoiceConnection);
|
||||
|
||||
this.voiceChannel = channel;
|
||||
this.client = client;
|
||||
this.session = session;
|
||||
this.token = token;
|
||||
this.server = server;
|
||||
this.endpoint = endpoint;
|
||||
console.log("I was instantiated!");
|
||||
};
|
||||
|
||||
module.exports = VoiceConnection;
|
||||
42
lib/index.js
42
lib/index.js
@@ -4,6 +4,8 @@ module.exports = {
|
||||
Client: require("./Client/Client.js")
|
||||
};
|
||||
|
||||
var VoiceChannel = require("./Structures/VoiceChannel.js");
|
||||
|
||||
var a = new module.exports.Client();
|
||||
a.on("debug", function (m) {
|
||||
return console.log("[debug]", m);
|
||||
@@ -14,38 +16,30 @@ a.on("warn", function (m) {
|
||||
var start = Date.now();
|
||||
a.on("message", function (m) {
|
||||
if (m.content === "$$$") {
|
||||
a.internal.setTopic(m.channel, "a channel topic!");
|
||||
}
|
||||
});
|
||||
a.on("userTypingStart", function (user, chan) {
|
||||
console.log(user.username + " typing");
|
||||
});
|
||||
a.on("userTypingStop", function (user, chan) {
|
||||
console.log(user.username + " stopped typing");
|
||||
});
|
||||
a.on("ready", function () {
|
||||
for (var _iterator = a.internal.servers, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref;
|
||||
for (var _iterator = m.channel.server.channels, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref = _i.value;
|
||||
}
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref = _i.value;
|
||||
}
|
||||
|
||||
var server = _ref;
|
||||
var channel = _ref;
|
||||
|
||||
if (server.name === "craptown") {
|
||||
a.leaveServer(server);
|
||||
if (channel instanceof VoiceChannel) {
|
||||
a.internal.joinVoiceChannel(channel)["catch"](error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function error(e) {
|
||||
throw e;
|
||||
console.log(e);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user