Fancy logging to Discord go brrt

This commit is contained in:
Christopher Cookman 2023-05-04 09:33:47 -06:00
parent 8626f22c10
commit a665cffcb9
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -214,11 +214,23 @@ const rest = new REST({
}).setToken(config.discord.token); }).setToken(config.discord.token);
var logChannel; var logChannel;
var sendLog; var sendLog;
var logMsg = null; // Used to store the log message, so it can be edited instead of sending a new one
var curMsg = ""; // Used to calculate the length of the log message, so it can be edited instead of sending a new one
dcClient.on('ready', async () => { dcClient.on('ready', async () => {
await dcClient.channels.fetch(config.discord.logId).then((channel) => { await dcClient.channels.fetch(config.discord.logId).then(async (channel) => {
sendLog = (message) => { await channel.send(`\`\`\`ansi\n${curMsg}\`\`\``).then((msg) => {
channel.send(`\`\`\`ansi\n${message}\`\`\``); logMsg = msg;
});
sendLog = async (message) => {
if(curMsg.length + message.length < 2000) {
curMsg = `${curMsg}\n${message}`;
await logMsg.edit(`\`\`\`ansi\n${curMsg}\`\`\``);
} else {
curMsg = message;
await channel.send(`\`\`\`ansi\n${message}\`\`\``).then((msg) => {
logMsg = msg;
});
}
console.log(message); console.log(message);
}; };