chomens-bot-js/plugins/discord.js
2022-11-10 19:38:14 +07:00

31 lines
853 B
JavaScript

const {escapeMarkdown} = require('../util/escapeMarkdown');
function inject(bot, dcclient, config) {
let queue = '';
const queueInterval = setInterval(() => {
if (queue === '') return;
bot.channel.send({
content: '```ansi\n' + queue.substring(0, 1986) + '\n```',
allowedMentions: {
parse: [],
},
});
queue = '';
}, 1000);
bot.on('parsed_chat', (message) => {
const cleanMessage = escapeMarkdown(message.toAnsi(), true);
const discordMsg = cleanMessage
.replaceAll('@', '@\u200b')
.replaceAll('http', 'http\u200b')
.replaceAll('\u001b[9', '\u001b[3');
if (message.toMotd().startsWith('§8[§eChomeNS §9Discord§8] §c')) return;
queue += '\n' + discordMsg;
});
bot.once('end', () => {
clearInterval(queueInterval);
});
};
module.exports = {inject};