mirror of
https://github.com/discordjs/discord.js.git
synced 2026-05-23 03:50:09 +00:00
Compare commits
6 Commits
@discordjs
...
v11
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da39e858a1 | ||
|
|
747d76de10 | ||
|
|
de0cacdf32 | ||
|
|
bb4cb3e7fe | ||
|
|
08865a98cd | ||
|
|
20075e306b |
@@ -23,7 +23,7 @@ The usage of the API isn't any different from using it in Node.js.
|
||||
|
||||
## Example
|
||||
```html
|
||||
<script type="text/javascript" src="discord.11.5.0.min.js"></script>
|
||||
<script type="text/javascript" src="discord.11.6.4.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
const client = new Discord.Client();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "discord.js",
|
||||
"version": "11.6.1",
|
||||
"version": "11.6.4",
|
||||
"description": "A powerful library for interacting with the Discord API",
|
||||
"main": "./src/index",
|
||||
"types": "./typings/index.d.ts",
|
||||
|
||||
@@ -15,13 +15,17 @@ class APIRequest {
|
||||
}
|
||||
|
||||
getRoute(url) {
|
||||
let route = url.split('?')[0];
|
||||
if (route.includes('/channels/') || route.includes('/guilds/')) {
|
||||
const startInd = route.includes('/channels/') ? route.indexOf('/channels/') : route.indexOf('/guilds/');
|
||||
const majorID = route.substring(startInd).split('/')[2];
|
||||
route = route.replace(/(\d{8,})/g, ':id').replace(':id', majorID);
|
||||
const route = url.split('?')[0].split('/');
|
||||
const routeBucket = [];
|
||||
for (let i = 0; i < route.length; i++) {
|
||||
// Reactions routes and sub-routes all share the same bucket
|
||||
if (route[i - 1] === 'reactions') break;
|
||||
// Literal IDs should only be taken account if they are the Major ID (the Channel/Guild ID)
|
||||
if (/\d{16,19}/g.test(route[i]) && !/channels|guilds/.test(route[i - 1])) routeBucket.push(':id');
|
||||
// All other parts of the route should be considered as part of the bucket identifier
|
||||
else routeBucket.push(route[i]);
|
||||
}
|
||||
return route;
|
||||
return routeBucket.join('/');
|
||||
}
|
||||
|
||||
getAuth() {
|
||||
|
||||
@@ -55,7 +55,7 @@ class WebSocketPacketManager {
|
||||
this.register(Constants.WSEvents.RELATIONSHIP_REMOVE, require('./handlers/RelationshipRemove'));
|
||||
this.register(Constants.WSEvents.MESSAGE_REACTION_ADD, require('./handlers/MessageReactionAdd'));
|
||||
this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE, require('./handlers/MessageReactionRemove'));
|
||||
this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE, require('./handlers/MessageReactionRemoveEmoji'));
|
||||
this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE_EMOJI, require('./handlers/MessageReactionRemoveEmoji'));
|
||||
this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE_ALL, require('./handlers/MessageReactionRemoveAll'));
|
||||
this.register(Constants.WSEvents.WEBHOOKS_UPDATE, require('./handlers/WebhooksUpdate'));
|
||||
}
|
||||
|
||||
@@ -41,6 +41,11 @@ class ReactionCollector extends Collector {
|
||||
|
||||
if (this.client.getMaxListeners() !== 0) this.client.setMaxListeners(this.client.getMaxListeners() + 1);
|
||||
this.client.on('messageReactionAdd', this.listener);
|
||||
|
||||
this.on('fullCollect', (reaction, user) => {
|
||||
this.users.set(user.id, user);
|
||||
this.total++;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,9 +69,8 @@ class ReactionCollector extends Collector {
|
||||
* @returns {?string} Reason to end the collector, if any
|
||||
* @private
|
||||
*/
|
||||
postCheck(reaction, user) {
|
||||
this.users.set(user.id, user);
|
||||
if (this.options.max && ++this.total >= this.options.max) return 'limit';
|
||||
postCheck() {
|
||||
if (this.options.max && this.total >= this.options.max) return 'limit';
|
||||
if (this.options.maxEmojis && this.collected.size >= this.options.maxEmojis) return 'emojiLimit';
|
||||
if (this.options.maxUsers && this.users.size >= this.options.maxUsers) return 'userLimit';
|
||||
return null;
|
||||
|
||||
@@ -99,6 +99,14 @@ class Collector extends EventEmitter {
|
||||
*/
|
||||
this.emit('collect', collect.value, this);
|
||||
|
||||
/**
|
||||
* Emitted whenever an element is collected.
|
||||
* @event Collector#fullCollect
|
||||
* @param {...*} args The arguments emitted by the listener
|
||||
* @private
|
||||
*/
|
||||
this.emit('fullCollect', ...args, this);
|
||||
|
||||
if (this._idletimeout) {
|
||||
this.client.clearTimeout(this._idletimeout);
|
||||
this._idletimeout = this.client.setTimeout(() => this.stop('idle'), this.options.idle);
|
||||
|
||||
@@ -478,7 +478,7 @@ exports.WSEvents = {
|
||||
MESSAGE_DELETE_BULK: 'MESSAGE_DELETE_BULK',
|
||||
MESSAGE_REACTION_ADD: 'MESSAGE_REACTION_ADD',
|
||||
MESSAGE_REACTION_REMOVE: 'MESSAGE_REACTION_REMOVE',
|
||||
MESSAGE_REACTION_RMEOVE_EMOJI: 'MESSAGE_REACTION_REMOVE_EMOJI',
|
||||
MESSAGE_REACTION_REMOVE_EMOJI: 'MESSAGE_REACTION_REMOVE_EMOJI',
|
||||
MESSAGE_REACTION_REMOVE_ALL: 'MESSAGE_REACTION_REMOVE_ALL',
|
||||
USER_UPDATE: 'USER_UPDATE',
|
||||
USER_NOTE_UPDATE: 'USER_NOTE_UPDATE',
|
||||
|
||||
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for discord.js 11.6.1
|
||||
// Type definitions for discord.js 11.6.4
|
||||
// Project: https://github.com/discordjs/discord.js
|
||||
// Definitions by:
|
||||
// acdenisSK <acdenissk69@gmail.com> (https://github.com/acdenisSK)
|
||||
|
||||
Reference in New Issue
Block a user