-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 11f2b70
Showing
98 changed files
with
15,125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "@zhycorp/eslint-config/typescript/node", | ||
"rules": { | ||
"sort-keys": "off", | ||
"linebreak-style": "off", | ||
"@typescript-eslint/semi": "off", | ||
"@typescript-eslint/no-namespace": "off", | ||
"@typescript-eslint/member-delimiter-style": "off", | ||
"@typescript-eslint/no-unnecessary-condition": "off", | ||
"@typescript-eslint/indent": ["error", 2] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
test/config.json | ||
test/compiled | ||
dist | ||
index.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2021, XzFirzal | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# lavacoffee | ||
> A lightweight and rich-featured lavalink wrapper for node.js | ||
> Install and grab some coffee ☕ | ||
[![NPM Version](https://img.shields.io/npm/v/lavacoffee.svg?maxAge=3600)](https://www.npmjs.com/package/lavacoffee) | ||
[![NPM Downloads](https://img.shields.io/npm/dt/lavacoffee.svg?maxAge=3600)](https://www.npmjs.com/package/lavacoffee) | ||
|
||
# Table Of Contents | ||
- [Features](#features) | ||
- [Installation](#installation) | ||
- [Documentation](#documentation) | ||
- [Getting Lavalink](#getting-lavalink) | ||
- [Test](#test) | ||
- [Examples](#examples) | ||
- [Init](#init) | ||
- [Nodes](#nodes) | ||
- [Voice Updates](#voice-updates) | ||
- [Events](#events) | ||
- [Players](#players) | ||
- [Creating](#creating) | ||
- [Getting](#getting) | ||
- [Replaying](#replaying) | ||
|
||
# Features | ||
- Easy-to-use | ||
- Lightweight and performant | ||
|
||
# Installation | ||
> NPM (Stable) => npm install lavacoffee | ||
> Github (Dev) => npm install XzFirzal/lavacoffee#main | ||
# Documentation | ||
> https://xzfirzal.github.io/lavacoffee | ||
# Getting Lavalink | ||
Download the latest binaries from the [CI Server (Dev)](https://ci.fredboat.com/repository/download/Lavalink_Build?guest=1&branch=refs/heads/dev) | ||
|
||
Put an [application.yml](https://github.com/freyacodes/Lavalink/blob/master/LavalinkServer/application.yml.example) in your working directory. | ||
|
||
Run with `java -jar Lavalink.jar` | ||
|
||
Docker images are available on the [Docker hub](https://hub.docker.com/r/fredboat/lavalink/). | ||
|
||
# Test | ||
[Test Bot](https://github.com/XzFirzal/lavacoffee/blob/main/test/index.ts) | ||
> npm run test | ||
# Examples | ||
### Init | ||
```ts | ||
// Importing lava instance constructor | ||
import { CoffeeLava } from "lavacoffee" | ||
|
||
// Construct the lava instance | ||
const lava = new CoffeeLava(lavaOptions) | ||
|
||
// Init the lava instance | ||
lava.init(clientID) | ||
``` | ||
|
||
### Nodes | ||
```ts | ||
// Adding a node | ||
lava.add(nodeOptions) | ||
|
||
// More nodes | ||
lava.add(nodeOptions1) | ||
lava.add(nodeOptions2) | ||
... | ||
``` | ||
|
||
### Voice Updates | ||
```ts | ||
// Payload can be voice state update payload or voice server update payload | ||
lava.updateVoiceData(payload) | ||
``` | ||
|
||
### Events | ||
> [LavaEvents](https://xzfirzal.github.io/lavacoffee/interfaces/LavaEvents.html) | ||
## Players | ||
### Creating | ||
```ts | ||
// THis will create a new player or get an existing if exist | ||
const player = lava.create(playerOptions) | ||
|
||
// Connect to voice channel | ||
player.options.voiceID = voiceChannelID | ||
player.connect() | ||
|
||
// Adding tracks | ||
player.queue.add(tracks) | ||
|
||
// Play | ||
player.play() | ||
... | ||
``` | ||
|
||
### Getting | ||
```ts | ||
// Use this if you only want to get a player without creating it | ||
const player = lava.get(guildID) | ||
|
||
if (!player) return | ||
|
||
// Getting queue | ||
const queue = player.queue | ||
|
||
// Getting current track | ||
const track = player.queue.current | ||
... | ||
``` | ||
|
||
### Replaying | ||
```ts | ||
/** | ||
* When player is disconnected from node | ||
* it will automatically move to another node | ||
* then replay the track on current position | ||
* you can disable this behaviour with setting | ||
* `autoReplay` to false in LavaOptions | ||
*/ | ||
|
||
// Replay events | ||
|
||
// When successfully replayed | ||
lava.on("playerReplay", player => { ... }) | ||
|
||
// When there's an error while replaying | ||
lava.on("replayError", (player, error) => { ... }) | ||
... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
:root { | ||
--light-hl-0: #008000; | ||
--dark-hl-0: #6A9955; | ||
--light-hl-1: #AF00DB; | ||
--dark-hl-1: #C586C0; | ||
--light-hl-2: #000000; | ||
--dark-hl-2: #D4D4D4; | ||
--light-hl-3: #001080; | ||
--dark-hl-3: #9CDCFE; | ||
--light-hl-4: #A31515; | ||
--dark-hl-4: #CE9178; | ||
--light-hl-5: #0000FF; | ||
--dark-hl-5: #569CD6; | ||
--light-hl-6: #0070C1; | ||
--dark-hl-6: #4FC1FF; | ||
--light-hl-7: #795E26; | ||
--dark-hl-7: #DCDCAA; | ||
--light-code-background: #FFFFFF; | ||
--dark-code-background: #1E1E1E; | ||
} | ||
|
||
@media (prefers-color-scheme: light) { :root { | ||
--hl-0: var(--light-hl-0); | ||
--hl-1: var(--light-hl-1); | ||
--hl-2: var(--light-hl-2); | ||
--hl-3: var(--light-hl-3); | ||
--hl-4: var(--light-hl-4); | ||
--hl-5: var(--light-hl-5); | ||
--hl-6: var(--light-hl-6); | ||
--hl-7: var(--light-hl-7); | ||
--code-background: var(--light-code-background); | ||
} } | ||
|
||
@media (prefers-color-scheme: dark) { :root { | ||
--hl-0: var(--dark-hl-0); | ||
--hl-1: var(--dark-hl-1); | ||
--hl-2: var(--dark-hl-2); | ||
--hl-3: var(--dark-hl-3); | ||
--hl-4: var(--dark-hl-4); | ||
--hl-5: var(--dark-hl-5); | ||
--hl-6: var(--dark-hl-6); | ||
--hl-7: var(--dark-hl-7); | ||
--code-background: var(--dark-code-background); | ||
} } | ||
|
||
body.light { | ||
--hl-0: var(--light-hl-0); | ||
--hl-1: var(--light-hl-1); | ||
--hl-2: var(--light-hl-2); | ||
--hl-3: var(--light-hl-3); | ||
--hl-4: var(--light-hl-4); | ||
--hl-5: var(--light-hl-5); | ||
--hl-6: var(--light-hl-6); | ||
--hl-7: var(--light-hl-7); | ||
--code-background: var(--light-code-background); | ||
} | ||
|
||
body.dark { | ||
--hl-0: var(--dark-hl-0); | ||
--hl-1: var(--dark-hl-1); | ||
--hl-2: var(--dark-hl-2); | ||
--hl-3: var(--dark-hl-3); | ||
--hl-4: var(--dark-hl-4); | ||
--hl-5: var(--dark-hl-5); | ||
--hl-6: var(--dark-hl-6); | ||
--hl-7: var(--dark-hl-7); | ||
--code-background: var(--dark-code-background); | ||
} | ||
|
||
.hl-0 { color: var(--hl-0); } | ||
.hl-1 { color: var(--hl-1); } | ||
.hl-2 { color: var(--hl-2); } | ||
.hl-3 { color: var(--hl-3); } | ||
.hl-4 { color: var(--hl-4); } | ||
.hl-5 { color: var(--hl-5); } | ||
.hl-6 { color: var(--hl-6); } | ||
.hl-7 { color: var(--hl-7); } | ||
pre, code { background: var(--code-background); } |
Oops, something went wrong.