-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (35 loc) · 1.58 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const { Client, Intents, MessageEmbed } = require('discord.js');
const { getAudioUrl } = require('google-tts-api');
const { EmbedBuilder } = require('discord.js');
const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus } = require('@discordjs/voice');
const client = new Client({
intents: 32767,
});
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('messageCreate', message => {
if (message.author.bot) return;
const prefix = '>'; //PREFIX HERE
if (!message.content.startsWith(prefix)) return;
const args = message.content.slice(prefix.length).trim().split(' ');
const command = args.shift().toLowerCase();
if (command === '<') {
const { channel } = message.member.voice;
if (!args[0]) return message.channel.send('Please type something for the bot to say!');
if (!channel) return message.reply('You must be in the voice room to use this command!');
const string = args.join(' ');
if (string.length > 200) return message.channel.send('Please enter less than 200 characters');
const audioURL = getAudioUrl(string, {
lang: 'vi',
slow: false,
host: 'https://translate.google.com',
timeout: 10000,
});
let VoiceConnection = joinVoiceChannel({ channelId: channel.id, guildId: channel.guild.id, adapterCreator: channel.guild.voiceAdapterCreator });
const resource = createAudioResource(audioURL);
const player = createAudioPlayer();
VoiceConnection.subscribe(player);
player.play(resource); }
});
client.login("TOKEN") //TOKEN HERE