Compare commits
No commits in common. "eecb6020eaca9ef189a02cca7d01a84d27270240" and "9dd060aa2862fc7389af7819aa00323b486f7d8c" have entirely different histories.
eecb6020ea
...
9dd060aa28
5 changed files with 4 additions and 51 deletions
|
@ -144,7 +144,6 @@ export default {
|
|||
utility: '🔩\u2000Utility',
|
||||
admin: '⚡\u2000Admin',
|
||||
owner: '🛠️\u2000Owner',
|
||||
voice: '🗣️\u2000Voice',
|
||||
}[category];
|
||||
|
||||
embed.addFields({ name: title, value: `\`${object[category].join('` `')}\`` });
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { rand } from '../../utils/rand.js';
|
||||
import { execFile } from 'node:child_process';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('dectalk')
|
||||
.setDescription('Send a .wav sound file of what you wrote with dectalk')
|
||||
.addStringOption(option =>
|
||||
option.setName('message')
|
||||
.setDescription('Write something so I can talk it back with dectalk.')
|
||||
.setRequired(true)),
|
||||
category: 'voice',
|
||||
async execute(interaction, args) {
|
||||
args.message = rand(args.message, interaction);
|
||||
const output = `${interaction.id}_dectalk.wav`;
|
||||
const message = '[:phoneme on]' + args.message;
|
||||
await interaction.deferReply({ ephemeral: false });
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// Untested, most likely do not work.
|
||||
execFile('say.exe', ['-w', output, `${message}`], { cwd: './bin/dectalk/' }, (error, stdout, stderr) => {
|
||||
sendMessage(output, error, stdout, stderr);
|
||||
});
|
||||
}
|
||||
else if (process.platform === 'linux' || process.platform === 'darwin') {
|
||||
execFile('wine', ['say.exe', '-w', output, `${message}`], { cwd: './bin/dectalk/' }, (error, stdout, stderr) => {
|
||||
sendMessage(`./bin/dectalk/${output}`, error, stdout, stderr);
|
||||
});
|
||||
}
|
||||
|
||||
async function sendMessage(file, error, stdout, stderr) {
|
||||
if (error) {
|
||||
console.error(stderr);
|
||||
console.error(error);
|
||||
return interaction.editReply('Oh no! an error has occurred!');
|
||||
}
|
||||
|
||||
return interaction.editReply({ files: [file] });
|
||||
}
|
||||
|
||||
},
|
||||
};
|
1
index.js
1
index.js
|
@ -20,7 +20,6 @@ client.commands = new Collection();
|
|||
await loadCommandFromDir('fun');
|
||||
await loadCommandFromDir('secret');
|
||||
await loadCommandFromDir('utility');
|
||||
await loadCommandFromDir('voice');
|
||||
await loadCommandFromDir('admin');
|
||||
await loadCommandFromDir('owner');
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ const commands = [];
|
|||
await loadCommandFromDir('fun');
|
||||
await loadCommandFromDir('secret');
|
||||
await loadCommandFromDir('utility');
|
||||
await loadCommandFromDir('voice');
|
||||
await loadCommandFromDir('admin');
|
||||
await loadCommandFromDir('owner');
|
||||
commands.map(command => command.toJSON());
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import fs from 'node:fs';
|
||||
export function rand(text, interaction) {
|
||||
interaction.author = interaction.user;
|
||||
export function rand(text, message) {
|
||||
// Find a value in an array of objects in Javascript - https://stackoverflow.com/a/12462387
|
||||
function search(nameKey, myArray) {
|
||||
for (let i = 0; i < myArray.length; i++) {
|
||||
|
@ -24,15 +23,15 @@ export function rand(text, interaction) {
|
|||
const variables = [
|
||||
{
|
||||
name: /\[author\]/,
|
||||
value: interaction ? interaction.author.username : '',
|
||||
value: message ? message.author.username : '',
|
||||
},
|
||||
{
|
||||
name: /\[member\]/,
|
||||
value: interaction ? interaction.guild ? interaction.guild.members.cache.random().user.username : '' : '',
|
||||
value: message ? message.guild ? message.guild.members.cache.random().user.username : '' : '',
|
||||
},
|
||||
{
|
||||
name: /\[memberRand\]/,
|
||||
value: (() => interaction.guild ? interaction.guild.members.cache.random().user.username : ''),
|
||||
value: (() => message.guild ? message.guild.members.cache.random().user.username : ''),
|
||||
},
|
||||
{
|
||||
name: /\[dice\d*\]/,
|
||||
|
|
Loading…
Reference in a new issue