Draw each character with random y-offset
This commit is contained in:
@@ -45,7 +45,19 @@ module.exports = {
|
|||||||
ctx.textBaseline = 'middle';
|
ctx.textBaseline = 'middle';
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = 'center';
|
||||||
ctx.fillStyle = '#ffffff';
|
ctx.fillStyle = '#ffffff';
|
||||||
ctx.fillText(captcha, 100, 37.5);
|
|
||||||
|
// Calculate spacing between characters to fit within canvas width
|
||||||
|
const charWidth = 30;
|
||||||
|
const totalWidth = captcha.length * charWidth;
|
||||||
|
const startX = (canvas.width - totalWidth) / 2;
|
||||||
|
|
||||||
|
// Draw each character with random y-offset
|
||||||
|
for (let i = 0; i < captcha.length; i++) {
|
||||||
|
const x = startX + i * charWidth + charWidth / 2; // Adjust x-position for each character
|
||||||
|
const y = 37.5 + Math.random() * 30 - 15; // Random y-offset
|
||||||
|
ctx.fillText(captcha[i], x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Adding noise
|
// Adding noise
|
||||||
for (let i = 0; i < 50; i++) {
|
for (let i = 0; i < 50; i++) {
|
||||||
@@ -81,6 +93,7 @@ module.exports = {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (interaction.channel.id !== cfg.guilds[guildId].channelId) {
|
if (interaction.channel.id !== cfg.guilds[guildId].channelId) {
|
||||||
return interaction.reply({ content: cfg.messages.wrongChannel, ephemeral: true })
|
return interaction.reply({ content: cfg.messages.wrongChannel, ephemeral: true })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user