Update bot to new discord API and add simple chatgpt module
This commit is contained in:
@@ -1,32 +1,33 @@
|
||||
const printf=require('printf');
|
||||
const AudioQueue=require('../../AudioQueue.js')
|
||||
|
||||
module.exports = function (bot, api) {
|
||||
bot.on('voiceStateUpdate', async (oldState, newState) => {
|
||||
if (newState.member.user.bot) return;
|
||||
if (oldState.channel && newState.channel) return;
|
||||
const channel = oldState.channel || newState.channel;
|
||||
if (!channel) return;
|
||||
if (channel.members.array().length < 2) {
|
||||
return await api.leaveChannel(channel);
|
||||
}
|
||||
await api.joinChannel(channel);
|
||||
let joined = false;
|
||||
if (!oldState.channel) {
|
||||
joined = true;
|
||||
let conn=api.getConnectionForVoiceChannel(channel);
|
||||
api.queue=new AudioQueue(conn);
|
||||
}
|
||||
|
||||
let username = newState.member.displayName;
|
||||
let str = "";
|
||||
if (!joined) {
|
||||
str = printf(api.strings.USER_LEFT, username);
|
||||
} else {
|
||||
str = printf(api.strings.USER_JOINED, username);
|
||||
}
|
||||
const filepath = await api.generateVoice(str, api.announcementEngine, api.announcementVoice);
|
||||
api.queue.add(__dirname + "/sysmsg.wav");
|
||||
api.queue.add(filepath);
|
||||
})
|
||||
}
|
||||
const printf=require('printf');
|
||||
const AudioQueue=require('../../AudioQueue.js')
|
||||
|
||||
module.exports = function (bot, api) {
|
||||
bot.on('voiceStateUpdate', async (oldState, newState) => {
|
||||
console.log("Voice state update");
|
||||
if (newState.member.user.bot) return;
|
||||
if (oldState.channel && newState.channel) return;
|
||||
const channel = oldState.channel || newState.channel;
|
||||
if (!channel) return;
|
||||
if (channel.members.size < 1) {
|
||||
return await api.leaveChannel(channel);
|
||||
}
|
||||
await api.joinChannel(channel);
|
||||
let joined = false;
|
||||
if (!oldState.channel) {
|
||||
joined = true;
|
||||
let conn=api.getConnectionForVoiceChannel(channel);
|
||||
api.queue=new AudioQueue(conn, api);
|
||||
}
|
||||
|
||||
let username = newState.member.displayName;
|
||||
let str = "";
|
||||
if (!joined) {
|
||||
str = printf(api.strings.USER_LEFT, username);
|
||||
} else {
|
||||
str = printf(api.strings.USER_JOINED, username);
|
||||
}
|
||||
const filepath = await api.generateVoice(str, api.announcementEngine, api.announcementVoice);
|
||||
api.queue.add(__dirname + "/sysmsg.wav");
|
||||
api.queue.add(filepath);
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user