       }
       danbooru.get '/posts.json', { json: true, qs }
       .then (r)=>
-        url = "https://danbooru.donmai.us#{r[0].file_url}"
-        msg.channel.uploadFile request(url), @getFileName(url)
+        try
+          url = "https://danbooru.donmai.us#{r[0].file_url}"
+          msg.channel.uploadFile request(url), @getFileName(url)
+        catch
+          console.error r
       .catch (e)=>
         console.error e
         msg.reply 'Something went wrong.'

      }
      safebooru.get '/posts.json', { json: true, qs }
      .then (r)=>
        url = "https://safebooru.donmai.us#{r[0].file_url}"
        msg.channel.uploadFile request(url), @getFileName(url)
      .catch (e)=>
        console.error e
        msg.reply 'Something went wrong.'

        }
        safebooru.get '/posts.json', { json: true, qs }
      .then (r)=>
        try
          url = "https://safebooru.donmai.us#{r[0].file_url}"
          msg.channel.uploadFile request(url), @getFileName(url)
        catch
          console.error r
      .catch (e)=>
        console.error e
        return msg.reply e.msg if e.msg
