Skip to content

Commit

Permalink
fix(network): embed colors tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 committed Sep 17, 2023
1 parent 7004d2b commit 4544a47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 0 additions & 5 deletions src/Events/messageCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ export default {
threadId: connection.parentId ? connection.channelId : undefined,
allowedMentions: { parse: [] },
};

if (!channelInDb.embedColor && connection.embedColor && webhookMessage.embeds) {
webhookMessage.embeds[0] = EmbedBuilder.from(webhookMessage.embeds[0])
.setColor(connection.embedColor as HexColorString);
}
}

const webhook = new WebhookClient({ url: connection.webhookURL });
Expand Down
12 changes: 7 additions & 5 deletions src/Scripts/network/displaySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async function setupEmbed(interaction: Interaction, channelId: string) {
{ name: 'Connected', value: yesOrNoEmoji(networkData?.connected, yes, no), inline: true },
{ name: 'Compact', value: yesOrNoEmoji(networkData?.compact, enabled, disabled), inline: true },
{ name: 'Profanity Filter', value: yesOrNoEmoji(networkData?.profFilter, enabled, disabled), inline: true },
{ name: 'Embed Color', value: networkData?.embedColor ? `\`${networkData?.embedColor}\`` : no, inline: true },
])
.setColor(colors('chatbot'))
.setThumbnail(interaction.guild?.iconURL() || interaction.client.user.avatarURL())
Expand Down Expand Up @@ -180,8 +181,9 @@ export = {
.setCustomId('embed_color')
.setStyle(TextInputStyle.Short)
.setLabel('Embed Color')
.setPlaceholder('Provide a hex color code.')
.setValue(updConnection.embedColor || '#000000'),
.setPlaceholder('Provide a hex color code or leave blank to remove.')
.setValue(updConnection.embedColor || '#000000')
.setRequired(false),
),
);

Expand All @@ -204,7 +206,7 @@ export = {
const embedColor = modalSubmit.fields.getTextInputValue('embed_color');

const hex_regex = /^#[0-9A-F]{6}$/i;
if (!hex_regex.test(embedColor)) {
if (embedColor && !hex_regex.test(embedColor)) {
modalSubmit.reply({
content: `${emoji.normal.no} Invalid hex color code. Please try again.`,
ephemeral: true,
Expand All @@ -214,11 +216,11 @@ export = {

await db.connectedList.update({
where: { channelId: updConnection.channelId },
data: { embedColor },
data: { embedColor: embedColor ? embedColor : { unset: true } },
});

modalSubmit.reply({
content: `${emoji.normal.yes} Embed color successfully set to \`${embedColor}\`!`,
content: `${emoji.normal.yes} Embed color successfully ${embedColor ? `set to \`${embedColor}\`!` : 'unset'}`,
ephemeral: true,
});
break;
Expand Down

0 comments on commit 4544a47

Please sign in to comment.