Update dependencies & make webpack great again

This commit is contained in:
Crawl
2017-07-05 11:53:53 +02:00
parent e3cd000ec0
commit 0c34f3a313
12 changed files with 103 additions and 106 deletions

View File

@@ -34,7 +34,7 @@
"dependencies": { "dependencies": {
"long": "^3.2.0", "long": "^3.2.0",
"prism-media": "^0.0.1", "prism-media": "^0.0.1",
"snekfetch": "^3.1.0", "snekfetch": "^3.2.0",
"tweetnacl": "^1.0.0", "tweetnacl": "^1.0.0",
"ws": "^3.0.0" "ws": "^3.0.0"
}, },
@@ -45,16 +45,15 @@
"opusscript": "^0.0.3", "opusscript": "^0.0.3",
"sodium": "^2.0.1", "sodium": "^2.0.1",
"libsodium-wrappers": "^0.5.1", "libsodium-wrappers": "^0.5.1",
"uws": "^0.14.1" "uws": "^8.14.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^7.0.0", "@types/node": "^8.0.0",
"discord.js-docgen": "hydrabolt/discord.js-docgen", "discord.js-docgen": "hydrabolt/discord.js-docgen",
"eslint": "^3.19.0", "eslint": "^4.0.0",
"parallel-webpack": "^1.6.0", "parallel-webpack": "^2.0.0",
"uglify-js": "mishoo/UglifyJS2#harmony-v2.8.22", "uglifyjs-webpack-plugin": "iCrawl/uglifyjs-webpack-plugin",
"uglifyjs-webpack-plugin": "^0.4.3", "webpack": "^3.0.0"
"webpack": "^2.2.0"
}, },
"engines": { "engines": {
"node": ">=8.0.0" "node": ">=8.0.0"

View File

@@ -415,7 +415,7 @@ class Client extends EventEmitter {
*/ */
fetchApplication(id = '@me') { fetchApplication(id = '@me') {
return this.api.oauth2.applications[id].get() return this.api.oauth2.applications[id].get()
.then(app => new OAuth2Application(this, app)); .then(app => new OAuth2Application(this, app));
} }
/** /**

View File

@@ -193,11 +193,11 @@ class ClientDataResolver {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (/^https?:\/\//.test(resource)) { if (/^https?:\/\//.test(resource)) {
snekfetch.get(resource) snekfetch.get(resource)
.end((err, res) => { .end((err, res) => {
if (err) return reject(err); if (err) return reject(err);
if (!(res.body instanceof Buffer)) return reject(new TypeError('REQ_BODY_TYPE')); if (!(res.body instanceof Buffer)) return reject(new TypeError('REQ_BODY_TYPE'));
return resolve(res.body); return resolve(res.body);
}); });
} else { } else {
const file = path.resolve(resource); const file = path.resolve(resource);
fs.stat(file, (err, stats) => { fs.stat(file, (err, stats) => {

View File

@@ -136,7 +136,7 @@ class GroupDMChannel extends Channel {
{ nick, access_token: accessTokenOrUser } : { nick, access_token: accessTokenOrUser } :
{ recipient: id }; { recipient: id };
return this.client.api.channels[this.id].recipients[id].put({ data }) return this.client.api.channels[this.id].recipients[id].put({ data })
.then(() => this); .then(() => this);
} }
/** /**

View File

@@ -394,14 +394,14 @@ class Guild {
*/ */
fetchInvites() { fetchInvites() {
return this.client.api.guilds[this.id].invites.get() return this.client.api.guilds[this.id].invites.get()
.then(inviteItems => { .then(inviteItems => {
const invites = new Collection(); const invites = new Collection();
for (const inviteItem of inviteItems) { for (const inviteItem of inviteItems) {
const invite = new Invite(this.client, inviteItem); const invite = new Invite(this.client, inviteItem);
invites.set(invite.code, invite); invites.set(invite.code, invite);
} }
return invites; return invites;
}); });
} }
/** /**
@@ -490,10 +490,10 @@ class Guild {
if (!user) return Promise.reject(new Error('User is not cached. Use Client.fetchUser first.')); if (!user) return Promise.reject(new Error('User is not cached. Use Client.fetchUser first.'));
if (this.members.has(user.id)) return Promise.resolve(this.members.get(user.id)); if (this.members.has(user.id)) return Promise.resolve(this.members.get(user.id));
return this.client.api.guilds[this.id].members[user.id].get() return this.client.api.guilds[this.id].members[user.id].get()
.then(data => { .then(data => {
if (cache) return this.client.actions.GuildMemberGet.handle(this, data).member; if (cache) return this.client.actions.GuildMemberGet.handle(this, data).member;
else return new GuildMember(this, data); else return new GuildMember(this, data);
}); });
} }
/** /**
@@ -594,7 +594,7 @@ class Guild {
_data.explicit_content_filter = Number(data.explicitContentFilter); _data.explicit_content_filter = Number(data.explicitContentFilter);
} }
return this.client.api.guilds[this.id].patch({ data: _data, reason }) return this.client.api.guilds[this.id].patch({ data: _data, reason })
.then(newData => this.client.actions.GuildUpdate.handle(newData).updated); .then(newData => this.client.actions.GuildUpdate.handle(newData).updated);
} }
/** /**
@@ -739,11 +739,11 @@ class Guild {
*/ */
acknowledge() { acknowledge() {
return this.client.api.guilds[this.id].ack return this.client.api.guilds[this.id].ack
.post({ data: { token: this.client.rest._ackToken } }) .post({ data: { token: this.client.rest._ackToken } })
.then(res => { .then(res => {
if (res.token) this.client.rest._ackToken = res.token; if (res.token) this.client.rest._ackToken = res.token;
return this; return this;
}); });
} }
/** /**
@@ -778,15 +778,15 @@ class Guild {
const id = this.client.resolver.resolveUserID(user); const id = this.client.resolver.resolveUserID(user);
if (!id) return Promise.reject(new Error('Couldn\'t resolve the user ID to ban.')); if (!id) return Promise.reject(new Error('Couldn\'t resolve the user ID to ban.'));
return this.client.api.guilds[this.id].bans[id].put({ query: options }) return this.client.api.guilds[this.id].bans[id].put({ query: options })
.then(() => { .then(() => {
if (user instanceof GuildMember) return user; if (user instanceof GuildMember) return user;
const _user = this.client.resolver.resolveUser(id); const _user = this.client.resolver.resolveUser(id);
if (_user) { if (_user) {
const member = this.client.resolver.resolveGuildMember(this, _user); const member = this.client.resolver.resolveGuildMember(this, _user);
return member || _user; return member || _user;
} }
return id; return id;
}); });
} }
/** /**
@@ -965,10 +965,10 @@ class Guild {
.then(emoji => this.client.actions.GuildEmojiCreate.handle(this, emoji).emoji); .then(emoji => this.client.actions.GuildEmojiCreate.handle(this, emoji).emoji);
} else { } else {
return this.client.resolver.resolveBuffer(attachment) return this.client.resolver.resolveBuffer(attachment)
.then(data => { .then(data => {
const dataURI = this.client.resolver.resolveBase64(data); const dataURI = this.client.resolver.resolveBase64(data);
return this.createEmoji(dataURI, name, roles); return this.createEmoji(dataURI, name, roles);
}); });
} }
} }
@@ -980,7 +980,7 @@ class Guild {
deleteEmoji(emoji) { deleteEmoji(emoji) {
if (!(emoji instanceof Emoji)) emoji = this.emojis.get(emoji); if (!(emoji instanceof Emoji)) emoji = this.emojis.get(emoji);
return this.client.api.guilds(this.id).emojis[emoji.id].delete() return this.client.api.guilds(this.id).emojis[emoji.id].delete()
.then(() => this.client.actions.GuildEmojiDelete.handle(emoji).data); .then(() => this.client.actions.GuildEmojiDelete.handle(emoji).data);
} }
/** /**
@@ -995,7 +995,7 @@ class Guild {
leave() { leave() {
if (this.ownerID === this.client.user.id) return Promise.reject(new Error('Guild is owned by the client.')); if (this.ownerID === this.client.user.id) return Promise.reject(new Error('Guild is owned by the client.'));
return this.client.api.users['@me'].guilds[this.id].delete() return this.client.api.users['@me'].guilds[this.id].delete()
.then(() => this.client.actions.GuildDelete.handle({ id: this.id }).guild); .then(() => this.client.actions.GuildDelete.handle({ id: this.id }).guild);
} }
/** /**
@@ -1009,7 +1009,7 @@ class Guild {
*/ */
delete() { delete() {
return this.client.api.guilds[this.id].delete() return this.client.api.guilds[this.id].delete()
.then(() => this.client.actions.GuildDelete.handle({ id: this.id }).guild); .then(() => this.client.actions.GuildDelete.handle({ id: this.id }).guild);
} }
/** /**
@@ -1167,12 +1167,12 @@ class Guild {
updatedRoles = updatedRoles.map((r, i) => ({ id: r.id, position: i })); updatedRoles = updatedRoles.map((r, i) => ({ id: r.id, position: i }));
return this.client.api.guilds[this.id].roles.patch({ data: updatedRoles }) return this.client.api.guilds[this.id].roles.patch({ data: updatedRoles })
.then(() => .then(() =>
this.client.actions.GuildRolesPositionUpdate.handle({ this.client.actions.GuildRolesPositionUpdate.handle({
guild_id: this.id, guild_id: this.id,
roles: updatedRoles, roles: updatedRoles,
}).guild }).guild
); );
} }
/** /**
@@ -1197,12 +1197,12 @@ class Guild {
updatedChannels = updatedChannels.map((r, i) => ({ id: r.id, position: i })); updatedChannels = updatedChannels.map((r, i) => ({ id: r.id, position: i }));
return this.client.api.guilds[this.id].channels.patch({ data: updatedChannels }) return this.client.api.guilds[this.id].channels.patch({ data: updatedChannels })
.then(() => .then(() =>
this.client.actions.GuildChannelsPositionUpdate.handle({ this.client.actions.GuildChannelsPositionUpdate.handle({
guild_id: this.id, guild_id: this.id,
roles: updatedChannels, roles: updatedChannels,
}).guild }).guild
); );
} }
/** /**
@@ -1229,8 +1229,8 @@ class Guild {
_sortPositionWithID(collection) { _sortPositionWithID(collection) {
return collection.sort((a, b) => return collection.sort((a, b) =>
a.position !== b.position ? a.position !== b.position ?
a.position - b.position : a.position - b.position :
Long.fromString(a.id).sub(Long.fromString(b.id)).toNumber() Long.fromString(a.id).sub(Long.fromString(b.id)).toNumber()
); );
} }
} }

View File

@@ -485,12 +485,12 @@ class GuildMember {
*/ */
kick(reason) { kick(reason) {
return this.client.api.guilds[this.guild.id].members[this.user.id].delete({ reason }) return this.client.api.guilds[this.guild.id].members[this.user.id].delete({ reason })
.then(() => .then(() =>
this.client.actions.GuildMemberRemove.handle({ this.client.actions.GuildMemberRemove.handle({
guild_id: this.guild.id, guild_id: this.guild.id,
user: this.user, user: this.user,
}).member }).member
); );
} }
/** /**

View File

@@ -11,7 +11,6 @@ const Collector = require('./interfaces/Collector');
* @extends {Collector} * @extends {Collector}
*/ */
class MessageCollector extends Collector { class MessageCollector extends Collector {
/** /**
* @param {TextChannel|DMChannel|GroupDMChannel} channel The channel * @param {TextChannel|DMChannel|GroupDMChannel} channel The channel
* @param {CollectorFilter} filter The filter to be applied to this collector * @param {CollectorFilter} filter The filter to be applied to this collector

View File

@@ -13,7 +13,6 @@ const Collection = require('../util/Collection');
* @extends {Collector} * @extends {Collector}
*/ */
class ReactionCollector extends Collector { class ReactionCollector extends Collector {
/** /**
* @param {Message} message The message upon which to collect reactions * @param {Message} message The message upon which to collect reactions
* @param {CollectorFilter} filter The filter to apply to this collector * @param {CollectorFilter} filter The filter to apply to this collector

View File

@@ -212,7 +212,7 @@ class Role {
}, },
reason, reason,
}) })
.then(role => this.client.actions.GuildRoleUpdate.handle({ role, guild_id: this.guild.id }).updated); .then(role => this.client.actions.GuildRoleUpdate.handle({ role, guild_id: this.guild.id }).updated);
} }
/** /**
@@ -312,9 +312,9 @@ class Role {
*/ */
delete(reason) { delete(reason) {
return this.client.api.guilds[this.guild.id].roles[this.id].delete({ reason }) return this.client.api.guilds[this.guild.id].roles[this.id].delete({ reason })
.then(() => .then(() =>
this.client.actions.GuildRoleDelete.handle({ guild_id: this.guild.id, role_id: this.id }).role this.client.actions.GuildRoleDelete.handle({ guild_id: this.guild.id, role_id: this.id }).role
); );
} }
/** /**

View File

@@ -204,7 +204,7 @@ class User {
return this.client.api.users[this.client.user.id].channels.post({ data: { return this.client.api.users[this.client.user.id].channels.post({ data: {
recipient_id: this.id, recipient_id: this.id,
} }) } })
.then(data => this.client.actions.ChannelCreate.handle(data).channel); .then(data => this.client.actions.ChannelCreate.handle(data).channel);
} }
/** /**
@@ -213,9 +213,8 @@ class User {
*/ */
deleteDM() { deleteDM() {
if (!this.dmChannel) return Promise.reject(new Error('No DM Channel exists!')); if (!this.dmChannel) return Promise.reject(new Error('No DM Channel exists!'));
return this.client.api.channels[this.dmChannel.id].delete().then(data => return this.client.api.channels[this.dmChannel.id].delete()
this.client.actions.ChannelDelete.handle(data).channel .then(data => this.client.actions.ChannelDelete.handle(data).channel);
);
} }
/** /**

View File

@@ -133,18 +133,18 @@ class TextBasedChannel {
const Message = require('../Message'); const Message = require('../Message');
if (!this.client.user.bot) { if (!this.client.user.bot) {
return this.fetchMessages({ limit: 1, around: messageID }) return this.fetchMessages({ limit: 1, around: messageID })
.then(messages => { .then(messages => {
const msg = messages.get(messageID); const msg = messages.get(messageID);
if (!msg) throw new Error('MESSAGE_MISSING'); if (!msg) throw new Error('MESSAGE_MISSING');
return msg; return msg;
}); });
} }
return this.client.api.channels[this.id].messages[messageID].get() return this.client.api.channels[this.id].messages[messageID].get()
.then(data => { .then(data => {
const msg = data instanceof Message ? data : new Message(this, data, this.client); const msg = data instanceof Message ? data : new Message(this, data, this.client);
this._cacheMessage(msg); this._cacheMessage(msg);
return msg; return msg;
}); });
} }
/** /**
@@ -170,15 +170,15 @@ class TextBasedChannel {
fetchMessages(options = {}) { fetchMessages(options = {}) {
const Message = require('../Message'); const Message = require('../Message');
return this.client.api.channels[this.id].messages.get({ query: options }) return this.client.api.channels[this.id].messages.get({ query: options })
.then(data => { .then(data => {
const messages = new Collection(); const messages = new Collection();
for (const message of data) { for (const message of data) {
const msg = new Message(this, message, this.client); const msg = new Message(this, message, this.client);
messages.set(message.id, msg); messages.set(message.id, msg);
this._cacheMessage(msg); this._cacheMessage(msg);
} }
return messages; return messages;
}); });
} }
/** /**
@@ -350,13 +350,13 @@ class TextBasedChannel {
); );
} }
return this.client.api.channels[this.id].messages['bulk-delete'] return this.client.api.channels[this.id].messages['bulk-delete']
.post({ data: { messages: messageIDs } }) .post({ data: { messages: messageIDs } })
.then(() => .then(() =>
this.client.actions.MessageDeleteBulk.handle({ this.client.actions.MessageDeleteBulk.handle({
channel_id: this.id, channel_id: this.id,
ids: messageIDs, ids: messageIDs,
}).messages }).messages
); );
} }
throw new TypeError('MESSAGE_BULK_DELETE_TYPE'); throw new TypeError('MESSAGE_BULK_DELETE_TYPE');
} }

View File

@@ -11,9 +11,10 @@ const version = require('./package.json').version;
const createConfig = options => { const createConfig = options => {
const plugins = [ const plugins = [
new webpack.DefinePlugin({ 'global.GENTLY': false }), new webpack.DefinePlugin({ 'global.GENTLY': false }),
new webpack.optimize.ModuleConcatenationPlugin(),
]; ];
if (options.minify) plugins.push(new UglifyJSPlugin({ minimize: true })); if (options.minify) plugins.push(new UglifyJSPlugin({ uglifyOptions: { output: { comments: false } } }));
const filename = `./webpack/discord${process.env.VERSIONED === 'false' ? '' : '.' + version}${options.minify ? '.min' : ''}.js`; // eslint-disable-line const filename = `./webpack/discord${process.env.VERSIONED === 'false' ? '' : '.' + version}${options.minify ? '.min' : ''}.js`; // eslint-disable-line