Commit Graph

1104 Commits

Author SHA1 Message Date
BorgerKing
bbdbc4cfa7 feat: remove datastores and implement Managers (#3696)
* Initial commit: add 5 initial managers

- Base manager
- GuildChannelManager
- MessageManager
- PresenceManager
- Reaction Manager
- Added LimitedCollection

* Add GuildEmojiManager, various fixes

* Modify some managers and add guildmembermanager

* Initial integration

* Delete old stores

* Integration part two, removed LRUCollection

- Most of the integration has been finished
- TODO typings
- Removed LRUCollection, needless sweeping

* Typings + stuff i somehow missed in ChannelManager

* LimitedCollection typings/ final changes

* Various jsdoc and syntactical fixes, Removed Util.mixin()

* tslint fix

* Grammatical and logical changes

* Delete temporary file placed by mistake

* Grammatical changes

* Add missing type

* Update jsdoc examples

* fix: ChannelManager#remove should call cache#delete not cache#remove

* fix recursive require

* Fix missed cache in util

* fix: more missed cache

* Remove accidental _fetchMany change from #3645

* fix: use .cache.delete() over .remove()

* fix: missing cache in ReactionCollector

* fix: missed cache in client

* fix: members is a collection not a manager

Co-Authored-By: Sugden <28943913+NotSugden@users.noreply.github.com>

* fix: various docs and cache fixes

* fix: missed cache

* fix: missing _roles

* Final testing and debugging

* LimitedCollection: return the Collection instead of undefined on .set

* Add cache to BaseManager in typings

* Commit fixes i forgot to stage yesterday

* Update invite events

* Account for new commit

* fix: MessageReactionRemoveAll should call .cache.clear()

* fix: add .cache at various places, correct return type

* docs: remove mentions of 'store'

* Add extra documented properties to typings

Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
2020-02-11 20:21:07 +01:00
Vlad Frangu
b4e56d3e0e src: fix up WebSocketShard errors (#3722)
* src: Fix up WebSocketShard errors

* typings: Forgot to update

* src: Forgot debug variable

* src: Fix issue Bella found
If the WS was not connected when the HELLO timeout passes
(CONNECTING, etc), the shard would get stuck
due to never rejecting the WebSocketShard#connect
Promise with the DESTROYED event
2020-02-02 11:12:58 +01:00
BorgerKing
030d263a9e feat(MessageReaction): add remove method and Client#messageReactionRemoveEmoji (#3723)
* Add support for MessageReaction#remove and MESSAGE_REACTION_REMOVE_EMOJI

* Remove reaction from cache

Co-Authored-By: matthewfripp <50251454+matthewfripp@users.noreply.github.com>

* fix: message may be partial

* Clarify what the event entails

* Document client in MessageReaction

Co-Authored-By: SpaceEEC <spaceeec@yahoo.com>

* await the REST call

* Add MessageReaction#remove to typings

Co-authored-by: matthewfripp <50251454+matthewfripp@users.noreply.github.com>
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
2020-01-25 20:00:53 +01:00
Gryffon Bellish
b81f771007 cleanup: fix deepscan issues (#3740)
* fix: don't double check if shards are auto.

* fix: remove useless roles array.

* fix: remove useless undefined checks.

* fix: remove useless `this` binding

* Apply suggestions from code review

Co-Authored-By: Sugden <28943913+NotSugden@users.noreply.github.com>

* Fix: Space's suggestion

* Fix: time is always truthy

* Check if it's an invalid date.

Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
2020-01-24 16:58:23 +01:00
BorgerKing
929ff9ccd0 feat(Client): add support for INVITE_CREATE and INVITE_DELETE events (#3720)
* Add support for new Invite events

* Merge typings for events

Co-Authored-By: Sugden <leoaustin675@gmail.com>

* Add warning about requiring permissions

* Null check channel and guild

* fix: .guilds not .channels
2020-01-24 16:38:26 +01:00
Amish Shah
629c57f890 fix: regression (changing voice servers) 2020-01-13 22:29:05 +00:00
Vlad Frangu
c23cc7a42e src: Cleanup event listeners on WebSocket connections (#3681)
* src: Cleanup event listeners on WebSocket connections
Should prevent #3641 from happening, as well as double connections on a shard

* typings: Forgot to add the method
2020-01-13 18:53:07 +00:00
izexi
6af0da1043 feat(Partials): add DMChannel/MessageReaction#fetch() and PartialTypes.REACTION (#3474)
* add DMChannel#fetch() & Action#getChannel({recipients})

* ref for MessageReaction partial

* typings

* add PartialTypes.REACTION

* accommodate for fully removed reactions

* fix incorrect wording and typo

* typings: MessageReaction#count is nullable

* typings: mark MessageReaction#partial as readonly

Co-Authored-By: Vlad Frangu <kingdgrizzle@gmail.com>

* fix(User): fetch dm channel if cached one is partial

* docs: add missing comma

Co-Authored-By: Antonio Román <kyradiscord@gmail.com>

* fix: accomodate for new reactions

* fix: updating existing/new count on _patch

* docs: typo

* for consistency

Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
Co-authored-by: Antonio Román <kyradiscord@gmail.com>
2020-01-05 16:45:49 +01:00
Vlad Frangu
710101c580 src(WebSocket): fix race condition (#3636)
A race condition caused Client#user to be null in the ready event if the client handled 0 guilds.
2019-12-22 10:31:26 +01:00
Vlad Frangu
5519d6fbaa src: sharding cleanup and checkReady rewrite (#3393)
* src: Step 1 of who knows how many

* src: Remove accidentally committed test file

* src: Remove useless added property in package.json

* docs: Trailing spaces, come back >.>

* src: Buhbye uws, we will miss you..not!

* src: Move 'auto' shard selection from totalShardCount to shards

* src: tweak

* src: Filter out floats from shard IDs
You want half of a shard or what?

* src: Misc cleanup and bugfix for GUILD_BAN_ADD

* src: Rewrite checkReady

* src: Misse this while merging master into my branch

* typings: Bring these up to date

* typings: Forgot allReady event

* src: Don't checkReady if the shard isn't waiting for guilds

* src: Fix a possible bug for when the ws dies and the session becomes -1

* src: Hopefully fix last edge case that could case a shard to infinitely boot loop

* src: Rename totalShardCount to shardCount

* src: Small bugfix

* src: Correct error message for shardCount being imvalid

Co-Authored-By: bdistin <bdistin@gmail.com>

* src: Small tweaks

* src: If this doesn't fix the issues I'm gonna throw a brick at my PC

* src: I swear, STOP BREAKING

* src: *groans at a certain snake*

* src: Use undefined instead of null on destroy in close event

Setting it to null sets the close code to null, which causes a WebSocket error to be thrown. The error is thrown from WebSocket, although there is no connection alive. Fun times!

* src: @SpaceEEC's requested changes

* src: Remove zucc from discord.js

Discord is removing support for it, sooo... Bye bye

* src: Missed this

* src: Apply @kyranet's suggestions

Co-Authored-By: Antonio Román <kyradiscord@gmail.com>

* src: @kyranet's suggestions

* src: Remove pako, update debug messages
- Pako is officially gone from both enviroments
  Install zlib-sync on node.js if you want it
- Improve a few debug messages some more
- Discover that internal sharding works in browsers but please don't do that
2019-12-15 20:45:27 +01:00
sillyfrog
4585d965b4 Start/Stop speaking events on UDP packets (#3578)
* Start/Stop speaking using incomming UDP packets

* Fix ESLint errors

* Updates for styling consistency

Co-Authored-By: Gryffon Bellish <owenbellish@gmail.com>

* Minor improvements

* Acutally use previousTimeout

* Use BaseClient setTimeout and refresh()

* Update README to match node version for refresh()

* Update comment to match startSpeaking

* Correctly report Priority bit

* Fix ESlint errors
2019-12-06 11:59:57 +00:00
Clemens E
bb8333a4f9 Handle voice errors outside of authenticated event (#3520) 2019-12-06 11:56:29 +00:00
Marwin M
3a9eb5b929 Fix Opus voice streams (#3555)
This fixes a wrong assumption about incoming discord voice packets revealed during a recent discord change that broke incoming opus voice streams
2019-10-29 12:22:21 +00:00
Gryffon Bellish
9bcb6a04ba fix(VoiceConnection): clear timeouts using Client#clearTimeout (#3553)
* Update VoiceConnection.js

* fix last instance
2019-10-27 16:58:38 +01:00
Antonio Román
a61cfc3004 docs: VoiceStateUpdate always sends an instance of VoiceState (#3537)
* docs: VoiceStateUpdate always sends the old

* typings: Update definition for voiceStateUpdate event
2019-10-18 11:32:19 +02:00
Souji
48856c0815 fix: set messages deleted when their channel is deleted (#3519) 2019-10-04 16:44:04 +02:00
Crawl
321beb73bd revert: "feat(Partials): add DMChannel/MessageReaction#fetch()… (#3468)
This reverts commit b0047c424b.
2019-09-10 19:49:56 +02:00
izexi
b0047c424b feat(Partials): add DMChannel/MessageReaction#fetch() and Parti… (#3261)
* add DMChannel#fetch() & Action#getChannel({recipients})

* ref for MessageReaction partial

* typings

* add PartialTypes.REACTION

* accommodate for fully removed reactions

* fix incorrect wording and typo

* typings: MessageReaction#count is nullable

* typings: mark MessageReaction#partial as readonly

Co-Authored-By: Vlad Frangu <kingdgrizzle@gmail.com>

* fix(User): fetch dm channel if cached one is partial

* docs: add missing comma

Co-Authored-By: Antonio Román <kyradiscord@gmail.com>
2019-09-10 16:09:06 +02:00
iCrawl
4fc461c2f9 fix: browser-compatability
Fix #3453
2019-09-08 11:47:46 +02:00
Schuyler Cebulskie
4b34f1acbe Remove past-tense naming on shard events 2019-08-31 17:14:48 -04:00
Amish Shah
c715ed9f8b voice: remove passes
(discord will begin dropping duplicated audio packets from tomorrow, you should not set passes > 1)
2019-08-22 12:15:20 +01:00
Saya
e4309b23d5 feat: abort Requests that takes a lot of time to resolve (#3327)
* Add Request Timeout

* Add abort controller in packages

* Fix Lint Error.

* Fix Lint Errors

* Make Timeout Customizable & use finally

* Fixed a minor issue

* Fix eslint

* Update request timeout to use d.js client timeout methods.
2019-08-19 18:55:07 +02:00
Amish Shah
c6e8fccbf0 voice: fix #3418
(kicking bot from voice channel doesn't allow it to rejoin)
2019-08-17 13:42:22 +01:00
Amish Shah
2c4d14a71b voice: remove redundant debug info 2019-08-14 19:22:41 +01:00
Kitten King
d8516efa36 docs: fix typos (#3404) 2019-07-25 17:18:23 +02:00
SpaceEEC
6cd4c27fae docs(Client): fetchVoiceRegions returns a promise 2019-06-08 16:18:50 +02:00
DeJay
5aa9425040 Removes the trace packet (#3312)
* Removes the trace packet

* Update src/client/websocket/WebSocketShard.js

Co-Authored-By: Amish Shah <amishshah.2k@gmail.com>

* Update src/client/websocket/WebSocketShard.js

Co-Authored-By: Amish Shah <amishshah.2k@gmail.com>
2019-05-30 19:57:34 +01:00
Amish Shah
8652e47c14 fix: decode voice ws data as json 2019-05-28 14:51:41 +01:00
Amish Shah
b5aff6d120 remove member voice state after emitting leave event 2019-05-28 10:00:57 +01:00
Gus Caplan
065908956b fix websocket unpacking (#3301) 2019-05-27 18:13:25 +01:00
Amish Shah
db56e0cbae fix: delete VoiceStates even for uncached members 2019-05-27 18:09:54 +01:00
Amish Shah
949488bbbd Fix #3218 2019-05-27 14:04:13 +01:00
anandre
34006cb51e docs(StreamDispatcher): specify pausedTime is in milliseconds (#3295)
* Update TextChannel.js

Update `setRateLimitPerUser` description to specify the `number` is in seconds, per the Discord docs

* Update TextChannel.js

Add unit to the rateLimitPerUser property

* Update GuildChannel.js

* Update StreamDispatcher.js

Specify unit for `StreamDispatcher.pausedTime`
2019-05-24 20:33:40 +02:00
SpaceEEC
1bafa4b86b fix(READY): do not overwrite Client#user when reidentifying
See #3216, this commit attempts to fix losing ClientUser#_typing, which results in no longer being able to clear typing intervals
2019-05-16 19:56:19 +02:00
SpaceEEC
16fcfa3db3 fix(WebSocketManager): rethrow unknown errors when connecting a WebSocketShard 2019-05-15 22:13:12 +02:00
Amish Shah
72dd872fce VoiceBroadcast.{dispatchers -> subscribers} 2019-05-12 20:29:28 +01:00
izexi
75d5598fda import TextDecoder from Util (#3258) 2019-05-08 21:03:18 +01:00
izexi
0dd3ed72ef fix(Partials): Client#event:messageUpdate(oldMessage) and MessageReactionAdd on guild channels (#3250)
* ref: add getPayload and use for other get* methods

* return existing data.*

* use Action.getUser()
2019-05-07 20:56:39 +01:00
Gus Caplan
3d4513268d Add optional zstd for faster WebSocket data inflation (#3223)
* zstd
2019-05-07 14:30:34 +01:00
Darqam
8915bc1d37 docs:(Client): disambiguate the description of channels collection (#3251)
* Disambiguate the description of <client>.channels

Although not explicitly said, the current wording makes it seem like all channels are cached and available at any time in this store. Hopefully this variation makes it a bit clearer.

* make more explicit (I think)

* remove trailing white spaces
2019-05-06 20:08:56 +02:00
izexi
176fc47699 feat(Actions): use partials for messageDeleteBulk (#3240)
* make use of partials

* don't cache the messages

* pass each message within the for..of iteration
2019-05-03 17:38:57 +02:00
Jacz
692494dc04 feat(VoiceState): self mute/deaf methods (#3243)
* Implemented setSelfMute/Deaf, done typings, fixed bug in VoiceState with errors.

* Completed requested changes

* return send in sendVoiceStateUpdate so its a promise, update typings

* Updated methods to return a boolean

* Requested changes

* Fix bug

* Update src/structures/VoiceState.js

Co-Authored-By: MrJacz <23615291+MrJacz@users.noreply.github.com>

* fix
2019-05-03 17:11:11 +02:00
Vlad Frangu
a59968f7de src: add news and store channels, and missing guild props (#3168)
* src: Implement store and news channels!

* src: Remove code dupe

* src: Add missing guild properties

* docs: Add a small notice that the channel type may also change

* src: Remove re-creation of the MessageStore

* lint: Unused Import

* src: Requested changes for StoreChannels

* typings: Fix typings

* src: Moar guild updates

* src: Set maximumPresence to the data prop, the already existent one, or default to 5000

* typings: afkChannel is a VC

I keep confusing them, ffs

Co-Authored-By: vladfrangu <kingdgrizzle@gmail.com>

* docs: Document that maximumMembers and maximumPresences may be inaccurate before fetching

* src Appels requested changes
2019-05-03 17:08:07 +02:00
Amish Shah
bcb0cd838b voice: remove Guild.voiceConnection and VoiceChannel.connection 2019-04-29 19:29:16 +01:00
Amish Shah
dd44647537 voice: Guild.voiceConnection => Guild.voice.connection 2019-04-29 19:24:27 +01:00
Amish Shah
ce1e3d2084 feat(VoiceConnection): add .voice 2019-04-29 19:13:41 +01:00
Vlad Frangu
d7a9b74523 src: Replace instanceof Array checks with Array.isArray and instanceof Buffer with Buffer.isBuffer (#3227)
* src: Replace instanceof Array checks with Array.isArray

* src: Buffer.isBuffer instead of instanceof Buffer
2019-04-29 17:49:41 +01:00
bdistin
9b0f4b298d feature: public raw events (#3159)
* add a public alternative to the private raw event

while retaining raw for use in debugging privately

* only emit dispatch packets

* requested changes

TIL, that's neat

* fix padding

* requested changes

* Update WebSocketManager.js
2019-04-29 17:37:57 +01:00
izexi
23191da13d feat(Partials.GuildMember): GuildMemberRemove & Guild#me (#3229)
* use partials for GuildMemberRemove & Guild#me

* oops

* guild.members instead of Action.members

Co-Authored-By: izexi <43889168+izexi@users.noreply.github.com>
2019-04-29 17:05:52 +01:00
Vlad Frangu
bc31746621 src: Client#readyAt should be updated when triggerReady is called (#3234) 2019-04-29 17:03:29 +01:00