How to send data using a Discord Webhook in Glitch?

I want to receive data from IFTTT and send it to multiple discord servers via webhooks. I am a complete beginner and only know some JavaScript. What code should I use to send data via Discord webhooks?

Hello @masteradit

I recommend that you use discord.js to handle webhooks, you should also store webhooks in a JSON file, this is something I can help you further with in a social media such as Discord if you would like.

@ihack2712 How do I code it?

I mean can you give me an example code?

Oh, yeah!

This snippet is untested, and made using discordjs/discord.js (master).

INSTALLATION npm i -S discordjs/discord.js


// Dependencies
const Discord = require('discord.js');

// Initiate a new Webhook.
const Webhook = new Discord.WebhookClient(process.env.WEBHOOK_ID, process.env.WEBHOOK_TOKEN);

// Send a message
Webhook.send('Hello world')
  .then(() => console.log('Message sent!'))
  .catch(e => console.log('Failed to send message!', err.message))

// Or even send an embed
var embed = new Dicscord.MessageEmbed()
  .addField('Lorem', 'Ipsum')

// Send the message embed
Webhook.send({ embed })
  .then(() => console.log('Embed sent!'))
  .catch(e => console.log('Failed to send embed!', err.message))

1 Like

@ihack2712 Thanks! I have a few more questions.

I am very familiar with this type of structure:
Is there an alternative way to send Webhooks like this? :arrow_up:

Btw, can we chat at Discord? Here’s my server:

Hello, yes we can chat at discord, but I see that I don’t have to join any servers. Can you send me your Discord tag?

@Master Adit ᵛᵉʳᶦᶠᶦᵉᵈ#8363 -> this is my discord username

I’ve added you :slight_smile: