66 EmbedBuilder ,
77 type RestOrArray
88} from 'discord.js'
9- import { Stream } from 'node:stream'
10- import { EmbedOptions , EmbedSetters } from './types'
9+ import type { Stream } from 'node:stream'
10+ import type { EmbedOptions } from './types'
1111
1212export const useActionRow = <
1313 T extends AnyComponentBuilder = AnyComponentBuilder
@@ -21,24 +21,37 @@ export const useActionRow = <
2121
2222export const useEmbed = ( options : EmbedOptions ) => {
2323 const builder = new EmbedBuilder ( )
24- const setters : EmbedSetters = {
25- color : ( value ) => builder . setColor ( value ?? null ) ,
26- title : ( value ) => builder . setTitle ( value ?? null ) ,
27- url : ( value ) => builder . setURL ( value ?? null ) ,
28- author : ( value ) => builder . setAuthor ( value ?? null ) ,
29- description : ( value ) => builder . setDescription ( value ?? null ) ,
30- thumbnail : ( value ) => builder . setThumbnail ( value ?? null ) ,
31- image : ( value ) => builder . setImage ( value ?? null ) ,
32- timestamp : ( ) => builder . setTimestamp ( ) ,
33- footer : ( value ) => builder . setFooter ( value ?? null ) ,
34- fields : ( value ) => builder . addFields ( ...( value ?? [ ] ) )
35- }
36-
37- Object . entries ( options ) . forEach ( ( [ key , value ] ) => {
38- const _key = key as keyof EmbedOptions
3924
40- setters [ _key ] ! ( value )
41- } )
25+ if ( options . color ) {
26+ builder . setColor ( options . color )
27+ }
28+ if ( options . title ) {
29+ builder . setTitle ( options . title )
30+ }
31+ if ( options . url ) {
32+ builder . setURL ( options . url )
33+ }
34+ if ( options . author ) {
35+ builder . setAuthor ( options . author )
36+ }
37+ if ( options . description ) {
38+ builder . setDescription ( options . description )
39+ }
40+ if ( options . thumbnail ) {
41+ builder . setThumbnail ( options . thumbnail )
42+ }
43+ if ( options . image ) {
44+ builder . setImage ( options . image )
45+ }
46+ if ( options . timestamp ) {
47+ builder . setTimestamp ( options . timestamp )
48+ }
49+ if ( options . footer ) {
50+ builder . setFooter ( options . footer )
51+ }
52+ if ( options . fields ) {
53+ builder . addFields ( ...options . fields )
54+ }
4255
4356 return builder
4457}
0 commit comments