Skip to content

Commit f5ab9a3

Browse files
authored
Update io.mjs
Fixed a bug that didnt display the channel messages if the directory didnt exist
1 parent 8d433aa commit f5ab9a3

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

modules/functions/io.mjs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,25 +164,25 @@ export async function getSavedChatMessage(group, category, channel, index = -1){
164164
}
165165

166166

167-
168167
var dir = `./chats/${group}/${category}/${channel}/`;
169168

170169
if (!fs.existsSync(dir)){
171170
consolas(`Directory ${dir} didnt exist`, "Debug");
172-
return;
171+
//return;
173172
}
174-
fs.readdirSync(`./chats/${group}/${category}/${channel}/`).forEach(file => {
175-
176-
var message = JSON.parse(fs.readFileSync(`./chats/${group}/${category}/${channel}/${file}`));
177-
178-
179-
if(message.message.includes("<br>") && (message.message.split("<br>").length-1) <= 1){
180-
message.message = message.message.replaceAll("<br>", "")
181-
}
173+
else{
174+
fs.readdirSync(`./chats/${group}/${category}/${channel}/`).forEach(file => {
182175

183-
sortedMessages.push(message);
184-
});
176+
var message = JSON.parse(fs.readFileSync(`./chats/${group}/${category}/${channel}/${file}`));
177+
if(message.message.includes("<br>") && (message.message.split("<br>").length-1) <= 1){
178+
message.message = message.message.replaceAll("<br>", "")
179+
}
180+
181+
sortedMessages.push(message);
182+
});
183+
}
185184

185+
186186

187187
sortedMessages = sortedMessages.sort((a, b) => {
188188
if (a.timestamp < b.timestamp) {
@@ -250,4 +250,4 @@ export async function saveChatMessage(message, editedMsgId = null){
250250
return console.log(err);
251251
}
252252
});
253-
}
253+
}

0 commit comments

Comments
 (0)