Skip to content

Commit

Permalink
docs: add basic structure
Browse files Browse the repository at this point in the history
  • Loading branch information
twlite committed Jul 8, 2024
1 parent c3b7f5e commit ca8d2d9
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion packages/discord-player/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
# Discord Player

This branch is a work in progress of discord-player V7.
A robust and versatile [Discord](https://discord.com) music bot for [discord.js](https://discord.js.org) with a focus on performance and ease of use.

> **Note:** This package is still in development and is not yet ready for production use.
## Example (Concept)

> At the moment, the following example is a concept only and does not represent the final API. The API is subject to change at any time.
### Initialize the server

```js
import { createServer } from '@discord-player/server';

const server = createServer({
async authenticate(id, password) {
return id === 'my-id' && password === 'my-password';
},
port: 5678,
});

const { address, port } = await server.listen();

console.log(`Server listening on ${address}:${port}`);
console.log(`Connect with discord-player://my-id:my-password@${address}:${port}`);
```

### Client usage

```js
import { createPlayer } from 'discord-player';
import { DiscordJS } from '@discord-player/discord.js';

const adapter = DiscordJS(client);
const player = createPlayer(adapter, {
nodes: ['discord-player://id:password@localhost:5678'],
});

// track start event
player.events.on('trackStart', (queue, track) => {
const { textChannel } = queue.metadata;
textChannel.send(`Now playing: ${track.title}`);
});

// play command
const { track } = await player.play(voiceChannel, query, {
metadata: {
textChannel: message.channel,
},
});

message.channel.send(`Queued: ${track.title}`);
```

0 comments on commit ca8d2d9

Please sign in to comment.