Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Imports; GatewayIntent GuildVoiceStates is already included
- const { getVoiceConnection, createAudioPlayer, createAudioResource, AudioPlayerStatus } = require('@discordjs/voice');
- //Connecting and subscribing
- const connection = getVoiceConnection(interaction.guild.id);
- const filepath = '../../utilityFiles/soundbite.mp3';
- const audioPlayer = createAudioPlayer();
- const audioResource = createAudioResource(filepath, {inlineVolume: true});
- audioResource.volume.setVolume(1.0);
- audioPlayer.play(audioResource);
- connection.subscribe(audioPlayer);
- //Test to see if audioPlayer's playing, which the console says it has.
- audioPlayer.on(AudioPlayerStatus.Playing, () => {
- console.log('The audio player has started playing!');
- });
- // Dependency Report
- --------------------------------------------------
- Core Dependencies
- - @discordjs/voice: 0.18.0
- - prism-media: 1.3.5
- Opus Libraries
- - @discordjs/opus: 0.10.0
- - opusscript: 0.0.8
- Encryption Libraries
- - sodium-native: not found
- - sodium: not found
- - @stablelib/xchacha20poly1305: not found
- - @noble/ciphers: not found
- FFmpeg
- - version: 6.0-essentials_build-www.gyan.dev
- - libopus: yes
- --------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment