update document
This commit is contained in:
41
Document/VoiceCall.md
Normal file
41
Document/VoiceCall.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Setup
|
||||
- Before you use it, properly initialize the module (`@discordjs/voice` patch)
|
||||
|
||||
```js
|
||||
new Client({
|
||||
patchVoice: true, // Enable default
|
||||
})
|
||||
```
|
||||
|
||||
# Usage: Call DM / Group DM
|
||||
|
||||
```js
|
||||
const dmChannel = client.channels.cache.get('id');
|
||||
/* or
|
||||
const dmChannel = User.dmChannel || await User.createDM();
|
||||
*/
|
||||
const connection = await dmChannel.call();
|
||||
/* Return @discordjs/voice VoiceConnection */
|
||||
```
|
||||
|
||||
# Play Music using `play-dl`
|
||||
|
||||
```js
|
||||
const connection = await message.member.user.dmChannel.call();
|
||||
const play = require('play-dl');
|
||||
const {
|
||||
createAudioPlayer,
|
||||
createAudioResource,
|
||||
} = require('@discordjs/voice');
|
||||
let stream = await play.stream('youtube link');
|
||||
let resource = createAudioResource(stream.stream, {
|
||||
inputType: stream.type,
|
||||
});
|
||||
let player = createAudioPlayer({
|
||||
behaviors: {
|
||||
noSubscriber: NoSubscriberBehavior.Play,
|
||||
},
|
||||
});
|
||||
player.play(resource);
|
||||
connection.subscribe(player);
|
||||
```
|
||||
Reference in New Issue
Block a user