Skip to content

Commit

Permalink
Update io.mjs
Browse files Browse the repository at this point in the history
Fixed a bug that didnt display the channel messages if the directory didnt exist
  • Loading branch information
hackthedev authored Aug 4, 2024
1 parent 8d433aa commit f5ab9a3
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions modules/functions/io.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -164,25 +164,25 @@ export async function getSavedChatMessage(group, category, channel, index = -1){
}



var dir = `./chats/${group}/${category}/${channel}/`;

if (!fs.existsSync(dir)){
consolas(`Directory ${dir} didnt exist`, "Debug");
return;
//return;
}
fs.readdirSync(`./chats/${group}/${category}/${channel}/`).forEach(file => {

var message = JSON.parse(fs.readFileSync(`./chats/${group}/${category}/${channel}/${file}`));


if(message.message.includes("<br>") && (message.message.split("<br>").length-1) <= 1){
message.message = message.message.replaceAll("<br>", "")
}
else{
fs.readdirSync(`./chats/${group}/${category}/${channel}/`).forEach(file => {

sortedMessages.push(message);
});
var message = JSON.parse(fs.readFileSync(`./chats/${group}/${category}/${channel}/${file}`));
if(message.message.includes("<br>") && (message.message.split("<br>").length-1) <= 1){
message.message = message.message.replaceAll("<br>", "")
}

sortedMessages.push(message);
});
}



sortedMessages = sortedMessages.sort((a, b) => {
if (a.timestamp < b.timestamp) {
Expand Down Expand Up @@ -250,4 +250,4 @@ export async function saveChatMessage(message, editedMsgId = null){
return console.log(err);
}
});
}
}

0 comments on commit f5ab9a3

Please sign in to comment.