mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 22:32:50 +02:00
Streams?
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
|
const { Readable } = require('stream');
|
||||||
|
// const path = require('path');
|
||||||
|
// const { promisifyAll } = require('tsubaki');
|
||||||
|
// const fs = promisifyAll(require('fs'));
|
||||||
|
|
||||||
module.exports = class DECTalkCommand extends Command {
|
module.exports = class DECTalkCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -38,10 +42,13 @@ module.exports = class DECTalkCommand extends Command {
|
|||||||
if (this.client.voiceConnections.has(channel.guild.id)) return msg.say('I am already playing a sound.');
|
if (this.client.voiceConnections.has(channel.guild.id)) return msg.say('I am already playing a sound.');
|
||||||
try {
|
try {
|
||||||
const connection = await channel.join();
|
const connection = await channel.join();
|
||||||
const body = snekfetch
|
const { body } = await snekfetch
|
||||||
.get('http://tts.cyzon.us/tts')
|
.get('http://tts.cyzon.us/tts')
|
||||||
.query({ text });
|
.query({ text });
|
||||||
const dispatcher = connection.playStream(body);
|
const stream = new Readable();
|
||||||
|
stream.read = function () {};
|
||||||
|
stream.push(body);
|
||||||
|
const dispatcher = connection.playStream(stream);
|
||||||
dispatcher.once('end', () => channel.leave());
|
dispatcher.once('end', () => channel.leave());
|
||||||
dispatcher.once('error', () => channel.leave());
|
dispatcher.once('error', () => channel.leave());
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user