Skip to content

Commit

Permalink
randommeme keep track of randomly rolled subreddit name
Browse files Browse the repository at this point in the history
  • Loading branch information
Supinic committed Oct 17, 2024
1 parent 642e8b4 commit db0d094
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion commands/randommeme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {
}

const input = (args.shift() ?? sb.Utils.randArray(config.defaultMemeSubreddits));
const subreddit = encodeURIComponent(input.toLowerCase());
let subreddit = encodeURIComponent(input.toLowerCase());

/** @type {Subreddit} */
let forum = this.data.subreddits[subreddit];
Expand All @@ -77,6 +77,10 @@ module.exports = {

forum = new Subreddit(body);
if (!config.uncached.includes(subreddit)) {
// override the subreddit name in case of uncached subreddits. if it isn't overridden,
// the original name (e.g. "random") stays, and the posts request is rolled randomly again,
// creating a de-synchronization between the random roll and the result.
subreddit = forum.name;
this.data.subreddits[subreddit] = forum;
}
}
Expand Down

0 comments on commit db0d094

Please sign in to comment.