Skip to content

Instantly share code, notes, and snippets.

@hasangenc0
Created March 18, 2024 13:47
Show Gist options
  • Save hasangenc0/55cbd589721b22bb9d4a59221f0214a5 to your computer and use it in GitHub Desktop.
Save hasangenc0/55cbd589721b22bb9d4a59221f0214a5 to your computer and use it in GitHub Desktop.
import fs from 'fs';
import { WebhookClient } from 'discord.js'
const webhookUrl = "DISCORD_WEBHOOK_URL";
const client = new WebhookClient({
url: webhookUrl
});
export async function notify(message, imagePath) {
const imageBuffer = fs.readFileSync(imagePath);
await client.send({
body: { content: message },
files: [
{
attachment: imageBuffer
}
]
}).catch(console.error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment