Giphy API integration failing in Discord bot - no GIFs returned

I’m working on a Discord bot that should fetch random GIFs from Giphy but I keep running into issues. The code always jumps to the error handler and no GIFs are displayed. I’ve tried debugging by adding console logs but nothing shows up.

if (cmd === 'countdown') {
    var targetDate = new Date("dec 25, 2024 00:00:00").getTime();
    var now = new Date().getTime();
    var timeLeft = targetDate - now;

    var daysLeft = Math.floor(timeLeft / (1000 * 60 * 60 * 24)); 
    var hoursLeft = Math.floor((timeLeft %(1000 * 60 * 60 * 24))/(1000 * 60 * 60)); 
    var minutesLeft = Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60)); 
    var secondsLeft = Math.floor((timeLeft % (1000 * 60)) / 1000);

    giphyClient.search('gifs', {"q": "celebration"})
        .then((result) => {
            console.log(result);
            var totalGifs = result.data.length;
            var randomIndex = Math.floor((Math.random() * 10) + 1) % totalGifs;
            var selectedGif = result.data[randomIndex];
            msg.channel.send('🎄 **CHRISTMAS COUNTDOWN** 🎄');
            msg.channel.send(`**${daysLeft}** days, **${hoursLeft}** hrs, **${minutesLeft}** mins, **${secondsLeft}** secs`, {
                files: [selectedGif.images.fixed_height.url]})
        })
        .catch (() => {
            console.log('Something went wrong with the API call...')
        })
}

What could be causing the Giphy search to fail? Am I missing something in my API setup or is there an issue with how I’m handling the response data?

Your Giphy API client setup or auth is probably broken. Most Discord bot devs hit this because the error handler hides the real error message.

Change your catch block to catch((error) => { console.log(error); }) so you can actually see what’s failing.

But honestly, Discord bots with API integrations get messy fast. You’re juggling rate limits, error handling, auth, and keeping the thing running 24/7.

I just automated this whole thing with Latenode instead. Set up a webhook that triggers Giphy search, handles errors properly, and sends results back to Discord. Takes maybe 10 minutes and runs without babysitting.

The visual workflow builder makes debugging way easier - you see exactly where it breaks instead of digging through console logs.

You also get retry logic and proper error handling without writing all that boilerplate.