Using giphy for my discord bot

Hello. I’m new to glitch and I’m having problems with some of my code. I want a randomized gif from giphy when a certain command is used, and I’ve got the code. The only problem is that I get the error:

TypeError: GphApiClient is not a function

It worked while I used it in VSCode, but not after I moved it to Glitch. My project’s name is weeabot1.

Any help is appreciated, as I’m completely new to Glitch.

Wecome to Glitch, @TheGameGamerInt!

According to what the error signifies, it seems that GphApiClient is not a function and you’re still trying to call that function, which would further throw a TypeError, as it did.
Solution: Do not call the GphApiClient as function.


Then how would I get a gif from Giphy?

Can you please provide the code you were recently working on?

const GphApiClient = require('giphy-js-sdk-core')
var giphy = GphApiClient(giphyToken)'gifs', {"q": "punch, anime"})
                .then((response) => {
                    var totalResponses =;
                    var responseIndex = Math.floor((Math.random() * 10) + 1) % totalResponses;
                    var responseFinal =[responseIndex]

Which package are you working with to connect to the Giphy API?

I’m using giphy-js-sdk-core

So do you have any advice for that, or know someone who has any?

Is giphy-js-sdk-core installed/added in the package.json file? That could be the issue.

Yeah, but I think I fixed the problem now. Just had to change the code to
var giphy = GphApiClient + giphyToken

Hmm, according to the API docs on the NPM package page this is how you initialise a GphApiClient:

yeah, and when i did that i got an error

but now, whenever i try to boot up the bot, i get the error code (node:3927)UnhandledPromiseRejectionWarning error: an invalid token was provided

not sure if it’s connected or not, but it’s still a problem

1 Like

Looks like you’ve supplied invalid KEY to the client, which causes the error.

Where and which key?

Ok, fixed. And why must a post be 20 char-long?

I am not quite sure about that, please ask the Giphy staff for the internal questions.

To avoid people posting ‘spam’ answers/replies. However half of them aren’t.

Well, I fixed it somehow. Now everything is working. May be a new post where I need help with some of the stuff I plan on implementing

1 Like