Closed ExperiBass closed 3 years ago
Checked on Reddit for PRAW, but might be applicable here as well
This means your script can't resolve hostname to an IP address. Test the script on another environment or contact your network administrator.
If you can't get it to work, can you create small reproducible code?
it appears to be reddit specifically, ive tried my discord bot and ESI, both work perfectly with no ENOTFOUND. heres the code:
let snoowrap = require('snoowrap')
let snoostorm = require('snoostorm')
let fs = require('fs')
const r = new snoowrap({
userAgent: 'X',
clientId: 'A',
clientSecret: 'B',
refresh_token: 'C'
})
let usages = JSON.parse(fs.readFileSync(`./usages.json`, 'utf8'))
let posts = new snoostorm.SubmissionStream(r, {
subreddit: `GoodAnimemes`,
limit: 0,
pollTime: 2000
})
let comments = new snoostorm.CommentStream(r, {
subreddit: `GoodAnimemes`,
limit: 0,
pollTime: 2000
})
posts.on(`item`, post => {
// if the post title has the word trap and the body doesnt, then save
if (post.title.includes("trap") && !post.selftext.includes("trap")) {
const data = {
title: post.title,
author: post.author.name,
url: post.url
}
usages.usages.push(data)
console.log(`Usage detected!`)
}
// if the body has the word trap, save (this catches posts that have the body and title both with the word trap)
if (post.selftext && post.selftext.includes("trap")) {
const data = {
selftext: post.selftext,
author: post.author.name,
url: post.url
}
usages.usages.push(data)
console.log(`Usage detected!`)
}
})
comments.on('item', comment => {
if (comment.body.includes("trap")) {
const data = {
comment: comment.body,
author: comment.author.name,
url: `https://reddit.com${comment.permalink}`
}
usages.usages.push(data)
console.log(`Usage detected!`)
}
})
process.on('SIGINT', () => {
console.log(`Writing file...`)
fs.writeFileSync(`./usages.json`, JSON.stringify(usages, null, 4))
process.exit()
})
process.on('unhandledRejection', (e) => {
console.error(e.stack)
})
process.on('uncaughtException', (e) => {
console.error(e.stack)
})
I see, most likely Reddit hiccup then. Once we migrate away from request dependency we should at least get a better error when this happens
cool, thanks :D
Dunno why this happens, my bot still works even with this oddly