Added option to index (specified) ignored posts. Saving index through save module, and it now notifies the user that an index has been written.

This commit is contained in:
2024-09-11 05:16:57 +02:00
parent c1b164a5f9
commit e48c00b529
6 changed files with 30 additions and 19 deletions

View File

@@ -14,7 +14,7 @@ async function getIndex(user) {
return yaml.safeLoad(indexFile);
} catch (error) {
console.log('\x1b[33m%s\x1b[0m', `Could not load index file for '${user.name}' at '${indexFilePath}': ${error}`);
console.log('\x1b[33m%s\x1b[0m', `No index file found for '${user.name}' at '${indexFilePath}'`);
return { profile: { image: null, description: null }, posts: [] };
}

View File

@@ -23,12 +23,12 @@ async function getUser(username, reddit) {
async function getPosts(username, reddit, args) {
try {
const user = await reddit.getUser(username).getSubmissions({
const submissions = await reddit.getUser(username).getSubmissions({
sort: args.sort,
limit: Infinity,
});
return user;
return submissions;
} catch (error) {
console.log('\x1b[31m%s\x1b[0m', `Failed to fetch posts from reddit user '${username}': ${error.message} (https://reddit.com/user/${username})`);