UNPKG

dango-cli

Version:

A configurable minecraft BE to Discord Bot cli tool

36 lines (28 loc) 1.04 kB
const { EmbedBuilder, WebhookClient } = require('discord.js'); const fs = require('fs'); const config = require('./index.js'); const webhook = config.webhookUrl; const cleanUrl = typeof webhook === 'string' ? webhook.replace(/^"|"$/g, '') : ''; console.log(cleanUrl); // Webhook client (replace with your actual webhook URL) const webhookClient = new WebhookClient({ url: `${cleanUrl}` }); // Logging function function log(...text) { console.log(new Date().toLocaleString(), '|', ...text); } // Send Embed to Discord Channel (object-based) async function sendEmbed({ title = "Bot Message", description, color = 'Grey', timestamp = true }) { const embed = new EmbedBuilder() .setTitle(title) .setDescription(description) .setColor(color); if (timestamp) embed.setTimestamp(); try { await webhookClient.send({ embeds: [embed] }); } catch (err) { log("Error sending embed:", err.message); } } module.exports = { log, sendEmbed };