mirror of
https://github.com/ION606/selmerBot.git
synced 2026-06-05 23:06:14 +00:00
Added OpenAI API intergration and verification for conversations AKA SELMER BOT CAN TALK NOW
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
const { convoManager } = require('./API/chat.js');
|
||||
const { MongoClient, ServerApiVersion, ConnectionClosedEvent } = require('mongodb');
|
||||
|
||||
function handle_dm(message, bot) {
|
||||
if (message.author.bot) { return; }
|
||||
|
||||
if (!message.content.startsWith('!') || message.content.split(' ')[0] == '!startconvo' || message.content.split(' ')[0] == '!endconvo') {
|
||||
const member = bot.guilds.cache.get(bot.home_server).members.cache.get(message.author.id);
|
||||
|
||||
const client = new MongoClient(bot.mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
|
||||
client.connect(async (err) => {
|
||||
if (err) { return console.log(err); }
|
||||
|
||||
const dbo = client.db('main').collection('authorized');
|
||||
dbo.find({id: message.author}).toArray((err, docs) => {
|
||||
|
||||
//Only available to Selmer Bot devs, testers and "authorized" users
|
||||
if (docs[0] != undefined || member.roles.cache.has('944048889038774302') || member.roles.cache.has('946610800418762792')) {
|
||||
convoManager(client, bot, message);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
client.close();
|
||||
} else {
|
||||
return message.reply('UNUSABLE DM COMMAND DETECTED');
|
||||
}
|
||||
|
||||
//Selmer Bot is conversing with them
|
||||
|
||||
}
|
||||
|
||||
|
||||
module.exports = { handle_dm }
|
||||
Reference in New Issue
Block a user