Skip to content

Commit

Permalink
✨ feat(Util.ts): add functionality to assign a flair to the Reddit po…
Browse files Browse the repository at this point in the history
…st after submitting it
  • Loading branch information
RagnarLothbrok-Odin committed Jan 30, 2024
1 parent dfa1d61 commit e3d16fe
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/utils/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,17 @@ export async function postToReddit(client: Client, cnt: string, author: string)
password: process.env.RedditPassword as string,
});

await reddit.submitSelfpost({
subredditName: process.env.RedditSubredditName as string,
title: `📣 | ${cnt.length > 50 ? `${cnt.substring(0, 47)}...` : cnt}`,
text: `${cnt}\n\nPosted by ${author} in our Discord Community at ${process.env.DiscordSupport}\n\nThis is an automated post.`,
})
.then(() => {
await reddit.getSubreddit(process.env.RedditSubredditName as string)
.submitSelfpost({
subredditName: process.env.RedditSubredditName as string,
title: `📣 | ${cnt.length > 50 ? `${cnt.substring(0, 47)}...` : cnt}`,
text: `${cnt}\n\nPosted by ${author} in our Discord Community at ${process.env.DiscordSupport}\n\nThis is an automated post.`,
})
.then((post) => {
if (process.env.RedditFlair) {
post.assignFlair({ text: process.env.RedditFlair, cssClass: '' });
}

console.log(`Posted message "${cnt}" to Reddit.`);
})
.catch((e) => console.error(e));
Expand Down

0 comments on commit e3d16fe

Please sign in to comment.