Skip to content

Instantly share code, notes, and snippets.

View DaBluLite's full-sized avatar
🏫
UNIWA, Here I come

DaBluLite DaBluLite

🏫
UNIWA, Here I come
View GitHub Profile
@DaBluLite
DaBluLite / blobToBase64.js
Created December 11, 2021 15:23
Fetch an image as a blob in Node.js then turn it into raw Base64, then use it as an attachment in a discord.js v13 message
function blobToBase64(blob) {
var blobObj = blob[Object.getOwnPropertySymbols(blob)[1]];
const base64_img = `data:image/png;base64,${blobObj.toString('base64')}`;
const sfbuff = new Buffer.from(base64_img.split(",")[1], "base64");
return base64data;
}
/*
How to use in Discord.js v13: