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',
|
utility: '🔩\u2000Utility',
|
||||||
admin: '⚡\u2000Admin',
|
admin: '⚡\u2000Admin',
|
||||||
owner: '🛠️\u2000Owner',
|
owner: '🛠️\u2000Owner',
|
||||||
voice: '🗣️\u2000Voice',
|
|
||||||
}[category];
|
}[category];
|
||||||
|
|
||||||
embed.addFields({ name: title, value: `\`${object[category].join('` `')}\`` });
|
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('fun');
|
||||||
await loadCommandFromDir('secret');
|
await loadCommandFromDir('secret');
|
||||||
await loadCommandFromDir('utility');
|
await loadCommandFromDir('utility');
|
||||||
await loadCommandFromDir('voice');
|
|
||||||
await loadCommandFromDir('admin');
|
await loadCommandFromDir('admin');
|
||||||
await loadCommandFromDir('owner');
|
await loadCommandFromDir('owner');
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ const commands = [];
|
||||||
await loadCommandFromDir('fun');
|
await loadCommandFromDir('fun');
|
||||||
await loadCommandFromDir('secret');
|
await loadCommandFromDir('secret');
|
||||||
await loadCommandFromDir('utility');
|
await loadCommandFromDir('utility');
|
||||||
await loadCommandFromDir('voice');
|
|
||||||
await loadCommandFromDir('admin');
|
await loadCommandFromDir('admin');
|
||||||
await loadCommandFromDir('owner');
|
await loadCommandFromDir('owner');
|
||||||
commands.map(command => command.toJSON());
|
commands.map(command => command.toJSON());
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
export function rand(text, interaction) {
|
export function rand(text, message) {
|
||||||
interaction.author = interaction.user;
|
|
||||||
// Find a value in an array of objects in Javascript - https://stackoverflow.com/a/12462387
|
// Find a value in an array of objects in Javascript - https://stackoverflow.com/a/12462387
|
||||||
function search(nameKey, myArray) {
|
function search(nameKey, myArray) {
|
||||||
for (let i = 0; i < myArray.length; i++) {
|
for (let i = 0; i < myArray.length; i++) {
|
||||||
|
@ -24,15 +23,15 @@ export function rand(text, interaction) {
|
||||||
const variables = [
|
const variables = [
|
||||||
{
|
{
|
||||||
name: /\[author\]/,
|
name: /\[author\]/,
|
||||||
value: interaction ? interaction.author.username : '',
|
value: message ? message.author.username : '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: /\[member\]/,
|
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\]/,
|
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*\]/,
|
name: /\[dice\d*\]/,
|
||||||
|
|
Loading…
Reference in a new issue