From ac689911ac3bf92d4c11704d21e21998050958d3 Mon Sep 17 00:00:00 2001 From: adb Date: Mon, 1 Mar 2021 00:33:12 +0100 Subject: [PATCH] fix optional callback --- node_app/mastodonMemeBot.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/node_app/mastodonMemeBot.js b/node_app/mastodonMemeBot.js index 50ac8da..5036179 100644 --- a/node_app/mastodonMemeBot.js +++ b/node_app/mastodonMemeBot.js @@ -11,22 +11,22 @@ export class mastodonMemeBot { access_token: config.accessToken, }); } - postRandomMeme(callback = undefined) { + postRandomMeme(callback = () => {}) { this.memeHandler.getRandomMeme(sub => { let status = `"${sub.title}"\n${sub.text}\nby ${sub.author}`; if (!this.allowedMedia.find(type => type === sub.url.split(/[.]+/).pop())) { console.log("no valid media, fetching new sub"); - this.postRandomMeme(callback??undefined); + this.postRandomMeme(callback); return; } let filepath = `./media/${sub.url.split(/[/]+/).pop()}`; if (getStat(filepath) === true) { console.log("post already exists, fetching new sub"); - this.postRandomMeme(callback??undefined); + this.postRandomMeme(callback); return; } this.memeHandler.downloadMedia(sub.url, filepath, () => { - this.client.postMedia(status, filepath, 5, () => this.postRandomMeme(), callback??undefined); + this.client.postMedia(status, filepath, 5, () => this.postRandomMeme(), callback); }) }) }