mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
feat(bots/discord/utils/discord/embeds): expose applyCommonEmbedStyles fn
This commit is contained in:
@@ -3,27 +3,24 @@ import { EmbedBuilder } from 'discord.js'
|
||||
import type { ConfigMessageScanResponseMessage } from '../../../config.example'
|
||||
|
||||
export const createErrorEmbed = (title: string, description?: string) =>
|
||||
applyCommonStyles(
|
||||
applyCommonEmbedStyles(
|
||||
new EmbedBuilder()
|
||||
.setTitle(title)
|
||||
.setDescription(description ?? null)
|
||||
.setAuthor({ name: 'Error' })
|
||||
.setColor('Red'),
|
||||
false,
|
||||
)
|
||||
|
||||
export const createStackTraceEmbed = (stack: unknown) =>
|
||||
// biome-ignore lint/style/useTemplate: shut
|
||||
createErrorEmbed('An exception was thrown', '```js' + stack + '```')
|
||||
createErrorEmbed('An exception was thrown', '```js\n' + stack + '```')
|
||||
|
||||
export const createSuccessEmbed = (title: string, description?: string) =>
|
||||
applyCommonStyles(
|
||||
applyCommonEmbedStyles(
|
||||
new EmbedBuilder()
|
||||
.setTitle(title)
|
||||
.setDescription(description ?? null)
|
||||
.setAuthor({ name: 'Success' })
|
||||
.setColor('Green'),
|
||||
false,
|
||||
)
|
||||
|
||||
export const createMessageScanResponseEmbed = (
|
||||
@@ -40,14 +37,20 @@ export const createMessageScanResponseEmbed = (
|
||||
iconURL: ReVancedLogoURL,
|
||||
})
|
||||
|
||||
return applyCommonStyles(embed)
|
||||
return applyCommonEmbedStyles(embed, true, true, true)
|
||||
}
|
||||
|
||||
const applyCommonStyles = (embed: EmbedBuilder, setColor = true, setThumbnail = true) => {
|
||||
embed.setFooter({
|
||||
text: 'ReVanced',
|
||||
iconURL: ReVancedLogoURL,
|
||||
})
|
||||
export const applyCommonEmbedStyles = (
|
||||
embed: EmbedBuilder,
|
||||
setThumbnail = false,
|
||||
setFooter = false,
|
||||
setColor = false,
|
||||
) => {
|
||||
if (setFooter)
|
||||
embed.setFooter({
|
||||
text: 'ReVanced',
|
||||
iconURL: ReVancedLogoURL,
|
||||
})
|
||||
|
||||
if (setColor) embed.setColor(DefaultEmbedColor)
|
||||
if (setThumbnail) embed.setThumbnail(ReVancedLogoURL)
|
||||
|
||||
Reference in New Issue
Block a user