mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-18 00:33:59 +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'
|
import type { ConfigMessageScanResponseMessage } from '../../../config.example'
|
||||||
|
|
||||||
export const createErrorEmbed = (title: string, description?: string) =>
|
export const createErrorEmbed = (title: string, description?: string) =>
|
||||||
applyCommonStyles(
|
applyCommonEmbedStyles(
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
.setDescription(description ?? null)
|
.setDescription(description ?? null)
|
||||||
.setAuthor({ name: 'Error' })
|
.setAuthor({ name: 'Error' })
|
||||||
.setColor('Red'),
|
.setColor('Red'),
|
||||||
false,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
export const createStackTraceEmbed = (stack: unknown) =>
|
export const createStackTraceEmbed = (stack: unknown) =>
|
||||||
// biome-ignore lint/style/useTemplate: shut
|
// 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) =>
|
export const createSuccessEmbed = (title: string, description?: string) =>
|
||||||
applyCommonStyles(
|
applyCommonEmbedStyles(
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
.setDescription(description ?? null)
|
.setDescription(description ?? null)
|
||||||
.setAuthor({ name: 'Success' })
|
|
||||||
.setColor('Green'),
|
.setColor('Green'),
|
||||||
false,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
export const createMessageScanResponseEmbed = (
|
export const createMessageScanResponseEmbed = (
|
||||||
@@ -40,14 +37,20 @@ export const createMessageScanResponseEmbed = (
|
|||||||
iconURL: ReVancedLogoURL,
|
iconURL: ReVancedLogoURL,
|
||||||
})
|
})
|
||||||
|
|
||||||
return applyCommonStyles(embed)
|
return applyCommonEmbedStyles(embed, true, true, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const applyCommonStyles = (embed: EmbedBuilder, setColor = true, setThumbnail = true) => {
|
export const applyCommonEmbedStyles = (
|
||||||
embed.setFooter({
|
embed: EmbedBuilder,
|
||||||
text: 'ReVanced',
|
setThumbnail = false,
|
||||||
iconURL: ReVancedLogoURL,
|
setFooter = false,
|
||||||
})
|
setColor = false,
|
||||||
|
) => {
|
||||||
|
if (setFooter)
|
||||||
|
embed.setFooter({
|
||||||
|
text: 'ReVanced',
|
||||||
|
iconURL: ReVancedLogoURL,
|
||||||
|
})
|
||||||
|
|
||||||
if (setColor) embed.setColor(DefaultEmbedColor)
|
if (setColor) embed.setColor(DefaultEmbedColor)
|
||||||
if (setThumbnail) embed.setThumbnail(ReVancedLogoURL)
|
if (setThumbnail) embed.setThumbnail(ReVancedLogoURL)
|
||||||
|
|||||||
Reference in New Issue
Block a user