Skip to content

Commit df3c7d7

Browse files
committed
fix: bg real
1 parent 0215d36 commit df3c7d7

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

src/commands/deathbattle.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)