0.1.5 • Published 1 year ago

discordjs-streaming v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Discord-video-experiment

features

  • Playing vp8 video in a voice channel (go live and webcam video)
  • Transcoding video and audio to vp8 (using ffmpeg)

example

console.clear();
const StreamClient = require('discordjs-streaming');
const { Client } = require('discord.js');
const config = require('../config.json');

const client = new Client({ intents: [ 'GuildVoiceStates', 'Guilds', 'GuildMessages', 'MessageContent' ] }) // You only need GuildVoiceStates for this to work
const stream = new StreamerClient(client, client.ws);

client.on('ready', () => {
    console.log(`${client.user.username} is online`);
});

client.on('messageCreate', async (message) => {
    if(['user id1', 'user id2'].includes(message.author.id)) {
        if(message.content.startsWith('!play')) {
            let args = message.content.slice(0).split(' ');
            let url = args[1];
            await stream.playVideo('stream', url, {
                guild_id: message.guild.id,
                channel_id: message.member.voice.channel.id,
                leaveOnFinish: false
            });
        } else if(message.content.startsWith('!leave')) {
            stream.leaveVoice();
        }
    }
});

client.login(config.token);

this is a very basic implementation and should 100% be built upon and not just copied, you can also find this code in the examples folder