NodeJS examples


Discord bot lyrics example

const fetch = require('node-fetch')

fetch('https://some-random-api.ml/lyrics?title=firestone')
    .then(res => res.json())
    .then(json => {
        message.channel.send(json.lyrics)
    });

Triggered example

const { MessageEmbed, MessageAttachment } = require('discord.js')

let link = `https://some-random-api.ml/canvas/triggered/?avatar=${message.author.avatarURL({ format: 'png' })}`
//Make sure the link ends with either .png or .jpg

//create a message attachment with the name of the file with discord.js built in attachment class.
let attachment = new MessageAttachment(link, 'triggered.gif');
message.channel.send(attachment); //send the attachment

// -------- Sending the image inside an embed --------
const attachment = new MessageAttachment(link, 'triggered.gif');
  const embed = new MessageEmbed()
    .setTitle(`Image Generated`)
    .attachFiles(attachment)
    .setImage('attachment://triggered.gif')
  message.channel.send(embed)