{"id":28284,"date":"2022-03-23T22:58:38","date_gmt":"2022-03-23T22:58:38","guid":{"rendered":"http:\/\/How-to-build-Discord-GIF-Bot-with-Nodejs"},"modified":"2025-02-19T16:19:59","modified_gmt":"2025-02-20T00:19:59","slug":"how-to-build-discord-gif-bot-with-nodejs","status":"publish","type":"post","link":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/","title":{"rendered":"How to build Discord GIF Bot"},"content":{"rendered":"<div class=\"wp-block-cloudinary-markdown \"><p>In this media jam, we will build a discord bot that sends GIFs to the user. We will use <a href=\"https:\/\/nodejs.org\/en\/\">Node.js<\/a> and <a href=\"https:\/\/discord.js.org\">Discord.js<\/a> to create the bot. We will also use <code>node-fetch<\/code> to fetch the GIFs from <a href=\"http:\/\/giphy.com\">Giphy.com<\/a>.<\/p>\n<p>If you want to jump right into the code, check out the <a href=\"https:\/\/github.com\/lelouchB\/discord-bot-gif\">GitHub Repo here<\/a>.<\/p>\n<h2>CodeSandbox<\/h2>\n<p>You can join the dummy server, <strong><a href=\"https:\/\/discord.gg\/qEpQKV84Yz\">Discord Bot Tutorial Server<\/a><\/strong> to explore and play with the bot. For example, type <code>!gif<\/code> followed by the search query in the general channel of the server and hit enter.<\/p>\n<p>You can also explore the code and preview the bot with the CodeSandbox.<\/p>\n<p><em>The following CodeSandbox contains an embed of a dummy Discord Server where the discord bot, built in this jam, is installed. Make sure you have the Discord App opened before exploring the CodeSandbox. There might be a few seconds delay between sending queries and receiving GIFs.<\/em><\/p>\n<\/div>\n  \n  <div class=\"wp-block-cloudinary-code-sandbox \">\n    <iframe\n      src=\"https:\/\/codesandbox.io\/embed\/discord-bot-gif-18ixy?theme=dark&amp;codemirror=1&amp;highlights=&amp;editorsize=50&amp;fontsize=14&amp;expanddevtools=0&amp;hidedevtools=0&amp;eslint=0&amp;forcerefresh=0&amp;hidenavigation=0&amp;initialpath=%2F&amp;module=index.js&amp;moduleview=0&amp;previewwindow=&amp;view=&amp;runonclick=1\"\n      height=\"500\"\n      style=\"width: 100%;\"\n      title=\"discord-bot-gif\"\n      loading=\"lazy\"\n      allow=\"accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking\"\n      sandbox=\"allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts\"\n    ><\/iframe>\n  <\/div>\n\n  <div class=\"wp-block-cloudinary-markdown \"><h2>Setup &amp; Install<\/h2>\n<p>You will use <a href=\"https:\/\/nodejs.org\/en\/\">Node.js<\/a> and <a href=\"https:\/\/discord.js.org\/#\/\">Discord.js<\/a> to build the bot.  Run the following command in the terminal to initialize a new Node.js project.<\/p>\n<pre class=\"js-syntax-highlighted\"><span><code class=\"hljs shcb-wrap-lines\">npm init -y\n<\/code><\/span><\/pre>\n<p>This command will create a <code>package.json<\/code> in your root directory. Run the following commands to install the dependencies.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\"><span class=\"hljs-selector-tag\">npm<\/span> <span class=\"hljs-selector-tag\">install<\/span> <span class=\"hljs-selector-tag\">discord<\/span><span class=\"hljs-selector-class\">.js<\/span> <span class=\"hljs-selector-tag\">node-fetch<\/span>\n<span class=\"hljs-selector-tag\">npm<\/span> <span class=\"hljs-selector-tag\">install<\/span> <span class=\"hljs-selector-tag\">-D<\/span> <span class=\"hljs-selector-tag\">dotenv<\/span> <span class=\"hljs-selector-tag\">nodemon<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>The <code>discord.js<\/code> module makes interacting with Discord API much more effortless. The <code>node-fetch<\/code> package helps in making GET requests to the Giphy API to retrieve the GIFs.<\/p>\n<p><code>dotenv<\/code> lets you store API Keys securely as environment variables. <code>nodemon<\/code> restarts the server with every change in the code.<\/p>\n<p>Update the <code>package.json<\/code> file like this to add two scripts, <code>start<\/code>, and <code>dev<\/code>, in the <code>scripts<\/code> field.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JSON \/ JSON with Comments\" data-shcb-language-slug=\"json\"><span><code class=\"hljs language-json shcb-wrap-lines\">{\n    <span class=\"hljs-attr\">\"name\"<\/span>: <span class=\"hljs-string\">\"discord-bot-gif\"<\/span>,\n    <span class=\"hljs-attr\">\"version\"<\/span>: <span class=\"hljs-string\">\"1.0.0\"<\/span>,\n    <span class=\"hljs-attr\">\"description\"<\/span>: <span class=\"hljs-string\">\"\"<\/span>,\n    <span class=\"hljs-attr\">\"main\"<\/span>: <span class=\"hljs-string\">\"index.js\"<\/span>,\n    <span class=\"hljs-attr\">\"scripts\"<\/span>: {\n        <span class=\"hljs-attr\">\"start\"<\/span>: <span class=\"hljs-string\">\"node index.js\"<\/span>,\n        <span class=\"hljs-attr\">\"dev\"<\/span>: <span class=\"hljs-string\">\"nodemon index.js\"<\/span>\n    },\n    <span class=\"hljs-attr\">\"keywords\"<\/span>: &#91;\n        <span class=\"hljs-string\">\"discord-bot\"<\/span>,\n        <span class=\"hljs-string\">\"giphhy\"<\/span>\n    ],\n    <span class=\"hljs-attr\">\"author\"<\/span>: <span class=\"hljs-string\">\"\"<\/span>,\n    <span class=\"hljs-attr\">\"license\"<\/span>: <span class=\"hljs-string\">\"ISC\"<\/span>,\n    <span class=\"hljs-attr\">\"devDependencies\"<\/span>: {\n        <span class=\"hljs-attr\">\"dotenv\"<\/span>: <span class=\"hljs-string\">\"^10.0.0\"<\/span>,\n        <span class=\"hljs-attr\">\"nodemon\"<\/span>: <span class=\"hljs-string\">\"^2.0.7\"<\/span>\n    },\n    <span class=\"hljs-attr\">\"dependencies\"<\/span>: {\n        <span class=\"hljs-attr\">\"discord.js\"<\/span>: <span class=\"hljs-string\">\"^12.5.3\"<\/span>,\n        <span class=\"hljs-attr\">\"node-fetch\"<\/span>: <span class=\"hljs-string\">\"^2.6.1\"<\/span>\n    }\n}\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JSON \/ JSON with Comments<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">json<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>The next step is to create an app on <a href=\"https:\/\/developers.giphy.com\/dashboard\/\">Giphy Developers<\/a> and retrieve the API key. Head over to <a href=\"http:\/\/giphy.com\">Giphy.com<\/a> and create an account if you haven\u2019t already.<\/p>\n<p>Navigate to <a href=\"https:\/\/developers.giphy.com\/dashboard\/\">https:\/\/developers.giphy.com\/dashboard\/<\/a> and click on  <strong>Create an App<\/strong> button.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624793281\/e-603fc45fe6c0b4006873802f\/boesdybjjtpvfpy0zsp0.png\" alt=\"Create an App\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1519\" height=\"711\"\/><\/p>\n<p>When prompted, select the <strong>API<\/strong> product and click on <strong>Next Step<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624793210\/e-603fc45fe6c0b4006873802f\/ss6fiq10oxxllindjpwk.png\" alt=\"Next Step\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"591\" height=\"791\"\/><\/p>\n<p>Enter your <strong>App Name<\/strong> and <strong>Description<\/strong> and hit <strong>Create App<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624793186\/e-603fc45fe6c0b4006873802f\/jlmax9sjt43wydey5dzb.png\" alt=\"Create App\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"850\" height=\"713\"\/><\/p>\n<p>Copy your <strong>API Key<\/strong> from the Giphy developer dashboard.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624793166\/e-603fc45fe6c0b4006873802f\/vpdx35qsqmtjdosqloa3.png\" alt=\"API Key\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1898\" height=\"860\"\/><\/p>\n<p>Create a new file named <code>.env<\/code> in the root directory of your project by running the following command.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\"><span class=\"hljs-selector-tag\">touch<\/span> <span class=\"hljs-selector-class\">.env<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Paste the Giphy API Key in the <code>.env<\/code> file.<\/p>\n<pre class=\"js-syntax-highlighted\"><code>GIPHY_API_KEY = &lt;YOUR-API-KEY&gt;\n<\/code><\/pre>\n<h2>How to get Discord Bot API Token<\/h2>\n<p>In this section, you will create a new Discord App and retrieve the API Token for the bot. Before proceeding further, make sure you have created a Discord account. You can create one <a href=\"https:\/\/discord.com\/register\">here<\/a>.<\/p>\n<p>Navigate to <a href=\"https:\/\/discord.com\/developers\/applications\/\">Discord\u2019s developer page<\/a>  in the browser and click on <strong>New Application<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624793098\/e-603fc45fe6c0b4006873802f\/g0gyxwnej8q1p530vmvx.png\" alt=\"New Application - Discord Developer Page\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1920\" height=\"860\"\/><\/p>\n<p>Name your application and click on the <strong>Create<\/strong> button.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624793054\/e-603fc45fe6c0b4006873802f\/csfagv1m3cykfd71wmkg.png\" alt=\"Name your Application\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1920\" height=\"860\"\/><\/p>\n<p>You can add general information like a description or an icon to your bot. Then, click on the <strong>Save Changes<\/strong> button to save the icon or description.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624793010\/e-603fc45fe6c0b4006873802f\/u5d4hr1hpvg9159rz4zg.png\" alt=\"Bot - General Info - Save Changes\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1920\" height=\"860\"\/><\/p>\n<p>Click on the <strong>Bot<\/strong> tab in the left menu. Then, on the <strong>Bot<\/strong> page, click on <strong>Add Bot<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624792984\/e-603fc45fe6c0b4006873802f\/ove7o1x7niwpybqqgdu9.png\" alt=\"Bot- Add bot\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1920\" height=\"860\"\/><\/p>\n<p>Yow will be prompted to confirm; click on <strong>Yes, do it!<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624792959\/e-603fc45fe6c0b4006873802f\/t0b4a5ehkvqgurrxamb7.png\" alt=\"Confirm- Yes, do it!\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1920\" height=\"860\"\/><\/p>\n<p>After creating the bot, copy the API Token from the <strong>Build-A-Bot<\/strong> section.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624792930\/e-603fc45fe6c0b4006873802f\/txh8c8yxrzehbmc04dzi.png\" alt=\"Copy the Discord Token\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1920\" height=\"860\"\/><\/p>\n<p>Paste the Discord Token in the <code>.env<\/code> file.<\/p>\n<pre class=\"js-syntax-highlighted\"><code>GIPHY_API_KEY = ''\nDISCORD_TOKEN = ''\n<\/code><\/pre>\n<h2>How to create a new Server in your Discord Account<\/h2>\n<p>In this section, you will create a dummy server in your Discord app and add the bot to it.<\/p>\n<p>Head over to your discord app, click on the plus icon present in the bottom left.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624792845\/e-603fc45fe6c0b4006873802f\/lishvmc4n3luzxvbtiye.png\" alt=\"Add a Server\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"385\" height=\"140\"\/><\/p>\n<p>When prompted, click on <strong>Create My Own<\/strong> to create a dummy server.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624792820\/e-603fc45fe6c0b4006873802f\/zt4fmhz1arw7g1dk213n.png\" alt=\"Create a Server\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"544\" height=\"688\"\/><\/p>\n<p>You will be asked who the server is for; you can skip this by clicking on <strong>skip this question<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624792792\/e-603fc45fe6c0b4006873802f\/j8scwzowiapsowfffdhe.png\" alt=\"Tell us more about your server\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"548\" height=\"483\"\/><\/p>\n<p>Given a name to your server, for example, <strong>Discord Bot Tutorial Server<\/strong>, and click on the <strong>Create<\/strong> button. You can also add an icon to it.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624792739\/e-603fc45fe6c0b4006873802f\/xnvr9cnujknjtatijbss.png\" alt=\"Customize your Server\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"536\" height=\"508\"\/><\/p>\n<p>You have successfully created a dummy discord server for development purposes.<\/p>\n<p>The next step is to add the bot to this server. Head over to <a href=\"https:\/\/discord.com\/developers\/applications\/\">Discord\u2019s developer page<\/a> and click on the <strong>OAuth2<\/strong> tab in the left tab menu.<\/p>\n<p>On the <strong>OAuth2<\/strong> page, select <strong>bot<\/strong> under the <strong>SCOPES<\/strong> section. After selecting the <strong>bot<\/strong>, copy the URL present just below it and paste it into a new tab in the browser.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624792692\/e-603fc45fe6c0b4006873802f\/puuqkwlbozzcspov4crj.png\" alt=\"OAuth2 -  Scopes _Bot\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1920\" height=\"860\"\/><\/p>\n<p>This link will install the <code>discord-bot-gif<\/code> in your dummy server. You will be asked to select the server you want the bot to be installed on this page, select the dummy server you created, and click on the <strong>Authorize<\/strong> button.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624792659\/e-603fc45fe6c0b4006873802f\/pucmmky8s03o45aovbov.png\" alt=\"Authorize\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1912\" height=\"842\"\/><\/p>\n<p>The bot will be installed in your dummy server, and you will see a message similar to the one below in the <code>general<\/code> channel of your server.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624792619\/e-603fc45fe6c0b4006873802f\/oo0uy9vzgyydd1lbbt7m.png\" alt=\"Bot appeared in Discord\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1820\" height=\"992\"\/><\/p>\n<h2>How to create the Bot<\/h2>\n<p>In this section, you will code the bot to send a message, <code>pong<\/code>, when <code>ping<\/code> is entered in the discord channel. This simple command, i.e., <code>ping<\/code>, will help in checking the status of the bot.<\/p>\n<p>Run the following command to create a file named <code>index.js<\/code> in your project\u2019s root directory.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\"><span class=\"hljs-selector-tag\">touch<\/span> <span class=\"hljs-selector-tag\">index<\/span><span class=\"hljs-selector-class\">.js<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Add the following code the <code>index.js<\/code> file.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">\"dotenv\"<\/span>).config();\n<span class=\"hljs-keyword\">const<\/span> Discord = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">\"discord.js\"<\/span>);\n\n<span class=\"hljs-keyword\">const<\/span> client = <span class=\"hljs-keyword\">new<\/span> Discord.Client();\n\nclient.on(<span class=\"hljs-string\">\"ready\"<\/span>, () =&gt; {\n  <span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-string\">`Logged in as <span class=\"hljs-subst\">${client.user.tag}<\/span>!`<\/span>);\n});\n\nclient.on(<span class=\"hljs-string\">\"message\"<\/span>, <span class=\"hljs-keyword\">async<\/span> (message) =&gt; {\n  <span class=\"hljs-keyword\">if<\/span> (message.content === <span class=\"hljs-string\">\"ping\"<\/span>) {\n    message.reply(<span class=\"hljs-string\">\"Pong!\"<\/span>);\n  }\n});\n\nclient.login(process.env.DISCORD_TOKEN);\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>In the above code, you start by importing the <code>dotenv<\/code> package to load the environment variables in your code. Then you create an instance of <code>Discord.Client<\/code>.<\/p>\n<p>You add two event handlers to the discord client, the first being the <code>ready<\/code> event triggered when the bot is ready and the second <code>message<\/code> event triggered when the user sends a message in the discord channel.<\/p>\n<p>The <code>ready<\/code> event handler logs the user tag of the bot in the terminal. In the <code>message<\/code> event handler, you check if the message typed by the user is <code>ping<\/code> or not. If it is <code>ping<\/code>, then you send a reply message <code>pong<\/code> to the user.<\/p>\n<p>Start the development server by running the following command in the terminal.<\/p>\n<pre class=\"js-syntax-highlighted\"><span><code class=\"hljs shcb-wrap-lines\">npm run dev\n<\/code><\/span><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624792567\/e-603fc45fe6c0b4006873802f\/g1ad4mp7tnzvfmtqsnhv.png\" alt=\"Nodemon Terminal\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1559\" height=\"369\"\/><\/p>\n<p>Your development server will start with <code>nodemon<\/code>, and once the discord client is ready, a message similar to <code>Logged in as discord-bot-gif#1153!<\/code> will be logged in the terminal.<\/p>\n<p>Head over to the  <code>general<\/code> channel in the discord server. You will notice that your bot is online in the right section. Type <code>ping<\/code> in the text area and hit enter.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624792468\/e-603fc45fe6c0b4006873802f\/pjqquf3fmruscm79fbat.gif\" alt=\"GIF - Ping\/Pong\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1280\" height=\"720\"\/><\/p>\n<p>The bot will reply with a <code>pong<\/code> message.<\/p>\n<h2>How to send GIF in the Discord Channel<\/h2>\n<p>In this section, you will fetch the GIFs based on the searched query and then send them to the channel. You have already installed the <code>node-fetch<\/code> package, which will help to fetch the GIFs from <a href=\"http:\/\/giphy.com\">Giphy.com<\/a>.<\/p>\n<p>You will send the user\u2019s query in the URL of the fetch request where <code>gifSearchText<\/code> is the query entered by the user and <code>process.env.GIPHY_API_KEY<\/code> is your Giphy API Key.<\/p>\n<pre class=\"js-syntax-highlighted\"><code>http:\/\/api.giphy.com\/v1\/gifs\/search?q=${gifSearchText}&amp;\napi_key=${process.env.GIPHY_API_KEY}&amp;limit=100\n<\/code><\/pre>\n<p>The next step is to finalize the invocation command, which triggers the bot to send the GIF; this tutorial uses <code>!gif<\/code> as the invocation command. You can also choose any other command like <code>!searchGif<\/code>, <code>!gifff<\/code>, etc.<\/p>\n<p>The search query will be followed by the invocation command. So, for example, the command to search for GIFs related to <strong>hello<\/strong> will look like this.<\/p>\n<pre class=\"js-syntax-highlighted\"><code>!gif hello\n<\/code><\/pre>\n<p>You first need to listen for the invocation command, i.e., <code>!gif<\/code>, and then make a request to Giphy API with the query followed by <code>!gif<\/code>.<\/p>\n<p>One way of doing so is using the <code>split()<\/code> method of an Array. You can split the entire string into an array of substrings and check if the index element is <code>!gif<\/code> or not. You can read more about the <code>split()<\/code> method <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/String\/split\">here<\/a>.<\/p>\n<p>Update the <code>index.js<\/code> file like this.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">\"dotenv\"<\/span>).config();\n<span class=\"hljs-keyword\">const<\/span> Discord = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">\"discord.js\"<\/span>);\n<span class=\"hljs-keyword\">const<\/span> fetch = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">\"node-fetch\"<\/span>);\n\n<span class=\"hljs-keyword\">const<\/span> client = <span class=\"hljs-keyword\">new<\/span> Discord.Client();\n\nclient.on(<span class=\"hljs-string\">\"ready\"<\/span>, () =&gt; {\n  <span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-string\">`Logged in as <span class=\"hljs-subst\">${client.user.tag}<\/span>!`<\/span>);\n});\n\nclient.on(<span class=\"hljs-string\">\"message\"<\/span>, <span class=\"hljs-keyword\">async<\/span> (message) =&gt; {\n  <span class=\"hljs-keyword\">if<\/span> (message.content === <span class=\"hljs-string\">\"ping\"<\/span>) {\n    message.reply(<span class=\"hljs-string\">\"Pong!\"<\/span>);\n  }\n\n  <span class=\"hljs-keyword\">let<\/span> splitMessage = message.content.split(<span class=\"hljs-string\">\" \"<\/span>);\n\n  <span class=\"hljs-keyword\">if<\/span> (splitMessage&#91;<span class=\"hljs-number\">0<\/span>] === <span class=\"hljs-string\">\"!gif\"<\/span>) {\n    <span class=\"hljs-keyword\">const<\/span> gifSearchText = splitMessage.slice(<span class=\"hljs-number\">0<\/span>, splitMessage.length).join(<span class=\"hljs-string\">\" \"<\/span>);\n\n    <span class=\"hljs-keyword\">const<\/span> url = <span class=\"hljs-string\">`http:\/\/api.giphy.com\/v1\/gifs\/search?q=<span class=\"hljs-subst\">${gifSearchText}<\/span>\n    &amp;api_key=<span class=\"hljs-subst\">${process.env.GIPHY_API_KEY}<\/span>&amp;limit=100`<\/span>;\n\n    <span class=\"hljs-keyword\">const<\/span> res = <span class=\"hljs-keyword\">await<\/span> fetch(url);\n\n    <span class=\"hljs-keyword\">const<\/span> json = <span class=\"hljs-keyword\">await<\/span> res.json();\n    \n    <span class=\"hljs-keyword\">const<\/span> randomIndex = <span class=\"hljs-built_in\">Math<\/span>.floor(<span class=\"hljs-built_in\">Math<\/span>.random() * json.data.length);\n\n    message.channel.send(json.data&#91;randomIndex].url);\n  }\n});\n\nclient.login(process.env.DISCORD_TOKEN);\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>In the above code, you split the message into substrings using the <code>split()<\/code> method.  The <code>split()<\/code> method splits the message wherever it finds a space, i.e., after the invocation word. You then check if the first element in the array is <code>!gif<\/code>.<\/p>\n<p>If the first element is <code>!gif<\/code>, you create a new substring of all the elements except <code>!gif<\/code> using the <code>slice()<\/code>  and <code>join<\/code> method.<\/p>\n<p>For example, a user can search for <code>!gif happy birthday<\/code>; you will need to make the fetch request using the string <code>happy birthday<\/code> and remove the <code>!gif<\/code> from the message, which is what the following line of code does.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> gifSearchText = splitMessage.slice(<span class=\"hljs-number\">0<\/span>, splitMessage.length).join(<span class=\"hljs-string\">\" \"<\/span>);\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Then you pass the search query, i.e., the <code>gifSearchText<\/code> variable and the Giphy API key in the fetch URL. You also pass a limit to return only 100 GIFs in the responses.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> url = <span class=\"hljs-string\">`http:\/\/api.giphy.com\/v1\/gifs\/search?q=<span class=\"hljs-subst\">${gifSearchText}<\/span>\n    &amp;api_key=<span class=\"hljs-subst\">${process.env.GIPHY_API_KEY}<\/span>&amp;limit=100`<\/span>;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>You then fetch the GIFs bypassing the URL or the <code>url<\/code> variable in the <code>fetch<\/code> method.<\/p>\n<p>You convert the returned response into JSON using the <code>.json()<\/code> method and send a random GIF from the fetched responses.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\">    <span class=\"hljs-keyword\">const<\/span> json = <span class=\"hljs-keyword\">await<\/span> res.json();\n    <span class=\"hljs-keyword\">const<\/span> randomIndex = <span class=\"hljs-built_in\">Math<\/span>.floor(<span class=\"hljs-built_in\">Math<\/span>.random() * json.data.length);\n    message.channel.send(json.data&#91;randomIndex].url);\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>You are actually sending the URL of the GIF which is converted to the GIF by Discord.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1624792389\/e-603fc45fe6c0b4006873802f\/zhymu8ie5brrtr4e06mw.gif\" alt=\"GIF - Showing bot in action\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1280\" height=\"720\"\/><\/p>\n<h2>Conclusion<\/h2>\n<p>In this media jam, you created a Discord Bot to send GIFs from scratch. We used Giphy API in this jam; you can also integrate other APIs like <a href=\"https:\/\/tenor.com\/gifapi\/documentation\">Tenor<\/a>, <a href=\"https:\/\/apidocs.imgur.com\/\">Imgur<\/a>, <a href=\"https:\/\/developers.gfycat.com\/\">Gfycat<\/a>, etc., with the bot. You can change the invocation command to select which API should be used. For example, <code>!giphy &lt;QUERY&gt;<\/code> or\n<code>!tenor &lt;QUERY&gt;<\/code>.<\/p>\n<p>You can also try to integrate <a href=\"https:\/\/developer.spotify.com\/documentation\/web-api\/\">Spotify API<\/a> to play music in the channel.<\/p>\n<p>Here are a few resources that you might find helpful:<\/p>\n<ul>\n<li>\n<a href=\"https:\/\/discord.js.org\/#\/docs\/main\/stable\/general\/welcome\">Discord.js Docs<\/a>\n<\/li>\n<li>\n<a href=\"https:\/\/developers.giphy.com\/docs\/api#quick-start-guide\">Giphy API Docs<\/a>\n<\/li>\n<\/ul>\n<p>Happy coding!<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":41,"featured_media":28285,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_cloudinary_featured_overwrite":false,"footnotes":""},"categories":[1],"tags":[134,383,371],"class_list":["post-28284","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-guest-post","tag-nodejs","tag-under-review"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.6 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to build Discord GIF Bot<\/title>\n<meta name=\"description\" content=\"In this media jam, we will build a discord bot to send GIFs with Node.js.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to build Discord GIF Bot\" \/>\n<meta property=\"og:description\" content=\"In this media jam, we will build a discord bot to send GIFs with Node.js.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudinary Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-23T22:58:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-20T00:19:59+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924935\/Web_Assets\/blog\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c.jpg?_i=AA\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"NewsArticle\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"How to build Discord GIF Bot\",\"datePublished\":\"2022-03-23T22:58:38+00:00\",\"dateModified\":\"2025-02-20T00:19:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/\"},\"wordCount\":6,\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924935\/Web_Assets\/blog\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c.jpg?_i=AA\",\"keywords\":[\"Guest Post\",\"Node(JS)\",\"Under Review\"],\"inLanguage\":\"en-US\",\"copyrightYear\":\"2022\",\"copyrightHolder\":{\"@id\":\"https:\/\/cloudinary.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/\",\"url\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/\",\"name\":\"How to build Discord GIF Bot\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924935\/Web_Assets\/blog\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c.jpg?_i=AA\",\"datePublished\":\"2022-03-23T22:58:38+00:00\",\"dateModified\":\"2025-02-20T00:19:59+00:00\",\"description\":\"In this media jam, we will build a discord bot to send GIFs with Node.js.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#primaryimage\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924935\/Web_Assets\/blog\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c.jpg?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924935\/Web_Assets\/blog\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c.jpg?_i=AA\",\"width\":4896,\"height\":3264},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudinary.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to build Discord GIF Bot\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"name\":\"Cloudinary Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudinary.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\",\"name\":\"Cloudinary Blog\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"width\":312,\"height\":60,\"caption\":\"Cloudinary Blog\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to build Discord GIF Bot","description":"In this media jam, we will build a discord bot to send GIFs with Node.js.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/","og_locale":"en_US","og_type":"article","og_title":"How to build Discord GIF Bot","og_description":"In this media jam, we will build a discord bot to send GIFs with Node.js.","og_url":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/","og_site_name":"Cloudinary Blog","article_published_time":"2022-03-23T22:58:38+00:00","article_modified_time":"2025-02-20T00:19:59+00:00","twitter_card":"summary_large_image","twitter_image":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924935\/Web_Assets\/blog\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c.jpg?_i=AA","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#article","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/"},"author":{"name":"","@id":""},"headline":"How to build Discord GIF Bot","datePublished":"2022-03-23T22:58:38+00:00","dateModified":"2025-02-20T00:19:59+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/"},"wordCount":6,"publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924935\/Web_Assets\/blog\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c.jpg?_i=AA","keywords":["Guest Post","Node(JS)","Under Review"],"inLanguage":"en-US","copyrightYear":"2022","copyrightHolder":{"@id":"https:\/\/cloudinary.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/","url":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/","name":"How to build Discord GIF Bot","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#primaryimage"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924935\/Web_Assets\/blog\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c.jpg?_i=AA","datePublished":"2022-03-23T22:58:38+00:00","dateModified":"2025-02-20T00:19:59+00:00","description":"In this media jam, we will build a discord bot to send GIFs with Node.js.","breadcrumb":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#primaryimage","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924935\/Web_Assets\/blog\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c.jpg?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924935\/Web_Assets\/blog\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c.jpg?_i=AA","width":4896,"height":3264},{"@type":"BreadcrumbList","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-build-discord-gif-bot-with-nodejs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudinary.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to build Discord GIF Bot"}]},{"@type":"WebSite","@id":"https:\/\/cloudinary.com\/blog\/#website","url":"https:\/\/cloudinary.com\/blog\/","name":"Cloudinary Blog","description":"","publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudinary.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudinary.com\/blog\/#organization","name":"Cloudinary Blog","url":"https:\/\/cloudinary.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","width":312,"height":60,"caption":"Cloudinary Blog"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":""}]}},"jetpack_featured_media_url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924935\/Web_Assets\/blog\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c\/a8320a5677c022645d630ad561835fea8fb84e0c-4896x3264-1_28285b665c.jpg?_i=AA","_links":{"self":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/comments?post=28284"}],"version-history":[{"count":1,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28284\/revisions"}],"predecessor-version":[{"id":36887,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28284\/revisions\/36887"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media\/28285"}],"wp:attachment":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media?parent=28284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/categories?post=28284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/tags?post=28284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}