Rei-x / discord-speech-recognition

Speech to text extension for discord.js
https://npmjs.com/package/discord-speech-recognition
MIT License
56 stars 22 forks source link

How would I make voice commands with this #26

Closed thecrazytech1 closed 2 years ago

thecrazytech1 commented 2 years ago

I want to make voice commands using this but I have no idea how

thecrazytech1 commented 2 years ago

I found out how to create voice commands, just get the message that the bot thought you said and make that into an if statement kinda like

client.on("speech", (msg) => {
  console.log(msg.content)
  const scr = client.channels.cache.find(channel => channel.id === "932082099836555345")
  scr.send(msg.content)
  if (msg.content === "!leave" || msg.content === "exclamation mark live" || msg.content === "Imma head out") {
    const voice = require('@discordjs/voice');
    voice.getVoiceConnection(`895951251911630870`).disconnect();
  }
});

Basically it, the first bit just sends the content to a channel, as well as the console and then the second if statment checks to see if the content included those words, for me when i said !leave it came up as exclamation mark live and once it gets those it just disconnects the bot from the channel, oh and i also made the bot joining the channel into a command which for me is !listen