Play audio in voice channel via ytdl/ffmpeg. Please note that playing audio may be buggy, please do let us know and we'll try to fix.
Consts
libsodium_fn = "libsodium.so(|.18|.23)"
- Source Edit
Procs
proc disconnect(v: VoiceClient; migrate = false): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
- Disconnects a voice client. Source Edit
proc elapsed(v: VoiceClient): float {....raises: [], tags: [], forbids: [].}
- Shows the elapsed time in seconds. Source Edit
proc pause(v: VoiceClient): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, TimeEffect, WriteIOEffect, ReadIOEffect], forbids: [].}
- Pause the current audio Source Edit
proc play(v: VoiceClient; input: Stream | Process): owned(Future[void]) {. ...stackTrace: false.}
- Plays audio data that comes from a stream or process. Audio must be 2 channel, 48k sample rate, PCM encoded byte stream. Make sure to use sendSpeaking before sending any audio Note: if you are playing voice on windows there might be some interuptions. Source Edit
proc playFFMPEG(v: VoiceClient; path: string): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [ReadDirEffect, ReadEnvEffect, ReadIOEffect, ExecIOEffect, RootEffect, WriteIOEffect, TimeEffect], forbids: [].}
- Gets audio data by passing input to ffmpeg (so input can be anything that ffmpeg supports). Requires ffmpeg be installed. Source Edit
proc playYTDL(v: VoiceClient; url: string; command = "yt-dlp"): owned( Future[void]) {....stackTrace: false, raises: [Exception], tags: [ ReadDirEffect, ReadEnvEffect, ReadIOEffect, ExecIOEffect, RootEffect, WriteIOEffect, TimeEffect], forbids: [].}
- Plays a youtube link using yt-dlp by default Requires yt-dlp to be installed, if you want to use youtube-dl, then you can specify it. Source Edit
proc reconnect(v: VoiceClient): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, ReadDirEffect, ReadEnvEffect, TimeEffect, ReadIOEffect], forbids: [].}
- Source Edit
proc resume(v: VoiceClient): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
- Continue playing audio Source Edit
proc selectProtocol(v: VoiceClient): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
- Tell discord our external IP/port and encryption mode Source Edit
proc sendAudioPacket(v: VoiceClient; data: string): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [RootEffect], forbids: [].}
- Sends opus encoded packet Source Edit
proc sendSpeaking(v: VoiceClient; speaking: bool | set[VoiceSpeakingFlags]): owned( Future[void]) {....stackTrace: false.}
- Source Edit
proc startSession(v: VoiceClient): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, ReadDirEffect, ReadEnvEffect, TimeEffect, ReadIOEffect, WriteIOEffect], forbids: [].}
- Start a discord voice session. Source Edit
proc stopPlaying(v: VoiceClient) {....raises: [], tags: [], forbids: [].}
- Stop the current audio Source Edit
proc unpause(v: VoiceClient): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
- (Alias) same as resume Source Edit
proc waitForReady(v: VoiceClient): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [TimeEffect, RootEffect], forbids: [].}
- Wait for when the bot is ready to play audio, this is necessary before using playFFmpeg or playYTDL. Source Edit