eris
Advanced tools
Comparing version 0.10.0 to 0.10.1
@@ -82,3 +82,3 @@ "use strict"; | ||
SELECT_PROTOCOL: 1, | ||
HELLO: 2, | ||
READY: 2, | ||
HEARTBEAT: 3, | ||
@@ -85,0 +85,0 @@ SESSION_DESCRIPTION: 4, |
@@ -31,2 +31,3 @@ "use strict"; | ||
* @prop {String?} splash The hash of the guild splash image, or null if no splash (VIP only) | ||
* @prop {String?} banner The hash of the guild banner image, or null if no banner (VIP only) | ||
* @prop {Boolean} unavailable Whether the guild is unavailable or not | ||
@@ -44,2 +45,8 @@ * @prop {Boolean} large Whether the guild is "large" by "some Discord standard" | ||
* @prop {Number} explicitContentFilter The explicit content filter level for the guild. 0 is off, 1 is on for people without roles, 2 is on for all | ||
* @prop {Number} premiumTier Nitro boost level of the guild | ||
* @prop {Number?} premiumSuscriptionCount The total number of users currently boosting this guild | ||
* @prop {String?} vanityURL The vanity URL of the guild (VIP only) | ||
* @prop {String} preferredLocale Preferred guild language | ||
* @prop {String?} description The description for the guild (VIP only) | ||
* @prop {Number} maxMembers The maximum amount of members for the guild | ||
*/ | ||
@@ -147,2 +154,8 @@ class Guild extends Base { | ||
this.systemChannelID = data.system_channel_id !== undefined ? data.system_channel_id : this.systemChannelID; | ||
this.premiumTier = data.premium_tier !== undefined ? data.premium_tier : this.premiumTier; | ||
this.premiumSuscriptionCount = data.premium_subscription_count !== undefined ? data.premium_subscription_count : this.premiumSuscriptionCount; | ||
this.vanityURL = data.vanity_url_code !== undefined ? data.vanity_url_code : this.vanityURL; | ||
this.preferredLocale = data.preferred_locale !== undefined ? data.preferred_locale : this.preferredLocale; | ||
this.description = data.description !== undefined ? data.description : this.description; | ||
this.maxMembers = data.max_members !== undefined ? data.max_members : this.maxMembers; | ||
} | ||
@@ -158,3 +171,3 @@ | ||
get iconURL() { | ||
return this.icon ? `${CDN_URL}/icons/${this.id}/${this.icon}.${this.shard.client.options.defaultImageFormat}?size=${this.shard.client.options.defaultImageSize}` : null; | ||
return this.icon ? `${CDN_URL}/icons/${this.id}/${this.icon}.${this.icon.startsWith("a_") ? "gif" : this.shard.client.options.defaultImageFormat}?size=${this.shard.client.options.defaultImageSize}` : null; | ||
} | ||
@@ -169,3 +182,3 @@ | ||
if(!format || !Constants.ImageFormats.includes(format.toLowerCase())) { | ||
format = this.shard.client.options.defaultImageFormat; | ||
format = this.icon.startsWith("a_") ? "gif" : this.shard.client.options.defaultImageFormat; | ||
} | ||
@@ -582,3 +595,3 @@ if( | ||
const base = super.toJSON(true); | ||
for(const prop of ["afkChannelID", "afkTimeout", "channels", "defaultNotifications", "emojis", "explicitContentFilter", "features", "icon", "joinedAt", "large", "maxPresences", "memberCount", "members", "mfaLevel", "name", "ownerID", "region", "roles", "splash", "banner", "unavailable", "verificationLevel"]) { | ||
for(const prop of ["afkChannelID", "afkTimeout", "banner", "channels", "defaultNotifications", "description", "emojis", "explicitContentFilter", "features", "icon", "joinedAt", "large", "maxMembers", "maxPresences", "memberCount", "members", "mfaLevel", "name", "ownerID", "preferredLocale", "premiumSuscriptionCount", "premiumTier", "region", "roles", "splash", "unavailable", "vanityURL", "verificationLevel"]) { | ||
if(this[prop] !== undefined) { | ||
@@ -585,0 +598,0 @@ base[prop] = this[prop] && this[prop].toJSON ? this[prop].toJSON() : this[prop]; |
@@ -39,2 +39,3 @@ "use strict"; | ||
* @prop {String} staticAvatarURL The URL of the user's avatar (always a JPG) | ||
* @prop {Number} premiumSince Timestamp of when the member boosted the guild | ||
*/ | ||
@@ -67,2 +68,3 @@ class Member extends Base { | ||
this.activities = data.activities; | ||
this.premiumSince = data.premium_since !== undefined ? data.premium_since : this.premiumSince; | ||
@@ -207,3 +209,3 @@ if(data.mute !== undefined) { | ||
const base = super.toJSON(true); | ||
for(const prop of ["game", "joinedAt", "nick", "roles", "status", "user", "voiceState"]) { | ||
for(const prop of ["game", "joinedAt", "nick", "roles", "status", "user", "voiceState", "premiumSince"]) { | ||
if(this[prop] !== undefined) { | ||
@@ -210,0 +212,0 @@ base[prop] = this[prop] && this[prop].toJSON ? this[prop].toJSON() : this[prop]; |
@@ -102,3 +102,7 @@ "use strict"; | ||
data.content = SystemJoinMessages[~~(this.createdAt % SystemJoinMessages.length)].replace(/%user%/g, this.author.mention); | ||
} else { | ||
} else if(this.type === 8) { | ||
data.content = `${this.author.mention} just boosted the server!`; | ||
} else if(this.type === 9 || this.type === 10 || this.type === 11) { | ||
data.content = `${this.author.mention} just boosted the server! ${this.channel.guild ? this.channel.guild.name : data.guild_id} has achieved **Level ${this.type - 8}!**`; | ||
} else { | ||
client.emit("warn", "Unhandled MESSAGE_CREATE type: " + JSON.stringify(data, null, 2)); | ||
@@ -105,0 +109,0 @@ } |
@@ -227,3 +227,3 @@ "use strict"; | ||
switch(packet.op) { | ||
case OPCodes.HELLO: { | ||
case OPCodes.READY: { | ||
if(packet.d.heartbeat_interval > 0) { | ||
@@ -244,55 +244,49 @@ if(this.heartbeatInterval) { | ||
} | ||
this.modes = packet.d.modes; | ||
this.udpIP = packet.d.ip; | ||
this.udpPort = packet.d.port; | ||
this.emit("debug", "Connecting to UDP: " + this.udpIP + ":" + this.udpPort); | ||
DNS.lookup(this.endpoint, (err, address) => { // RIP DNS | ||
if(err) { | ||
this.emit("error", err); | ||
return; | ||
this.udpSocket = Dgram.createSocket("udp4"); | ||
this.udpSocket.once("message", (packet) => { | ||
this.emit("debug", packet.toString()); | ||
let localIP = ""; | ||
let i = 3; | ||
while(++i < packet.indexOf(0, i)) { | ||
localIP += String.fromCharCode(packet[i]); | ||
} | ||
const localPort = parseInt(packet.readUIntLE(packet.length - 2, 2).toString(10)); | ||
this.udpIP = address; | ||
this.emit("debug", "Connecting to UDP: " + this.udpIP + ":" + this.udpPort); | ||
this.udpSocket = Dgram.createSocket("udp4"); | ||
this.udpSocket.once("message", (packet) => { | ||
this.emit("debug", packet.toString()); | ||
let localIP = ""; | ||
let i = 3; | ||
while(++i < packet.indexOf(0, i)) { | ||
localIP += String.fromCharCode(packet[i]); | ||
this.sendWS(OPCodes.SELECT_PROTOCOL, { | ||
protocol: "udp", | ||
data: { | ||
address: localIP, | ||
port: localPort, | ||
mode: ENCRYPTION_MODE | ||
} | ||
const localPort = parseInt(packet.readUIntLE(packet.length - 2, 2).toString(10)); | ||
this.sendWS(OPCodes.SELECT_PROTOCOL, { | ||
protocol: "udp", | ||
data: { | ||
address: localIP, | ||
port: localPort, | ||
mode: ENCRYPTION_MODE | ||
} | ||
}); | ||
}); | ||
this.udpSocket.on("error", (err, msg) => { | ||
this.emit("error", err); | ||
if(msg) { | ||
this.emit("debug", "Voice UDP error: " + msg); | ||
} | ||
if(this.ready || this.connecting) { | ||
this.disconnect(err); | ||
} | ||
}); | ||
this.udpSocket.on("close", (err) => { | ||
if(err) { | ||
this.emit("warn", "Voice UDP close: " + err); | ||
} | ||
if(this.ready || this.connecting) { | ||
this.disconnect(err); | ||
} | ||
}); | ||
const udpMessage = Buffer.alloc(70); | ||
udpMessage.writeUIntBE(this.ssrc, 0, 4); | ||
this._sendPacket(udpMessage); | ||
}); | ||
this.udpSocket.on("error", (err, msg) => { | ||
this.emit("error", err); | ||
if(msg) { | ||
this.emit("debug", "Voice UDP error: " + msg); | ||
} | ||
if(this.ready || this.connecting) { | ||
this.disconnect(err); | ||
} | ||
}); | ||
this.udpSocket.on("close", (err) => { | ||
if(err) { | ||
this.emit("warn", "Voice UDP close: " + err); | ||
} | ||
if(this.ready || this.connecting) { | ||
this.disconnect(err); | ||
} | ||
}); | ||
const udpMessage = Buffer.alloc(70); | ||
udpMessage.writeUIntBE(this.ssrc, 0, 4); | ||
this._sendPacket(udpMessage); | ||
break; | ||
@@ -299,0 +293,0 @@ } |
{ | ||
"name": "eris", | ||
"version": "0.10.0", | ||
"version": "0.10.1", | ||
"description": "A NodeJS Discord library", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
554367
12214