mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
31 lines
853 B
JavaScript
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};
|