From 33f5baa346318f1b0dc146de4929ab800cb42e9a Mon Sep 17 00:00:00 2001 From: = Date: Fri, 9 Jul 2021 19:00:28 -0400 Subject: [PATCH] catch errors with giphy search --- commands/gif.js | 6 +++--- package-lock.json | 12 ++++++------ package.json | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/commands/gif.js b/commands/gif.js index 9692c22..f2527e1 100644 --- a/commands/gif.js +++ b/commands/gif.js @@ -7,7 +7,7 @@ module.exports = { execute(message, file) { const client = message.client; if (!client.gifs.has(file.name)) { - giphy.search(file.name, (err, res) => { + giphy.search(file.name).then(function (res) { if (res.data[0] != undefined) { // message.channel.send(file.name + ' requested by ' + message.author.username + '\n' + res.data[0].embed_url).then().catch(console.error); const gifInfo = { @@ -19,8 +19,8 @@ module.exports = { } else { message.channel.send('I was unable to find a gif of ' + file.name); } - if (err) console.error(err); - }); + }) + .catch(err => console.error(err)); } else { // message.channel.send(file.name + ' requested by ' + message.author.username + '\n' + client.gifs.get(file.name).embed_url); const gifInfo = { diff --git a/package-lock.json b/package-lock.json index 4b6d1ad..4402a15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -843,9 +843,9 @@ } }, "giphy-api": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/giphy-api/-/giphy-api-2.0.1.tgz", - "integrity": "sha512-6FKx6y26W1OqPtEOohvr3MOqCcYWajmz/svrjWm6XW2eP9mHvcQoi4aFg5afCakVF2b7zVllP0aNF45CGHZn+A==" + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/giphy-api/-/giphy-api-2.0.2.tgz", + "integrity": "sha512-vZaLQhgMF0mDQSNpqooe4Zqoe2dWGqVYhh7Ar6I41BRtcZtfupr9avT23IIPScKBYfb3qAfiKQRQyKgLi8Lcxw==" }, "glob": { "version": "7.1.7", @@ -1833,9 +1833,9 @@ } }, "ws": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.0.tgz", - "integrity": "sha512-6ezXvzOZupqKj4jUqbQ9tXuJNo+BR2gU8fFRk3XCP3e0G6WT414u5ELe6Y0vtp7kmSJ3F7YWObSNr1ESsgi4vw==" + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.2.tgz", + "integrity": "sha512-lkF7AWRicoB9mAgjeKbGqVUekLnSNO4VjKVnuPHpQeOxZOErX6BPXwJk70nFslRCEEA8EVW7ZjKwXaP9N+1sKQ==" }, "xdg-basedir": { "version": "4.0.0", diff --git a/package.json b/package.json index 12414a9..0543e35 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dependencies": { "discord.js": "^12.5.3", "dotenv": "^10.0.0", - "giphy-api": "^2.0.1", + "giphy-api": "^2.0.2", "nodemon": "^2.0.9" }, "devDependencies": {