eris
Advanced tools
Comparing version 0.11.0 to 0.11.1
@@ -37,3 +37,3 @@ "use strict"; | ||
Eris.User = require("./lib/structures/User"); | ||
Eris.VERSION = require('./package.json').version; | ||
Eris.VERSION = require("./package.json").version; | ||
Eris.VoiceChannel = require("./lib/structures/VoiceChannel"); | ||
@@ -44,3 +44,3 @@ Eris.VoiceConnection = require("./lib/voice/VoiceConnection"); | ||
Object.keys(Eris).filter(prop => Eris.hasOwnProperty(prop) && typeof Eris[prop] === "function" && !(Eris[prop] instanceof Eris.Base)).forEach(prop => { | ||
Object.keys(Eris).filter((prop) => Eris.hasOwnProperty(prop) && typeof Eris[prop] === "function" && !(Eris[prop] instanceof Eris.Base)).forEach((prop) => { | ||
Eris[prop].prototype.toString = Eris.Base.prototype.toString; | ||
@@ -47,0 +47,0 @@ }); |
@@ -262,3 +262,3 @@ "use strict"; | ||
}, this.cooldown); | ||
} else{ | ||
} else { | ||
setTimeout(() => { | ||
@@ -276,3 +276,3 @@ this.usersOnCooldown.delete(userID); | ||
const response = await Promise.resolve(this.hooks.preCommand(msg, args)); | ||
if (response) { | ||
if(response) { | ||
msg = response.msg || msg; | ||
@@ -287,3 +287,3 @@ args = response.args || args; | ||
const response = await Promise.resolve(this.hooks.postCheck(msg, args, false)); | ||
if (response) { | ||
if(response) { | ||
msg = response.msg || msg; | ||
@@ -310,3 +310,3 @@ args = response.args || args; | ||
const response = await Promise.resolve(this.hooks.postCheck(msg, args, true)); | ||
if (response) { | ||
if(response) { | ||
msg = response.msg || msg; | ||
@@ -325,3 +325,3 @@ args = response.args || args; | ||
const response = await Promise.resolve(this.hooks.postCheck(msg, args, true)); | ||
if (response) { | ||
if(response) { | ||
msg = response.msg || msg; | ||
@@ -353,3 +353,3 @@ args = response.args || args; | ||
const response = await Promise.resolve(this.hooks.postCheck(msg, args, false)); | ||
if (response) { | ||
if(response) { | ||
msg = response.msg || msg; | ||
@@ -374,3 +374,3 @@ args = response.args || args; | ||
const response = await Promise.resolve(this.hooks.postCheck(msg, args, true)); | ||
if (response) { | ||
if(response) { | ||
msg = response.msg || msg; | ||
@@ -377,0 +377,0 @@ args = response.args || args; |
@@ -39,3 +39,3 @@ "use strict"; | ||
prefix: "@mention ", | ||
defaultCommandOptions: {}, | ||
defaultCommandOptions: {} | ||
}, commandOptions); | ||
@@ -131,5 +131,5 @@ this.guildPrefixes = {}; | ||
/** | ||
* Checks the command client for a command based on the provided message | ||
* @arg {Message} msg The message object from the message create event | ||
*/ | ||
* Checks the command client for a command based on the provided message | ||
* @arg {Message} msg The message object from the message create event | ||
*/ | ||
async onMessageCreate(msg) { | ||
@@ -157,3 +157,3 @@ if(!this.ready) { | ||
} | ||
if (msg.command.reactionButtons) { | ||
if(msg.command.reactionButtons) { | ||
msg.command.reactionButtons.forEach((button) => resp.addReaction(button.emoji)); | ||
@@ -160,0 +160,0 @@ this.activeMessages[resp.id] = { |
@@ -163,3 +163,3 @@ "use strict"; | ||
IS_CROSSPOST: 1 << 1, | ||
SUPPRESS_EMBEDS: 1 << 2, | ||
SUPPRESS_EMBEDS: 1 << 2 | ||
}; |
@@ -125,3 +125,3 @@ "use strict"; | ||
if(body[key] != undefined) { | ||
if(Array.isArray(body[key])) { | ||
if(Array.isArray(body[key])) { | ||
body[key].forEach(function(val) { | ||
@@ -128,0 +128,0 @@ qs += `&${encodeURIComponent(key)}=${encodeURIComponent(val)}`; |
"use strict"; | ||
const util = require('util'); | ||
const util = require("util"); | ||
@@ -5,0 +5,0 @@ class Base { |
@@ -18,3 +18,3 @@ "use strict"; | ||
* @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of PermissionOverwrites in this channel | ||
* @prop {Collection<GuildChannel>?} channels A collection of guild channels that are part of this category | ||
* @prop {Collection<GuildChannel>} channels A collection of guild channels that are part of this category | ||
*/ | ||
@@ -21,0 +21,0 @@ class CategoryChannel extends GuildChannel { |
@@ -86,6 +86,6 @@ "use strict"; | ||
) { | ||
size = this._client.options.defaultImageSize; | ||
size = this._client.options.defaultImageSize; | ||
} | ||
return this.icon ? `${Endpoints.CDN_URL}/channel-icons/${this.id}/${this.icon}.${format}?size=${size}` : null; | ||
} | ||
} | ||
@@ -92,0 +92,0 @@ toJSON() { |
@@ -14,2 +14,3 @@ "use strict"; | ||
const VoiceChannel = require("./VoiceChannel"); | ||
const VoiceState = require("./VoiceState"); | ||
@@ -36,2 +37,3 @@ /** | ||
* @prop {Number} maxPresences The maximum number of people that can be online in a guild at once (returned from REST API only) | ||
* @prop {Collection<VoiceState>} voiceStates Collection of voice states in the guild | ||
* @prop {Collection<GuildChannel>} channels Collection of Channels in the guild | ||
@@ -59,2 +61,3 @@ * @prop {Collection<Member>} members Collection of Members in the guild | ||
this.joinedAt = Date.parse(data.joined_at); | ||
this.voiceStates = new Collection(VoiceState); | ||
this.channels = new Collection(GuildChannel); | ||
@@ -188,3 +191,3 @@ this.members = new Collection(Member); | ||
) { | ||
size = this.shard.client.options.defaultImageSize; | ||
size = this.shard.client.options.defaultImageSize; | ||
} | ||
@@ -203,6 +206,6 @@ return this.icon ? `${CDN_URL}/icons/${this.id}/${this.icon}.${format}?size=${size}` : null; | ||
/** | ||
* Get the guild's splash with the given format and size | ||
* @arg {String} [format] The filetype of the icon ("jpg", "png", "gif", or "webp") | ||
* @param {Number} [size] The size of the icon (any power of two between 16 and 2048) | ||
*/ | ||
* Get the guild's splash with the given format and size | ||
* @arg {String} [format] The filetype of the icon ("jpg", "png", "gif", or "webp") | ||
* @param {Number} [size] The size of the icon (any power of two between 16 and 2048) | ||
*/ | ||
dynamicSplashURL(format,size){ | ||
@@ -217,3 +220,3 @@ if(!format || !Constants.ImageFormats.includes(format.toLowerCase())){ | ||
) { | ||
size = this.shard.client.options.defaultImageSize; | ||
size = this.shard.client.options.defaultImageSize; | ||
} | ||
@@ -224,6 +227,6 @@ return this.splash ? `${CDN_URL}/splashes/${this.id}/${this.splash}.${format}?size=${size}` : null; | ||
/** | ||
* Get the guild's banner with the given format and size | ||
* @arg {String} [format] The filetype of the icon ("jpg", "png", "gif", or "webp") | ||
* @param {Number} [size] The size of the icon (any power of two between 16 and 2048) | ||
*/ | ||
* Get the guild's banner with the given format and size | ||
* @arg {String} [format] The filetype of the icon ("jpg", "png", "gif", or "webp") | ||
* @param {Number} [size] The size of the icon (any power of two between 16 and 2048) | ||
*/ | ||
dynamicBannerURL(format,size){ | ||
@@ -238,3 +241,3 @@ if(!format || !Constants.ImageFormats.includes(format.toLowerCase())){ | ||
) { | ||
size = this.shard.client.options.defaultImageSize; | ||
size = this.shard.client.options.defaultImageSize; | ||
} | ||
@@ -247,11 +250,12 @@ return this.banner ? `${CDN_URL}/banners/${this.id}/${this.banner}.${format}?size=${size}` : null; | ||
* @arg {String} name The name of the channel | ||
* @arg {String} [type=0] The type of the channel, either 0 (text), 2 (voice), or 4 (category) | ||
* @arg {String} [reason] The reason to be displayed in audit logs | ||
* @arg {Object} [options] The properties the channel should have | ||
* @arg {Number} [type=0] The type of the channel, either 0 (text), 2 (voice), or 4 (category) | ||
* @arg {Object | String} [options] The properties the channel should have. If `options` is a string, it will be treated as `options.parentID` (see below). Passing a string is deprecated and will not be supported in future versions. | ||
* @arg {String} [options.topic] The topic of the channel (text channels only) | ||
* @arg {Boolean} [options.nsfw] The nsfw status of the channel | ||
* @arg {Number} [options.bitrate] The bitrate of the channel (voice channels only) | ||
* @arg {String?} [options.parentID] The ID of the parent category channel for this channel | ||
* @arg {Array} [options.permissionOverwrites] An array containing permission overwrite objects | ||
* @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (text channels only) | ||
* @arg {String} [options.reason] The reason to be displayed in audit logs | ||
* @arg {Number} [options.userLimit] The channel user limit (voice channels only) | ||
* @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (text channels only) | ||
* @arg {String?} [options.parentID] The ID of the parent channel category for this channel | ||
* @returns {Promise<CategoryChannel | TextChannel | VoiceChannel>} | ||
@@ -402,4 +406,4 @@ */ | ||
/** | ||
* Leaves the voice channel in this guild | ||
*/ | ||
* Leaves the voice channel in this guild | ||
*/ | ||
leaveVoiceChannel() { | ||
@@ -494,5 +498,5 @@ this.shard.client.closeVoiceConnection.call(this.shard.client, this.id); | ||
/** | ||
* Returns the vanity url of the guild | ||
* @returns {Promise} | ||
*/ | ||
* Returns the vanity url of the guild | ||
* @returns {Promise} | ||
*/ | ||
getVanity() { | ||
@@ -499,0 +503,0 @@ return this.shard.client.getGuildVanity.call(this.shard.client, this.id); |
@@ -25,3 +25,3 @@ "use strict"; | ||
super(data); | ||
if (!guild && data.guild_id) { | ||
if(!guild && data.guild_id) { | ||
this.guild = { | ||
@@ -28,0 +28,0 @@ id: data.guild_id |
@@ -69,3 +69,3 @@ "use strict"; | ||
} | ||
toString() { | ||
@@ -72,0 +72,0 @@ return `[Invite ${this.code}]`; |
@@ -57,3 +57,2 @@ "use strict"; | ||
} | ||
this.voiceState = new VoiceState(data); | ||
this.update(data); | ||
@@ -66,8 +65,15 @@ } | ||
this.joinedAt = data.joined_at !== undefined ? Date.parse(data.joined_at) : this.joinedAt; | ||
this.clientStatus = data.client_status !== undefined ? Object.assign({ web: "offline", desktop: "offline", mobile: "offline" }, data.client_status) : this.clientStatus; | ||
this.activities = data.activities; | ||
this.clientStatus = data.client_status !== undefined ? Object.assign({web: "offline", desktop: "offline", mobile: "offline"}, data.client_status) : this.clientStatus; | ||
this.activities = data.activities !== undefined ? data.activities : this.activities; | ||
this.premiumSince = data.premium_since !== undefined ? data.premium_since : this.premiumSince; | ||
if(data.mute !== undefined) { | ||
this.voiceState.update(data); | ||
if("mute" in data) { | ||
const state = this.guild.voiceStates.get(this.id); | ||
if(data.channel_id === null && !data.mute && !data.deaf && !data.suppress) { | ||
this.guild.voiceStates.delete(this.id); | ||
} else if(state) { | ||
state.update(data); | ||
} else if(data.channel_id || data.mute || data.deaf || data.suppress) { | ||
this.guild.voiceStates.update(data); | ||
} | ||
} | ||
@@ -81,2 +87,8 @@ | ||
get voiceState() { | ||
return this.guild.voiceStates.get(this.id) || new VoiceState({ | ||
id: this.id | ||
}); | ||
} | ||
get permission() { | ||
@@ -83,0 +95,0 @@ if(this.id === this.guild.ownerID) { |
@@ -20,3 +20,3 @@ "use strict"; | ||
* @prop {String[]} roleMentions Array of mentioned roles' ids | ||
* @prop {String[]?} channelMentions Array of mentions channels' ids | ||
* @prop {String[]} channelMentions Array of mentions channels' ids | ||
* @prop {Number?} editedTimestamp Timestamp of latest message edit | ||
@@ -29,3 +29,3 @@ * @prop {Boolean} tts Whether to play the message using TTS or not | ||
* @prop {String} messageReference.guildID The id of the guild this message was crossposted from | ||
* @prop {Number} flags Message flags (see constants) | ||
* @prop {Number} flags Message flags (see constants) | ||
* @prop {Object[]} attachments Array of attachments | ||
@@ -54,7 +54,7 @@ * @prop {Object[]} embeds Array of embeds | ||
if (data.message_reference) { | ||
if(data.message_reference) { | ||
this.messageReference = { | ||
messageID: data.message_reference.message_id, | ||
channelID: data.message_reference.channel_id, | ||
guildID: data.message_reference.guild_id, | ||
guildID: data.message_reference.guild_id | ||
}; | ||
@@ -80,3 +80,3 @@ } else { | ||
this.member = this.channel.guild.members.update(data.member, this.channel.guild); | ||
} else if (this.channel.guild.members.has(this.author.id)) { | ||
} else if(this.channel.guild.members.has(this.author.id)) { | ||
this.member = this.channel.guild.members.get(this.author.id); | ||
@@ -83,0 +83,0 @@ } else { |
@@ -71,3 +71,3 @@ "use strict"; | ||
dynamicAvatarURL(format, size) { | ||
if (!this.avatar) { | ||
if(!this.avatar) { | ||
return this.defaultAvatarURL; | ||
@@ -74,0 +74,0 @@ } |
@@ -74,12 +74,8 @@ "use strict"; | ||
random() { | ||
if(!this.size) { | ||
return undefined; | ||
} | ||
const index = Math.floor(Math.random() * this.size); | ||
const iter = this.values(); | ||
let res; | ||
for(let i = 0; i <= index; i++) { | ||
res = iter.next().value; | ||
for(let i = 0; i < index; ++i) { | ||
iter.next(); | ||
} | ||
return res; | ||
return iter.next().value; | ||
} | ||
@@ -86,0 +82,0 @@ |
@@ -39,3 +39,3 @@ "use strict"; | ||
const substream = delegateEvents[ev]; | ||
if (substream) { | ||
if(substream) { | ||
return this[substream][method](ev, fn); | ||
@@ -54,3 +54,3 @@ } else { | ||
const onStdoutEnd = () => { | ||
if (exited && !ended) { | ||
if(exited && !ended) { | ||
ended = true; | ||
@@ -85,8 +85,8 @@ this._reader.end(); | ||
if (killed) { | ||
if (ex) { | ||
if(killed) { | ||
if(ex) { | ||
this.emit("error", ex); | ||
} | ||
this.emit("close"); | ||
} else if (code === 0 && signal == null) { | ||
} else if(code === 0 && signal == null) { | ||
// All is well | ||
@@ -126,3 +126,3 @@ onStdoutEnd(); | ||
setTimeout(() => this._process && this._process.kill("SIGKILL"), 2000); | ||
} catch (e) { | ||
} catch(e) { | ||
ex = e; | ||
@@ -129,0 +129,0 @@ onExit(); |
@@ -247,3 +247,3 @@ "use strict"; | ||
this.udpPort = packet.d.port; | ||
this.emit("debug", "Connecting to UDP: " + this.udpIP + ":" + this.udpPort); | ||
@@ -295,3 +295,3 @@ | ||
this.secret = new Uint8Array(new ArrayBuffer(packet.d.secret_key.length)); | ||
for (let i = 0; i < packet.d.secret_key.length; ++i) { | ||
for(let i = 0; i < packet.d.secret_key.length; ++i) { | ||
this.secret[i] = packet.d.secret_key[i]; | ||
@@ -571,3 +571,3 @@ } | ||
this.packetBuffer.fill(0, 12, 12 + length); | ||
for (let i = 0; i < length; ++i) { | ||
for(let i = 0; i < length; ++i) { | ||
this.packetBuffer[12 + i] = buffer[i]; | ||
@@ -574,0 +574,0 @@ } |
{ | ||
"name": "eris", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"description": "A NodeJS Discord library", | ||
@@ -10,3 +10,6 @@ "main": "./index.js", | ||
"scripts": { | ||
"eslint": "eslint --fix lib index.js && echo \"\u001b[1m\u001b[32mOK\u001b[39m\u001b[22m\" || echo \"\u001b[1m\u001b[31mNot OK\u001b[39m\u001b[22m\"" | ||
"lint:js": "eslint -c .eslintrc.yml lib examples *.js", | ||
"lint:js:fix": "eslint -c .eslintrc.yml lib examples *.js --fix && echo \"\u001b[1m\u001b[32mOK\u001b[39m\u001b[22m\" || echo \"\u001b[1m\u001b[31mNot OK\u001b[39m\u001b[22m\"", | ||
"lint:ts": "eslint -c .eslintrc.ts.yml *.ts", | ||
"lint:ts:fix": "eslint -c .eslintrc.ts.yml *.ts --fix && echo \"\u001b[1m\u001b[32mOK\u001b[39m\u001b[22m\" || echo \"\u001b[1m\u001b[31mNot OK\u001b[39m\u001b[22m\"" | ||
}, | ||
@@ -33,2 +36,8 @@ "repository": { | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^2.7.0", | ||
"@typescript-eslint/parser": "^2.7.0", | ||
"eslint": "^6.6.0", | ||
"typescript": "^3.7.2" | ||
}, | ||
"optionalDependencies": { | ||
@@ -47,6 +56,3 @@ "opusscript": "^0.0.4", | ||
"ws": false | ||
}, | ||
"devDependencies": { | ||
"eslint": "^6.5.1" | ||
} | ||
} |
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
561542
12410
4
58