MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / createEmbed

Function createEmbed

src/utils/embeds.js:114–213  ·  view source on GitHub ↗
({
  title = '',
  description = '',
  color = 'primary',
  fields = [],
  author = null,
  footer = null,
  thumbnail = null,
  image = null,
  timestamp = false,
  url = null
} = {})

Source from the content-addressed store, hash-verified

112};
113
114export function createEmbed({
115 title = '',
116 description = '',
117 color = 'primary',
118 fields = [],
119 author = null,
120 footer = null,
121 thumbnail = null,
122 image = null,
123 timestamp = false,
124 url = null
125} = {}) {
126 const embed = new EmbedBuilder();
127
128 if (title && typeof title === 'string' && title.length > 0) {
129 embed.setTitle(title.substring(0, 256));
130 }
131
132 if (description && typeof description === 'string' && description.length > 0) {
133 embed.setDescription(description.substring(0, 4096));
134 }
135
136 try {
137 const embedColor = getColor(color) || '#000000';
138 embed.setColor(embedColor);
139 } catch (error) {
140 embed.setColor('#000000');
141 }
142
143 if (Array.isArray(fields) && fields.length > 0) {
144 const validFields = fields.filter(f => f && f.name && f.value);
145 if (validFields.length > 0) {
146 embed.addFields(validFields.slice(0, 25));
147 }
148 }
149
150 if (author) {
151 try {
152 if (typeof author === 'string' && author.length > 0) {
153 embed.setAuthor({ name: author.substring(0, 256) });
154 } else if (author && typeof author.name === 'string') {
155 embed.setAuthor(author);
156 }
157 } catch (error) {
158
159 }
160 }
161
162 if (footer) {
163 try {
164 if (typeof footer === 'string' && footer.length > 0) {
165 embed.setFooter({ text: footer.substring(0, 2048) });
166 } else if (footer && typeof footer.text === 'string') {
167 embed.setFooter(footer);
168 }
169 } catch (error) {
170
171 }

Callers 15

executePrefixCommandFunction · 0.90
executeFunction · 0.90
handleReviewFunction · 0.90
handleListFunction · 0.90
handleListFunction · 0.90
handleStatusFunction · 0.90
balance.jsFile · 0.90
inventory.jsFile · 0.90
fish.jsFile · 0.90
slut.jsFile · 0.90
pay.jsFile · 0.90

Calls 1

getColorFunction · 0.90

Tested by

no test coverage detected