Discord voice bot

Yksi ikuisuus sitten | 248 näyttökertaa

const Discord = require('discord.js');
const discordTTS=require("discord-tts");
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', async message => {
	// Join the same voice channel of the author of the message
  if (message.author.bot) return

  console.log(message.content);

  if (message.content == "=watch") {
    if (message.member.voice.channel) {
  		const connection = await message.member.voice.channel.join();

      const broadcast = client.voice.createBroadcast();

      broadcast.play(discordTTS.getVoiceStream("I have joined. I will tell when someone joins or disconnects."));
      const dispatcher=connection.play(broadcast, { volume: 0.5 });
      /*
      const dispatcher = connection.play('audio.mp3', { volume: 0.5 });

      dispatcher.on('start', () => {
      	console.log('audio.mp3 is now playing!');
      });

      dispatcher.on('finish', () => {
      	console.log('audio.mp3 has finished playing!');
      });

      // Always remember to handle errors appropriately!
      dispatcher.on('error', console.error);
      */
  	}
  } else if (message.content.startsWith("=say ")) {
      console.log(message.author)
/*    if (message.member.voice.channel) {
      const connection = await message.member.voice.channel.join();

      const broadcast = client.voice.createBroadcast();

      broadcast.play(discordTTS.getVoiceStream(""));
      const dispatcher=connection.play(broadcast, { volume: 0.5 });
    }
  }*/
  }
});

client.login('cantsee');