mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Update dependencies & make webpack great again
This commit is contained in:
15
package.json
15
package.json
@@ -34,7 +34,7 @@
|
||||
"dependencies": {
|
||||
"long": "^3.2.0",
|
||||
"prism-media": "^0.0.1",
|
||||
"snekfetch": "^3.1.0",
|
||||
"snekfetch": "^3.2.0",
|
||||
"tweetnacl": "^1.0.0",
|
||||
"ws": "^3.0.0"
|
||||
},
|
||||
@@ -45,16 +45,15 @@
|
||||
"opusscript": "^0.0.3",
|
||||
"sodium": "^2.0.1",
|
||||
"libsodium-wrappers": "^0.5.1",
|
||||
"uws": "^0.14.1"
|
||||
"uws": "^8.14.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^7.0.0",
|
||||
"@types/node": "^8.0.0",
|
||||
"discord.js-docgen": "hydrabolt/discord.js-docgen",
|
||||
"eslint": "^3.19.0",
|
||||
"parallel-webpack": "^1.6.0",
|
||||
"uglify-js": "mishoo/UglifyJS2#harmony-v2.8.22",
|
||||
"uglifyjs-webpack-plugin": "^0.4.3",
|
||||
"webpack": "^2.2.0"
|
||||
"eslint": "^4.0.0",
|
||||
"parallel-webpack": "^2.0.0",
|
||||
"uglifyjs-webpack-plugin": "iCrawl/uglifyjs-webpack-plugin",
|
||||
"webpack": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
|
||||
@@ -415,7 +415,7 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
fetchApplication(id = '@me') {
|
||||
return this.api.oauth2.applications[id].get()
|
||||
.then(app => new OAuth2Application(this, app));
|
||||
.then(app => new OAuth2Application(this, app));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -193,11 +193,11 @@ class ClientDataResolver {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (/^https?:\/\//.test(resource)) {
|
||||
snekfetch.get(resource)
|
||||
.end((err, res) => {
|
||||
if (err) return reject(err);
|
||||
if (!(res.body instanceof Buffer)) return reject(new TypeError('REQ_BODY_TYPE'));
|
||||
return resolve(res.body);
|
||||
});
|
||||
.end((err, res) => {
|
||||
if (err) return reject(err);
|
||||
if (!(res.body instanceof Buffer)) return reject(new TypeError('REQ_BODY_TYPE'));
|
||||
return resolve(res.body);
|
||||
});
|
||||
} else {
|
||||
const file = path.resolve(resource);
|
||||
fs.stat(file, (err, stats) => {
|
||||
|
||||
@@ -136,7 +136,7 @@ class GroupDMChannel extends Channel {
|
||||
{ nick, access_token: accessTokenOrUser } :
|
||||
{ recipient: id };
|
||||
return this.client.api.channels[this.id].recipients[id].put({ data })
|
||||
.then(() => this);
|
||||
.then(() => this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -394,14 +394,14 @@ class Guild {
|
||||
*/
|
||||
fetchInvites() {
|
||||
return this.client.api.guilds[this.id].invites.get()
|
||||
.then(inviteItems => {
|
||||
const invites = new Collection();
|
||||
for (const inviteItem of inviteItems) {
|
||||
const invite = new Invite(this.client, inviteItem);
|
||||
invites.set(invite.code, invite);
|
||||
}
|
||||
return invites;
|
||||
});
|
||||
.then(inviteItems => {
|
||||
const invites = new Collection();
|
||||
for (const inviteItem of inviteItems) {
|
||||
const invite = new Invite(this.client, inviteItem);
|
||||
invites.set(invite.code, invite);
|
||||
}
|
||||
return invites;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -490,10 +490,10 @@ class Guild {
|
||||
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));
|
||||
return this.client.api.guilds[this.id].members[user.id].get()
|
||||
.then(data => {
|
||||
if (cache) return this.client.actions.GuildMemberGet.handle(this, data).member;
|
||||
else return new GuildMember(this, data);
|
||||
});
|
||||
.then(data => {
|
||||
if (cache) return this.client.actions.GuildMemberGet.handle(this, data).member;
|
||||
else return new GuildMember(this, data);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -594,7 +594,7 @@ class Guild {
|
||||
_data.explicit_content_filter = Number(data.explicitContentFilter);
|
||||
}
|
||||
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() {
|
||||
return this.client.api.guilds[this.id].ack
|
||||
.post({ data: { token: this.client.rest._ackToken } })
|
||||
.then(res => {
|
||||
if (res.token) this.client.rest._ackToken = res.token;
|
||||
return this;
|
||||
});
|
||||
.post({ data: { token: this.client.rest._ackToken } })
|
||||
.then(res => {
|
||||
if (res.token) this.client.rest._ackToken = res.token;
|
||||
return this;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -778,15 +778,15 @@ class Guild {
|
||||
const id = this.client.resolver.resolveUserID(user);
|
||||
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 })
|
||||
.then(() => {
|
||||
if (user instanceof GuildMember) return user;
|
||||
const _user = this.client.resolver.resolveUser(id);
|
||||
if (_user) {
|
||||
const member = this.client.resolver.resolveGuildMember(this, _user);
|
||||
return member || _user;
|
||||
}
|
||||
return id;
|
||||
});
|
||||
.then(() => {
|
||||
if (user instanceof GuildMember) return user;
|
||||
const _user = this.client.resolver.resolveUser(id);
|
||||
if (_user) {
|
||||
const member = this.client.resolver.resolveGuildMember(this, _user);
|
||||
return member || _user;
|
||||
}
|
||||
return id;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -965,10 +965,10 @@ class Guild {
|
||||
.then(emoji => this.client.actions.GuildEmojiCreate.handle(this, emoji).emoji);
|
||||
} else {
|
||||
return this.client.resolver.resolveBuffer(attachment)
|
||||
.then(data => {
|
||||
const dataURI = this.client.resolver.resolveBase64(data);
|
||||
return this.createEmoji(dataURI, name, roles);
|
||||
});
|
||||
.then(data => {
|
||||
const dataURI = this.client.resolver.resolveBase64(data);
|
||||
return this.createEmoji(dataURI, name, roles);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -980,7 +980,7 @@ class Guild {
|
||||
deleteEmoji(emoji) {
|
||||
if (!(emoji instanceof Emoji)) emoji = this.emojis.get(emoji);
|
||||
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() {
|
||||
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()
|
||||
.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() {
|
||||
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 }));
|
||||
return this.client.api.guilds[this.id].roles.patch({ data: updatedRoles })
|
||||
.then(() =>
|
||||
this.client.actions.GuildRolesPositionUpdate.handle({
|
||||
guild_id: this.id,
|
||||
roles: updatedRoles,
|
||||
}).guild
|
||||
);
|
||||
.then(() =>
|
||||
this.client.actions.GuildRolesPositionUpdate.handle({
|
||||
guild_id: this.id,
|
||||
roles: updatedRoles,
|
||||
}).guild
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1197,12 +1197,12 @@ class Guild {
|
||||
|
||||
updatedChannels = updatedChannels.map((r, i) => ({ id: r.id, position: i }));
|
||||
return this.client.api.guilds[this.id].channels.patch({ data: updatedChannels })
|
||||
.then(() =>
|
||||
this.client.actions.GuildChannelsPositionUpdate.handle({
|
||||
guild_id: this.id,
|
||||
roles: updatedChannels,
|
||||
}).guild
|
||||
);
|
||||
.then(() =>
|
||||
this.client.actions.GuildChannelsPositionUpdate.handle({
|
||||
guild_id: this.id,
|
||||
roles: updatedChannels,
|
||||
}).guild
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1229,8 +1229,8 @@ class Guild {
|
||||
_sortPositionWithID(collection) {
|
||||
return collection.sort((a, b) =>
|
||||
a.position !== b.position ?
|
||||
a.position - b.position :
|
||||
Long.fromString(a.id).sub(Long.fromString(b.id)).toNumber()
|
||||
a.position - b.position :
|
||||
Long.fromString(a.id).sub(Long.fromString(b.id)).toNumber()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,12 +485,12 @@ class GuildMember {
|
||||
*/
|
||||
kick(reason) {
|
||||
return this.client.api.guilds[this.guild.id].members[this.user.id].delete({ reason })
|
||||
.then(() =>
|
||||
this.client.actions.GuildMemberRemove.handle({
|
||||
guild_id: this.guild.id,
|
||||
user: this.user,
|
||||
}).member
|
||||
);
|
||||
.then(() =>
|
||||
this.client.actions.GuildMemberRemove.handle({
|
||||
guild_id: this.guild.id,
|
||||
user: this.user,
|
||||
}).member
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,6 @@ const Collector = require('./interfaces/Collector');
|
||||
* @extends {Collector}
|
||||
*/
|
||||
class MessageCollector extends Collector {
|
||||
|
||||
/**
|
||||
* @param {TextChannel|DMChannel|GroupDMChannel} channel The channel
|
||||
* @param {CollectorFilter} filter The filter to be applied to this collector
|
||||
|
||||
@@ -13,7 +13,6 @@ const Collection = require('../util/Collection');
|
||||
* @extends {Collector}
|
||||
*/
|
||||
class ReactionCollector extends Collector {
|
||||
|
||||
/**
|
||||
* @param {Message} message The message upon which to collect reactions
|
||||
* @param {CollectorFilter} filter The filter to apply to this collector
|
||||
|
||||
@@ -212,7 +212,7 @@ class Role {
|
||||
},
|
||||
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) {
|
||||
return this.client.api.guilds[this.guild.id].roles[this.id].delete({ reason })
|
||||
.then(() =>
|
||||
this.client.actions.GuildRoleDelete.handle({ guild_id: this.guild.id, role_id: this.id }).role
|
||||
);
|
||||
.then(() =>
|
||||
this.client.actions.GuildRoleDelete.handle({ guild_id: this.guild.id, role_id: this.id }).role
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -204,7 +204,7 @@ class User {
|
||||
return this.client.api.users[this.client.user.id].channels.post({ data: {
|
||||
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() {
|
||||
if (!this.dmChannel) return Promise.reject(new Error('No DM Channel exists!'));
|
||||
return this.client.api.channels[this.dmChannel.id].delete().then(data =>
|
||||
this.client.actions.ChannelDelete.handle(data).channel
|
||||
);
|
||||
return this.client.api.channels[this.dmChannel.id].delete()
|
||||
.then(data => this.client.actions.ChannelDelete.handle(data).channel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -133,18 +133,18 @@ class TextBasedChannel {
|
||||
const Message = require('../Message');
|
||||
if (!this.client.user.bot) {
|
||||
return this.fetchMessages({ limit: 1, around: messageID })
|
||||
.then(messages => {
|
||||
const msg = messages.get(messageID);
|
||||
if (!msg) throw new Error('MESSAGE_MISSING');
|
||||
return msg;
|
||||
});
|
||||
.then(messages => {
|
||||
const msg = messages.get(messageID);
|
||||
if (!msg) throw new Error('MESSAGE_MISSING');
|
||||
return msg;
|
||||
});
|
||||
}
|
||||
return this.client.api.channels[this.id].messages[messageID].get()
|
||||
.then(data => {
|
||||
const msg = data instanceof Message ? data : new Message(this, data, this.client);
|
||||
this._cacheMessage(msg);
|
||||
return msg;
|
||||
});
|
||||
.then(data => {
|
||||
const msg = data instanceof Message ? data : new Message(this, data, this.client);
|
||||
this._cacheMessage(msg);
|
||||
return msg;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,15 +170,15 @@ class TextBasedChannel {
|
||||
fetchMessages(options = {}) {
|
||||
const Message = require('../Message');
|
||||
return this.client.api.channels[this.id].messages.get({ query: options })
|
||||
.then(data => {
|
||||
const messages = new Collection();
|
||||
for (const message of data) {
|
||||
const msg = new Message(this, message, this.client);
|
||||
messages.set(message.id, msg);
|
||||
this._cacheMessage(msg);
|
||||
}
|
||||
return messages;
|
||||
});
|
||||
.then(data => {
|
||||
const messages = new Collection();
|
||||
for (const message of data) {
|
||||
const msg = new Message(this, message, this.client);
|
||||
messages.set(message.id, msg);
|
||||
this._cacheMessage(msg);
|
||||
}
|
||||
return messages;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,13 +350,13 @@ class TextBasedChannel {
|
||||
);
|
||||
}
|
||||
return this.client.api.channels[this.id].messages['bulk-delete']
|
||||
.post({ data: { messages: messageIDs } })
|
||||
.then(() =>
|
||||
this.client.actions.MessageDeleteBulk.handle({
|
||||
channel_id: this.id,
|
||||
ids: messageIDs,
|
||||
}).messages
|
||||
);
|
||||
.post({ data: { messages: messageIDs } })
|
||||
.then(() =>
|
||||
this.client.actions.MessageDeleteBulk.handle({
|
||||
channel_id: this.id,
|
||||
ids: messageIDs,
|
||||
}).messages
|
||||
);
|
||||
}
|
||||
throw new TypeError('MESSAGE_BULK_DELETE_TYPE');
|
||||
}
|
||||
|
||||
@@ -11,9 +11,10 @@ const version = require('./package.json').version;
|
||||
const createConfig = options => {
|
||||
const plugins = [
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user