Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 3c2a697

Browse files
committed
fix: improve logic for edit embed controller
1 parent deaff0f commit 3c2a697

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

src/chat-input/Administrator/embeds/controllers.ts

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,42 @@ export const configureEmbedController: EmbedController = async (
165165
fields?: { create: EmbedField[] };
166166
} = {};
167167

168-
if (rawEmbed.data.color) upsertData.color = rawEmbed.data.color;
169-
upsertData.messageText = configureEmbedMessage ?? null;
170-
upsertData.authorName = rawEmbed.data.author?.name ?? null;
171-
upsertData.authorIconURL = rawEmbed.data.author?.icon_url ?? null;
172-
upsertData.authorURL = rawEmbed.data.author?.url ?? null;
173-
upsertData.title = rawEmbed.data.title ?? null;
174-
upsertData.description = rawEmbed.data.description ?? null;
175-
upsertData.url = rawEmbed.data.url ?? null;
176-
upsertData.imageURL = rawEmbed.data.image?.url ?? null;
177-
upsertData.thumbnailURL = rawEmbed.data.thumbnail?.url ?? null;
178-
upsertData.footerText = rawEmbed.data.footer?.text ?? null;
179-
upsertData.footerIconURL = rawEmbed.data.footer?.icon_url ?? null;
168+
if (options.getString('color') || rawEmbed.data.color) upsertData.color = configureEmbedData.color
169+
? resolveColor(`#${configureEmbedData.color.replaceAll('#', '')}`)
170+
: null;
171+
if (options.getString('message') || configureEmbedMessage === null) {
172+
upsertData.messageText = configureEmbedMessage ?? null;
173+
}
174+
if (options.getString('author-name') || configureEmbedData.authorName === null) {
175+
upsertData.authorName = configureEmbedData.authorName ?? null;
176+
}
177+
if (options.getString('author-icon-url') || configureEmbedData.authorIconUrl === null) {
178+
upsertData.authorIconURL = configureEmbedData.authorIconUrl ?? null;
179+
}
180+
if (options.getString('author-url') || configureEmbedData.authorUrl === null) {
181+
upsertData.authorURL = configureEmbedData.authorUrl ?? null;
182+
}
183+
if (options.getString('title') || configureEmbedData.title === null) {
184+
upsertData.title = configureEmbedData.title ?? null;
185+
}
186+
if (options.getString('description') || configureEmbedData.description === null) {
187+
upsertData.description = configureEmbedData.description ?? null;
188+
}
189+
if (options.getString('url') || configureEmbedData.url === null) {
190+
upsertData.url = configureEmbedData.url ?? null;
191+
}
192+
if (options.getString('image-url') || configureEmbedData.imageUrl === null) {
193+
upsertData.imageURL = configureEmbedData.imageUrl ?? null;
194+
}
195+
if (options.getString('thumbnail-url') || configureEmbedData.thumbnailUrl === null) {
196+
upsertData.thumbnailURL = configureEmbedData.thumbnailUrl ?? null;
197+
}
198+
if (options.getString('footer-text') || configureEmbedData.footerText === null) {
199+
upsertData.footerText = configureEmbedData.footerText ?? null;
200+
}
201+
if (options.getString('footer-icon-url') || configureEmbedData.footerIconUrl === null) {
202+
upsertData.footerIconURL = configureEmbedData.footerIconUrl ?? null;
203+
}
180204
if (fields.length > 0) upsertData.fields = { create: fields };
181205

182206
const newTotalFields = (setting?.fields?.length ?? 0) + fields.length;
@@ -222,9 +246,11 @@ export const configureEmbedController: EmbedController = async (
222246
include: { fields: true },
223247
});
224248

225-
i.editReply(Lang.t('commands:embeds.configurationSaved'));
249+
i.deleteReply();
226250
interaction.editReply({
251+
content: `${Lang.t('commands:embeds.configurationSaved')}${messageSuffix}`,
227252
components: [configureEmbedAcceptedRow],
253+
allowedMentions: { parse: [] },
228254
});
229255

230256
const newEmbedData = msg.embeds[0];

0 commit comments

Comments
 (0)