I'm coding a discord bot and I want to connect it to a mongoDB database. However when doing this, I get this error,
Error: querySrv ENODATA _mongodb._tcp.cluster0.h5prp.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (node:dns:228:19) {
errno: undefined,
code: 'ENODATA',
syscall: 'querySrv',
hostname: '_mongodb._tcp.cluster0.h5prp.mongodb.net'
}
Here is my code:
client.on('ready', () => {
console.log('The bot is ready!')
const dbOptions = {
// These are the default values
keepAlive: true
}
new WOKCommands(client, {
// The name of the local folder for your command files
commandsDir: path.join(__dirname, 'commands'),
// Allow importing of .ts files if you are using ts-node
typeScript: true,
// Pass in the new dbOptions
dbOptions,
// Pass in your own mongo connection URI
mongoUri: 'mongodb+srv://discordbot:******@cluster0.h5prp.mongodb.net/myFirstDatabase?retryWrites=true&w=majority'
})
})
I looked through documentation and other posts but could not find anything that solves my problem. I'm using Node.js v17.1.0. I'm using WOKCommands and following this tutorial series https://youtube.com/playlist?list=PLaxxQQak6D_f4Z5DtQo0b1McgjLVHmE8Q
I've allowed all IP Addresses to access my database, I've ensured my IP address is whitelisted
Any help appreciated.
Thanks