2.0.0 • Published 2 years ago

@skyra/audio v2.0.0

Weekly downloads
81
License
MIT
Repository
github
Last release
2 years ago

@skyra/audio

GitHub codecov Depfu npm npm bundle size minified (scoped)

Table of Contents

About

  • A JavaScript wrapper for the Lavalink audio client for Discord. Only supports Lavalink v3.
  • This is a derivative work of lavalink.js, this wouldn't be possible without the author's work.

Installation and Usage

Package managers

yarn add @skyra/audio
# or npm install @skyra/audio

Usage

const { Node } = require('@skyra/audio');

const node = new Node(
	{
		// Your Lavalink password:
		password: '',
		// The user ID of your bot:
		userID: '',
		// The total number of shards that your bot is running (optional, useful if you're load balancing):
		shardCount: 0,
		// A URL to your lavalink instance without protocol (optional, can be used instead of specifying hosts option):
		host: '',
		// Alternatively, define a custom rest and ws host links:
		hosts: {
			// The http host of your lavalink instance (optional):
			rest: '',
			// The ws host of your lavalink instance (optional):
			ws: ''
		}
	},
	(guildID, packet) => {
		const guild = client.guilds.cache.get(guildID);
		if (guild) return guild.shard.send(packet);
	}
);
await node.connect();

// This sends the required raw Voice State and Voice Server data to lavalink so it can make a connection.
client.ws.on('VOICE_STATE_UPDATE', async (data) => {
	try {
		await client.lavalink.voiceStateUpdate(data);
	} catch (error) {
		console.error(error);
	}
});

client.ws.on('VOICE_SERVER_UPDATE', async (data) => {
	try {
		await node.voiceServerUpdate(data);
	} catch (error) {
		console.error(error);
	}
});
import { Node } from '@skyra/audio';

// Same as before

Meta

License

Copyright © 2020, Skyra Project. Released under the MIT License.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request!

Buy us some doughnuts

Skyra Project is open source and always will be, even if we don't get donations. That said, we know there are amazing people who may still want to donate just to show their appreciation. Thanks you very much in advance!

We accept donations through Patreon, BitCoin, Ethereum, and Litecoin. You can use the buttons below to donate through your method of choice.

Donate WithQRAddress
PatreonPatreonImageClick Here
PayPalPayPalImageClick Here
BitCoinBitcoinImage3JNzCHMTFtxYFWBnVtDM9Tt34zFbKvdwco
EthereumEthereumImage0xcB5EDB76Bc9E389514F905D9680589004C00190c
LitecoinLitecoinImageMNVT1keYGMfGp7vWmcYjCS8ntU8LNvjnqM

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

2.0.0

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago