Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Prevent Crashing on error
Browse files Browse the repository at this point in the history
Fixes #2
  • Loading branch information
JonatanMGit committed Jul 11, 2021
1 parent 6f03f9f commit 1b0120f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,34 @@ client.on('message', (message) => {
howmany = Math.min(Math.max(parseInt(howmany), 1), 5);
Tenor.Search.Random(searchquery, howmany).then(Results => {
Results.forEach(Post => {
client.channels.cache.get("851892495482355753").send(Post.url);
client.channels.cache.get("851892495482355753").send(Post.url).catch(console.error);;
client.channels.cache.get("863382495680659456").send(Post.url).catch(console.error);
if (config.Verbose) console.log(`Query ${searchquery} responded with ${Post.url}`);
});
}).catch(console.error);
})

schedule.scheduleJob('0 * * * *', function () {
Tenor.Search.Random("vomit puke", "2").then(Results => {
client.channels.cache.get("851892495482355753").send("Es ist zeit");
client.channels.cache.get("851892495482355753").send("Es ist zeit").catch(console.error);
Results.forEach(Post => {
client.channels.cache.get("851892495482355753").send(Post.url);
if (config.Verbose) console.log(`Full Hour responded with ${Post.url}`);
client.channels.cache.get("851892495482355753").send(Post.url).catch(console.error);
if (config.Verbose) console.log(`Full Hour responded with ${Post.url}`).catch(console.error);
});
}).catch(console.error);
});

schedule.scheduleJob('30 * * * *', function () {
Tenor.Search.Random("30", "1").then(Results => {
client.channels.cache.get("851892495482355753").send("30 Minuten bis zur zeit");
client.channels.cache.get("851892495482355753").send("30 Minuten bis zur zeit").catch(console.error);
Results.forEach(Post => {
client.channels.cache.get("851892495482355753").send(Post.url);
if (config.Verbose) console.log(`Half Hour responded with ${Post.url}`);
});
}).catch(console.error);
});

process.on('uncaughtException', function (err) {
console.error(err);
console.log("Probably EAI_AGAIN error");
});

0 comments on commit 1b0120f

Please sign in to comment.