This repository has been archived by the owner on Apr 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
46 lines (38 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
41
42
43
44
45
46
const secrets = require('./config/secret.json');
const { prefix } = require('./config/config.json');
const Assisky = require('../dist');
const STTEmitter = Assisky.setup({
voskLogLevel: -1,
// modelPath: "model",
});
STTEmitter.on('recognition', (userId, result, guild, voiceChannel, _connection) => {
console.log(userId, result, guild.id, voiceChannel.id);
});
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'ping') {
message.channel.send('Pong.');
} else if (command === 'listen') {
if (message.member.voice.channel) {
(async () => {
const connection = await message.member.voice.channel.join();
const listenResult = Assisky.startListeningUser(message.author.id, connection);
if (listenResult === 'WARN_ALREADY_LISTENING') message.reply('The recognition was already started!');
else if (listenResult === true) message.reply('Recognition started.');
})();
} else {
message.reply('Join a VC first!');
}
} else if (command === 'leave') {
Assisky.stopListeningChannel(message.member.voice.channel.id);
message.guild.me.voice.channel.leave();
}
});
client.login(secrets.token);