Created
March 18, 2024 13:47
-
-
Save hasangenc0/55cbd589721b22bb9d4a59221f0214a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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