Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
ef56d82
fix(Nullable): added null type to it
Aug 31, 2020
7f2d621
chore(Vscode): custom workspace rules
Aug 31, 2020
2dddbd1
feat(VoiceSupport): add partial voice support
Aug 31, 2020
f5481af
revert(Vscode) remove workspace settings
Aug 31, 2020
22ce402
build(Npm): switched to discord/erlpack
Aug 31, 2020
fa35d50
docs(Readme): add other optional packages
Aug 31, 2020
cd74de6
fix(OptionalDependencies): added modules
Aug 31, 2020
b71e02b
chore(Gitignore): add .vscode
Aug 31, 2020
5a657c0
Merge branch 'master' of https://github.com/Sardonyx78/node-discord
Aug 31, 2020
4d953fe
chore(Npmignore): created
Aug 31, 2020
aa69d93
ci(Compile): add ci for compiling
Sep 1, 2020
2068777
ci(Deploy): changed default commit author
Sep 1, 2020
c16345c
ci(Compile): compiled latest push
github-actions[bot] Sep 1, 2020
47ab915
build(Npm): removed prepare script
Sep 1, 2020
fe6730b
Merge pull request #1 from Sardonyx78/speed-test
Sep 1, 2020
57a1ae9
fix(Voice): GuildVoiceChannels are now stored in the channels.
Sep 1, 2020
d82b9b8
fix(Exports): imported correctly
Sep 1, 2020
aa704bd
ci(Compile): compiled latest push
github-actions[bot] Sep 1, 2020
43b7cc2
Merge branch 'speed-test'
Sep 1, 2020
3a7f571
ci(Compile): compiled latest push
github-actions[bot] Sep 1, 2020
1c8bb2f
Merge pull request #2 from Sardonyx78/speed-test
Sep 1, 2020
0837a58
fix(Sharding): instead of undefined, shardId will be 1
Sep 1, 2020
fc6f809
Merge branch 'master' of https://github.com/Sardonyx78/node-discord
Sep 1, 2020
2e11ad3
ci(Compile): compiled latest push
github-actions[bot] Sep 1, 2020
424fbb7
fix(Message): fixed message member laways undefined
Sep 1, 2020
f9b7c6c
Merge branch 'master' of https://github.com/Sardonyx78/node-discord
Sep 1, 2020
dd23151
feat(VoiceState): add VoiceState to all members
Sep 1, 2020
e934c94
fix(Message): member value, get properly
Sep 1, 2020
86f5c65
feat(MuteFlags): these flags describe current mute/deaf
Sep 1, 2020
09474af
ci(Compile): compiled latest push
github-actions[bot] Sep 1, 2020
ff4663a
fix(Message): member value, added return
Sep 1, 2020
9fe5cd8
ci(Compile): compiled latest push
github-actions[bot] Sep 1, 2020
0cc335c
refactor: targeted es2019
Sep 1, 2020
2756c2e
feat(Sharding): add optional sharding
Sep 2, 2020
4329915
fix(Message): add return statement in else
Sep 2, 2020
003bfda
fix(GuildVoice): fixed sending op code 2 instead of 4
Sep 2, 2020
ce833e9
fix(Connection): fixed 'ws' and 'udp' of undefined error
Sep 2, 2020
69560d2
feat(VoiceStream): add VoiceStream
Sep 2, 2020
7a21c53
Merge branch 'master' of https://github.com/Sardonyx78/node-discord
Sep 2, 2020
39b7612
ci(Compile): compiled latest push
github-actions[bot] Sep 2, 2020
5232c7e
refactor(MuteState): rename
Sep 2, 2020
0d53672
feat(Readable): added Readable instead of VoiceStream
Sep 2, 2020
f76b903
revert(VoiceStream): removed
Sep 2, 2020
d265348
fix(VoiceWs): fixed endpoint being undefined and sending IDENTIFY bef…
Sep 2, 2020
8354276
fix(VoiceWs): not parsing the incoming message
Sep 2, 2020
22cb59d
fix(VoiceWs): fixed sending incorrect sessionID
Sep 2, 2020
03d39c5
ci(Compile): changed npm script
Sep 2, 2020
d8959a9
fix(VoiceWs): a typo of a property name
Sep 2, 2020
c484cce
fix(UdpSocket): fixed stoping process on error by handling it
Sep 2, 2020
a4fda8a
Merge remote-tracking branch 'refs/remotes/origin/master'
Sep 2, 2020
5ff26bb
ci(Compile): compiled latest push
github-actions[bot] Sep 2, 2020
30de755
chore(Tsconfig): remove unneccessary libs and add 'jest' as a type
Sep 2, 2020
08faf8c
Merge branch 'master' of https://github.com/Sardonyx78/node-discord
Sep 2, 2020
94c8a38
ci(Compile): remove old release to save space
Sep 2, 2020
d47dbc2
ci(Compile): Compile the project @ $GITHUB_SHA
github-actions[bot] Sep 2, 2020
73ee639
Update compile.yml
Sep 2, 2020
b6bb492
revert(Npm): changed erlpack version back
Sep 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
36 changes: 36 additions & 0 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Compile

on: [push]

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Node v12
uses: actions/setup-node@v1
with:
node-version: 12

- name: Install dependencies
run: npm ci

- name: Remove the old release
run: rm -rf ./lib

- name: Build package
run: npm run ci:build

- name: Commit
uses: EndBug/add-and-commit@v4
with:
add: 'lib'
force: true
message: 'ci(Compile): Compile the project @ $env:GITHUB_SHA'
author_email: 41898282+github-actions[bot]@users.noreply.github.com
author_name: github-actions[bot]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ jobs:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: gh-pages
FOLDER: docs
GIT_CONFIG_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
GIT_CONFIG_NAME: github-actions[bot]
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: npm ci

- name: Build package
run: npm run build
run: npm run ci:build

jest:
name: Jest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ node_modules

# Workspace configuration
.idea
.vscode

# Images used for testing files
tests/*.png
Expand All @@ -11,6 +12,7 @@ tests/*.gif

# Compiled output
/lib
/dist

# Test bot credentials
tests/config.json
Expand Down
11 changes: 11 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.github
src
tests
.commitlintrc.js
.eslintrc
.gitignore
.prettierrc
jest.config.js
typedoc.json
tsconfig.json
dist
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,7 @@ bot.connect();

# Optional Libraries
There are multiple optional libraries which could be installed in addition to node-discord to improve performance.
- **erlpack** - Provides fast encoding and decoding for WebSocket payloads.
- **zlib-sync** - Compresses and decompresses WebSocket payloads before attempting to parse them.
- **[discord/erlpack](https://github.com/discord/erlpack)** - Provides fast encoding and decoding for WebSocket payloads.
- **[zlib-sync](https://www.npmjs.com/package/zlib-sync)** - Compresses and decompresses WebSocket payloads before attempting to parse them.
- **[OpusScript](https://www.npmjs.com/package/opusscript)** - Decodes and encodes opus encoded voice packets. **Needed for voice support**
- **[sodium-native](https://www.npmjs.com/package/sodium-native)** - Decodes incoming voice packets from Discord. **Needed for voice support**
135 changes: 135 additions & 0 deletions lib/Collection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/**
* Collections serve as data holders throughout the library.
* They are a combination of JavaScript Maps and Arrays with the
* ability to hold large amount of data.
* @template K, V
*/
declare class Collection<K, V> extends Map<K, V> {
/**
* The maximum number of items allowed in this Collection
*/
readonly limit: number | null | undefined;
constructor(entries?: Iterable<readonly [K, V]> | null, limit?: number);
/**
* Whether the given argument is a Collection
* @param {unknown} collection Data to check if collection
* @returns {boolean}
*/
static isCollection<K, V>(collection: unknown): collection is Collection<K, V>;
/**
* Maps the {@link Collection} values into an array
* @type {V[]}
*/
get toArray(): V[];
/**
* Maps the {@link Collection} keys into an array
* @type {K[]}
*/
get toArrayKeys(): K[];
/**
* Maps the {@link Collection} entries an array
* @type {[K, V][]}
*/
get toArrayEntries(): [K, V][];
/**
* Creates a new Collection with all elements that pass the test implemented by the provided callback.
* Identical to {@link Array.prototype.filter}
* @param {function(value: V, key: K, collection: this): boolean} cb Callback function. Return true to keep the element, false otherwise
* @returns {Collection<K, V>}
*/
filter<T extends V = V>(cb: (value: V, key?: K, collection?: this) => boolean): Collection<K, T>;
/**
* Get the first value in the {@link Collection}
* @type {V | undefined}
*/
get first(): V | undefined;
/**
* Get he first key in the {@link Collection}
* @returns {K}
*/
get firstKey(): K | undefined;
/**
* Get the last value in the {@link Collection}
* @type {V}
*/
get last(): V | undefined;
/**
* Get he last key in the {@link Collection}
* @returns {K}
*/
get lastKey(): K | undefined;
/**
* Returns the item if exists or creates a new one and caches it.
* @param {K} key The key of the item
* @param {V} value The value of the item
* @returns {V}
*/
getOrSet(key: K, value: V): V;
/**
* ֛Merges collection(s) on top of this one. Replaces existing keys by newer Collections
* @param {...(Collection<K, V> | [K, V][])[]} collections The collection(s) to be merged on top of this one
*/
merge(...collections: (Collection<K, V> | [K, V][])[]): void;
/**
* Create a new Collection populated with the results of calling a provided callback on every element in the calling Collection.
* Identical to {@link Array.prototype.map}
* @param {function(value: V, key: K, collection: this): R} cb Callback function. The returned value is added to the new Collection
* @returns {Collection<K, V>}
* @template K, V
* @template R - is the type of the values the new Collection will contain
*/
map<R>(cb: (value: V, key: K, collection: this) => R): Collection<K, R>;
/**
* Checks if the Collection has reached its limit and sets the item using {@link Map.prototype.set}
* @param {K} key The key to set
* @param {V} value The value to set
* @param {boolean} force Whether to add the item to the Collection if its limit was reached
* @returns {this}
*/
set(key: K, value: V, force?: boolean): this;
/**
* Returns the matching values for the given keys inside the Collection.
* @param {K[]} keys Array of all keys to look for
* @returns {V[]}
*/
getMany(keys: K[]): (V | undefined)[];
/**
* Removes the last item from the Collection and returns that item
* Equivalent to Array#pop() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop
* @returns {[K, V] | undefined}
*/
pop(): [K, V] | undefined;
/**
* Removes the first item from a Collection and returns that removed item
* Equivalent to Array#shift() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
* @returns {[K, V] | undefined}
*/
shift(): [K, V] | undefined;
/**
* Tests whether all items in the Collection pass the test implemented by the provided function
* Equivalent to Array#every() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
* @param {function(value: V, key: K, collection: this): boolean} cb A function to test for each element
* @returns {boolean}
*/
every(cb: (value: V, key: K, collection: this) => boolean): boolean;
/**
* Tests whether at least one element in the array passes the test implemented by the provided function
* Equivalent to Array#some() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
* @param {function(value: V, key: K, collection: this): boolean} cb A function to test for each element
* @returns {boolean}
*/
some(cb: (value: V, key: K, collection: this) => boolean): boolean;
/**
* Returns the value of the item in this collection that satisfies the provided testing callback function
* Equivalent to Array#find() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
* @param {function(value: V, key: K, collection: this): boolean} cb A function to test for each element
* @returns {V | undefined}
*/
find(cb: (value: V, key: K, collection: this) => boolean): V | undefined;
/**
* @ignore
* @returns {Serializable}
*/
toJSON(): V[];
}
export default Collection;
Loading