const { WebhookClient, EmbedBuilder } = require('discord.js'); const express = require('express'); const router = express.Router(); const webhookClient = new WebhookClient({ url: process.env.MINECRAFT_WEBHOOK_URL }); router.post('/sendchatmessage', (req, res) => { const { content, username, avatarURL } = req.body; if (!username || !content || !avatarURL) return res.status(400).send({ error: 'Content, username and avatar_url are required' }); webhookClient.send({ content: content, username: username, avatarURL: avatarURL, }); res.send({ data: 'Test data' }); }); router.post('/sendgamemessage', (req, res) => { const { content, avatarURL } = req.body; if (!content || !avatarURL) return res.status(400).send({ error: 'Content, username and avatar_url are required' }); const messageEmbed = new EmbedBuilder() .setColor(process.env.EMBED_COLOR) .setAuthor({ name: content, iconURL: avatarURL }); webhookClient.send({ embeds: [messageEmbed], username: 'Server', }); res.send({ data: 'Test data' }); }); module.exports = router;