forked from Supositware/Haha-Yes
yes
This commit is contained in:
parent
6127921ab3
commit
c2a57fdc46
2 changed files with 12 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
||||||
const { Command } = require('discord-akairo');
|
const { Command } = require('discord-akairo');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const exec = util.promisify(require('child_process').exec);
|
const exec = util.promisify(require('child_process').exec);
|
||||||
|
const os = require('os');
|
||||||
const rand = require('../../../rand.js');
|
const rand = require('../../../rand.js');
|
||||||
|
|
||||||
class dectalkCommand extends Command {
|
class dectalkCommand extends Command {
|
||||||
|
@ -28,25 +29,24 @@ class dectalkCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
|
let output = `${os.tmpdir()}/${message.id}_dectalk.wav`;
|
||||||
args.decMessage = rand.random(args.decMessage, message);
|
args.decMessage = rand.random(args.decMessage, message);
|
||||||
args.decMessage = args.decMessage.replace('\n', ' ');
|
args.decMessage = args.decMessage.replace('\n', ' ');
|
||||||
let decMessage = '[:phoneme on] ' + args.decMessage.replace(/(["'$`\\])/g,'\\$1');
|
let decMessage = '[:phoneme on] ' + args.decMessage.replace(/(["'$`\\])/g,'\\$1');
|
||||||
|
|
||||||
console.log(decMessage);
|
|
||||||
|
|
||||||
if (process.platform == 'win32') {
|
if (process.platform == 'win32') {
|
||||||
exec(`cd .\\dectalk && .\\say.exe -w dectalk.wav "${decMessage}"`)
|
exec(`cd .\\dectalk && .\\say.exe -w ${output} "${decMessage}"`)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return message.channel.send('Oh no! an error has occured!');
|
return message.channel.send('Oh no! an error has occured!');
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return message.channel.send({files: ['./dectalk/dectalk.wav']});
|
return message.channel.send({files: [output]});
|
||||||
});
|
});
|
||||||
} else if (process.platform == 'linux' || process.platform == 'darwin') {
|
} else if (process.platform == 'linux' || process.platform == 'darwin') {
|
||||||
let loadingmsg = await message.channel.send('Processing ( this can take some time ) <a:loadingmin:527579785212329984>');
|
let loadingmsg = await message.channel.send('Processing ( this can take some time ) <a:loadingmin:527579785212329984>');
|
||||||
|
|
||||||
exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w dectalk.wav "${decMessage}"`)
|
exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w ${output} "${decMessage}"`)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
loadingmsg.delete();
|
loadingmsg.delete();
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
@ -54,7 +54,7 @@ class dectalkCommand extends Command {
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
loadingmsg.delete();
|
loadingmsg.delete();
|
||||||
return message.channel.send({files: ['./dectalk/dectalk.wav']});
|
return message.channel.send({files: [output]});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const { Command } = require('discord-akairo');
|
const { Command } = require('discord-akairo');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const exec = util.promisify(require('child_process').exec);
|
const exec = util.promisify(require('child_process').exec);
|
||||||
|
const os = require('os');
|
||||||
const rand = require('../../../rand.js');
|
const rand = require('../../../rand.js');
|
||||||
|
|
||||||
class dectalkvcCommand extends Command {
|
class dectalkvcCommand extends Command {
|
||||||
|
@ -28,12 +29,13 @@ class dectalkvcCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
|
let output = `${os.tmpdir()}/${message.id}_dectalk.wav`;
|
||||||
args.decMessage = rand.random(args.decMessage, message);
|
args.decMessage = rand.random(args.decMessage, message);
|
||||||
args.decMessage = args.decMessage.replace('\n', ' ');
|
args.decMessage = args.decMessage.replace('\n', ' ');
|
||||||
let decMessage = '[:phoneme on] ' + args.decMessage.replace(/(["'$`\\])/g,'\\$1');
|
let decMessage = '[:phoneme on] ' + args.decMessage.replace(/(["'$`\\])/g,'\\$1');
|
||||||
|
|
||||||
if (process.platform == 'win32') {
|
if (process.platform == 'win32') {
|
||||||
exec(`cd .\\dectalk && .\\say.exe -w dectalkvc.wav "${decMessage}"`)
|
exec(`cd .\\dectalk && .\\say.exe -w ${output} "${decMessage}"`)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return message.channel.send('Oh no! an error has occured!');
|
return message.channel.send('Oh no! an error has occured!');
|
||||||
|
@ -43,7 +45,7 @@ class dectalkvcCommand extends Command {
|
||||||
if (!voiceChannel) return message.channel.send('Please enter a voice channel first.');
|
if (!voiceChannel) return message.channel.send('Please enter a voice channel first.');
|
||||||
try {
|
try {
|
||||||
const connection = await voiceChannel.join();
|
const connection = await voiceChannel.join();
|
||||||
const dispatcher = connection.play('./dectalk/dectalk.wav');
|
const dispatcher = connection.play(output);
|
||||||
dispatcher.once('finish', () => voiceChannel.leave());
|
dispatcher.once('finish', () => voiceChannel.leave());
|
||||||
dispatcher.once('error', () => voiceChannel.leave());
|
dispatcher.once('error', () => voiceChannel.leave());
|
||||||
return null;
|
return null;
|
||||||
|
@ -56,7 +58,7 @@ class dectalkvcCommand extends Command {
|
||||||
} else if (process.platform == 'linux' || process.platform == 'darwin') {
|
} else if (process.platform == 'linux' || process.platform == 'darwin') {
|
||||||
let loadingmsg = await message.channel.send('Processing ( this can take some time ) <a:loadingmin:527579785212329984>');
|
let loadingmsg = await message.channel.send('Processing ( this can take some time ) <a:loadingmin:527579785212329984>');
|
||||||
|
|
||||||
exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w dectalkvc.wav "${decMessage}"`)
|
exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w ${output} "${decMessage}"`)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
loadingmsg.delete();
|
loadingmsg.delete();
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
@ -68,7 +70,7 @@ class dectalkvcCommand extends Command {
|
||||||
try {
|
try {
|
||||||
loadingmsg.delete();
|
loadingmsg.delete();
|
||||||
const connection = await voiceChannel.join();
|
const connection = await voiceChannel.join();
|
||||||
const dispatcher = connection.play('./dectalk/dectalkvc.wav');
|
const dispatcher = connection.play(output);
|
||||||
dispatcher.once('finish', () => voiceChannel.leave());
|
dispatcher.once('finish', () => voiceChannel.leave());
|
||||||
dispatcher.once('error', () => voiceChannel.leave());
|
dispatcher.once('error', () => voiceChannel.leave());
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue