diff options
| author | Fuwn <[email protected]> | 2025-09-09 18:16:44 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-09-09 18:16:44 -0700 |
| commit | 8baec3564fccac1a7743ac9de481f54e0808c0c9 (patch) | |
| tree | e29b09fb158539a15df8a5a10bb484666fb22c2d /src/discord/embeds.ts | |
| parent | refactor(src): Use arrow functions everywhere (diff) | |
| download | umabotdiscord-8baec3564fccac1a7743ac9de481f54e0808c0c9.tar.xz umabotdiscord-8baec3564fccac1a7743ac9de481f54e0808c0c9.zip | |
style: Use base prettier:recommended rules
Diffstat (limited to 'src/discord/embeds.ts')
| -rw-r--r-- | src/discord/embeds.ts | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/discord/embeds.ts b/src/discord/embeds.ts index 833c831..1fad102 100644 --- a/src/discord/embeds.ts +++ b/src/discord/embeds.ts @@ -1,16 +1,16 @@ -import type { DiscordEmbed } from './interfaces.ts'; -import type { RedditPost } from '../reddit.ts'; +import type { DiscordEmbed } from "./interfaces.ts"; +import type { RedditPost } from "../reddit.ts"; const decodeHtmlEntities = (str: string): string => { return str - .replace(/&/g, '&') - .replace(/</g, '<') - .replace(/>/g, '>') + .replace(/&/g, "&") + .replace(/</g, "<") + .replace(/>/g, ">") .replace(/"/g, '"') .replace(/'/g, "'") - .replace(///g, '/') - .replace(/`/g, '`') - .replace(/=/g, '='); + .replace(///g, "/") + .replace(/`/g, "`") + .replace(/=/g, "="); }; export const createPostEmbed = (post: RedditPost): DiscordEmbed => { @@ -19,10 +19,10 @@ export const createPostEmbed = (post: RedditPost): DiscordEmbed => { post.secure_media?.reddit_video?.fallback_url || post.url; - let description = post.selftext || ''; + let description = post.selftext || ""; if (description.length > 1000) - description = description.substring(0, 997).trim() + ' ...'; + description = description.substring(0, 997).trim() + " ..."; const embed: DiscordEmbed = { title: post.title, @@ -35,30 +35,30 @@ export const createPostEmbed = (post: RedditPost): DiscordEmbed => { }, fields: [ { - name: 'Score', + name: "Score", value: `${post.score} ⬆️`, inline: true, }, { - name: 'Comments', + name: "Comments", value: `${post.num_comments} 💬`, inline: true, }, ], timestamp: new Date(post.created_utc * 1000).toISOString(), footer: { - text: 'r/okbuddyumamusume', + text: "r/okbuddyumamusume", }, }; if (mediaUrl) if (post.media?.reddit_video || post.secure_media?.reddit_video) { - if (!description) description = ''; + if (!description) description = ""; description += - '\n\n📹 **This post contains a video** - [Click here to view](' + + "\n\n📹 **This post contains a video** - [Click here to view](" + mediaUrl + - ')'; + ")"; embed.description = description; if (post.preview?.images?.[0]?.source?.url) { @@ -66,21 +66,21 @@ export const createPostEmbed = (post: RedditPost): DiscordEmbed => { post.preview.images[0].source.url, ); - console.log('Using preview image:', decodedURL); + console.log("Using preview image:", decodedURL); embed.image = { url: decodedURL }; } else if ( post.thumbnail && - post.thumbnail !== 'self' && - post.thumbnail !== 'default' + post.thumbnail !== "self" && + post.thumbnail !== "default" ) { const decodedThumbnail = decodeHtmlEntities(post.thumbnail); - console.log('Using thumbnail:', decodedThumbnail); + console.log("Using thumbnail:", decodedThumbnail); embed.image = { url: decodedThumbnail }; } else { - console.log('No suitable thumbnail found for video post'); + console.log("No suitable thumbnail found for video post"); } } else { embed.image = { url: mediaUrl }; |