@@ -128,16 +128,34 @@ async function createBattleImage(
128128 const canvas = createCanvas ( 1920 , 1080 ) ;
129129 const ctx = canvas . getContext ( "2d" ) ;
130130
131+ const possiblePaths = [
132+ path . join ( process . cwd ( ) , "src" , "deathbattle.png" ) ,
133+ path . join ( process . cwd ( ) , "dist" , "deathbattle.png" ) ,
134+ path . join ( process . cwd ( ) , "altershaper-bot" , "dist" , "deathbattle.png" ) ,
135+ ] ;
136+
137+ let background : any = null ;
138+
139+ for ( const imagePath of possiblePaths ) {
140+ try {
141+ background = await loadImage ( imagePath ) ;
142+ break ;
143+ } catch ( error ) {
144+ continue ;
145+ }
146+ }
147+
131148 try {
132- const backgroundPath = path . join ( process . cwd ( ) , "dist" , "deathbattle.png" ) ;
133- console . log ( "Attempting to load background image from:" , backgroundPath ) ;
134- console . log ( "Current working directory:" , process . cwd ( ) ) ;
135- console . log ( "__dirname:" , __dirname ) ;
136-
137- const background = await loadImage ( backgroundPath ) ;
138- console . log ( "Successfully loaded background image!" ) ;
139-
140- ctx . drawImage ( background , 0 , 0 , 1920 , 1080 ) ;
149+ if ( background ) {
150+ ctx . drawImage ( background , 0 , 0 , 1920 , 1080 ) ;
151+ } else {
152+ ctx . fillStyle = "#2F3136" ;
153+ ctx . fillRect ( 0 , 0 , 1920 , 1080 ) ;
154+ ctx . fillStyle = "#FFFFFF" ;
155+ ctx . font = "bold 66px Verdana" ;
156+ ctx . textAlign = "center" ;
157+ ctx . fillText ( "DEATHBATTLE" , 960 , 540 ) ;
158+ }
141159
142160 const avatar1 = await loadImage (
143161 fighter1 . displayAvatarURL ( { extension : "png" , size : 512 } ) ,
0 commit comments