Skip to content

Instantly share code, notes, and snippets.

@DoNotSpamPls
Created August 21, 2021 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DoNotSpamPls/9bbfbb8d993d23f0802c695d68f4e4de to your computer and use it in GitHub Desktop.
Save DoNotSpamPls/9bbfbb8d993d23f0802c695d68f4e4de to your computer and use it in GitHub Desktop.
const Eris = require('eris');
const { spawn } = require('child_process');
var client = new Eris("BOT_TOKEN");
var ffmpeg = spawn(`ffmpeg.exe`, [
'-i', 'https://bss.neterra.tv/rtplive/veselinaradio_live.stream/chunklist.m3u8', // Radio Veselina
'-c:a', 'libopus',
'-f', 'opus',
'pipe:1'
]);;
client.on("ready", () => {
client.editStatus("dnd", {
name: "радио веселина",
type: 2,
});
console.log("Ready!");
});
client.on("messageCreate", (msg) => {
if (msg.content === ";;veselina") {
if (msg.member.voiceState.channelID) {
client.joinVoiceChannel(msg.member.voiceState.channelID).catch((err) => {
console.log(err);
}).then((connection) => {
connection.updateVoiceState(false, true);
ffmpeg.stderr.on('data', function (data) {
console.log('stderr: ' + data.toString());
});
ffmpeg.on('error', err => {
console.error(err);
});
connection.play(ffmpeg.stdout, {
voiceDataTimeout: 500
});
connection.once("error", (err) => {
console.log(err);
//if (connection) connection.disconnect();
});
connection.once("end", () => {
ffmpeg.kill('SIGINT');
connection.disconnect();
});
});
msg.addReaction("👍");
} else client.createMessage(msg.channel.id, "You need to be in a voice channel!");
}
if (msg.content === ";;vstop") {
if (msg.member.voiceState.channelID) {
client.leaveVoiceChannel(msg.member.voiceState.channelID);
msg.addReaction("👍");
}
}
});
client.connect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment