const { sendMessage } = require('../api');
const { ADMIN_GROUP_IDS } = require('../config');
const { safeExec } = require('../helpers');

const reportError = safeExec(async (context, err) => {
  const msg = `🚨 Errore in <b>${context}</b>\n<pre>${err.stack || err.message}</pre>`;
  for (const id of ADMIN_GROUP_IDS) {
    await sendMessage(id, msg);
  }
});

module.exports = { reportError };
