TheCodedProf | da197f2 | 2023-03-01 18:15:51 -0500 | [diff] [blame^] | 1 | import Styles from "../../styles/Components/transcripts.module.css" |
| 2 | import Image from "next/image"; |
| 3 | import JSDom from "jsdom"; |
TheCodedProf | c86e44b | 2023-02-28 17:30:57 -0500 | [diff] [blame] | 4 | |
TheCodedProf | da197f2 | 2023-03-01 18:15:51 -0500 | [diff] [blame^] | 5 | function embed(props) { |
TheCodedProf | c86e44b | 2023-02-28 17:30:57 -0500 | [diff] [blame] | 6 | |
TheCodedProf | da197f2 | 2023-03-01 18:15:51 -0500 | [diff] [blame^] | 7 | let description = props.embed.description; |
| 8 | if (description) { |
| 9 | description = description.split("\n"); |
| 10 | } |
| 11 | |
| 12 | return ( // added it |
| 13 | <div className={Styles.embed} style={{borderColor: props.color ?? "#F27878"}}> |
| 14 | { |
| 15 | props.embed.author ? |
| 16 | <div className={Styles.embedAuthor}> |
| 17 | { |
| 18 | props.embed.author.iconURL ? |
| 19 | <Image src={props.embed.author.iconURL} alt=""/> : |
| 20 | null |
| 21 | } |
| 22 | { |
| 23 | props.embed.author.url ? |
| 24 | <a href={props.embed.author.url}> |
| 25 | {props.embed.author?.name ?? ""} |
| 26 | </a> : |
| 27 | <p>{props.embed.author?.name ?? ""}</p> |
| 28 | } |
| 29 | </div> : |
| 30 | null |
| 31 | } |
| 32 | { |
| 33 | props.embed.title ? |
| 34 | <div className={Styles.embedTitle}>{props.embed.title}</div> : |
| 35 | null |
| 36 | } |
| 37 | { |
| 38 | props.embed.description ? |
| 39 | <div className={Styles.embedDescription}> |
| 40 | { |
| 41 | description.map(i => {// idk how to do make this work |
| 42 | i = i |
| 43 | .replaceAll(/<a?:.+:\D+>/g, (match, id) => { |
| 44 | return <Image src={`https://cdn.discordapp.com/emojis/${id}.png`} alt=""/> |
| 45 | }) |
| 46 | .replaceAll(/\*\*.+\*\*/g, (match, text) => { |
| 47 | return <b>{text}</b> |
| 48 | }) |
| 49 | .replaceAll(/\*.+\*/g, (match, text) => { |
| 50 | return <i>{text}</i> |
| 51 | }) |
| 52 | return <>{new JSDom.JSDOM(i)}<br/></> // CANT FIND A DOM PARSER THAT WORKS |
| 53 | }) |
| 54 | } |
| 55 | </div> |
| 56 | : null |
| 57 | } |
| 58 | </div> |
| 59 | ) |
TheCodedProf | c86e44b | 2023-02-28 17:30:57 -0500 | [diff] [blame] | 60 | } |
| 61 | |
TheCodedProf | da197f2 | 2023-03-01 18:15:51 -0500 | [diff] [blame^] | 62 | export default embed; |