(state)
| 54 | } |
| 55 | |
| 56 | function buildPreviewEmbed(state) { |
| 57 | const embed = new EmbedBuilder(); |
| 58 | |
| 59 | if (state.title) embed.setTitle(state.title.substring(0, 256)); |
| 60 | if (state.description) embed.setDescription(state.description.substring(0, 4096)); |
| 61 | |
| 62 | try { |
| 63 | embed.setColor(state.color || getColor('primary')); |
| 64 | } catch { |
| 65 | embed.setColor(getColor('primary')); |
| 66 | } |
| 67 | |
| 68 | if (state.author?.name) { |
| 69 | const obj = { name: state.author.name.substring(0, 256) }; |
| 70 | if (state.author.iconUrl && isValidUrl(state.author.iconUrl)) obj.iconURL = state.author.iconUrl; |
| 71 | if (state.author.url && isValidUrl(state.author.url)) obj.url = state.author.url; |
| 72 | embed.setAuthor(obj); |
| 73 | } |
| 74 | |
| 75 | if (state.footer?.text) { |
| 76 | const obj = { text: state.footer.text.substring(0, 2048) }; |
| 77 | if (state.footer.iconUrl && isValidUrl(state.footer.iconUrl)) obj.iconURL = state.footer.iconUrl; |
| 78 | embed.setFooter(obj); |
| 79 | } |
| 80 | |
| 81 | if (state.thumbnail && isValidUrl(state.thumbnail)) embed.setThumbnail(state.thumbnail); |
| 82 | if (state.image && isValidUrl(state.image)) embed.setImage(state.image); |
| 83 | if (state.timestamp) embed.setTimestamp(); |
| 84 | |
| 85 | if (state.fields.length > 0) embed.addFields(state.fields.slice(0, 25)); |
| 86 | |
| 87 | if ( |
| 88 | !state.title && |
| 89 | !state.description && |
| 90 | state.fields.length === 0 && |
| 91 | !state.author?.name |
| 92 | ) { |
| 93 | embed.setDescription('*(Empty — use the menu below to add content)*'); |
| 94 | } |
| 95 | |
| 96 | return embed; |
| 97 | } |
| 98 | |
| 99 | function buildDashboardEmbed(state) { |
| 100 | const trunc = (str, n) => |
no test coverage detected