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!
EDIT
This snippet is untested, and made using discordjs/discord.js
(master).
INSTALLATION npm i -S discordjs/discord.js
THIS IS NOT SUPPORTED FOR STABLE VERSION, ONLY MASTER VERSION
// 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()
.setTitle('Hello')
.setDescription('world!')
.addField('Lorem', 'Ipsum')
.setThumbnail('https://cdn-images-1.medium.com/max/409/1*D4PatAaU5Xu7BA5cFrNSjQ.png')
// Send the message embed
Webhook.send({ embed })
.then(() => console.log('Embed sent!'))
.catch(e => console.log('Failed to send embed!', err.message))
@ihack2712 Thanks! I have a few more questions.
I am very familiar with this type of structure:
{"content":"Hi","username":"TestBot"}
Is there an alternative way to send Webhooks like this?
Btw, can we chat at Discord? Here’s my server: https://discord.gg/DdGbkGd
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