Compare commits

...

2 commits

Author SHA1 Message Date
dartz 1ebd111e85 make image fit 2024-07-25 22:23:39 -04:00
dartz 49c6282784 readme + check opacity 2024-07-25 19:32:30 -04:00
4 changed files with 19 additions and 0 deletions

10
README.md Normal file
View file

@ -0,0 +1,10 @@
# ElectionsBot
A political bot for Discord that returns data, results, and more.
# Quickstart
```
npm i
tsc
node dist/index.js
```

3
config.example.json Normal file
View file

@ -0,0 +1,3 @@
{
"token": "INSERT_TOKEN_HERE"
}

View file

@ -153,6 +153,10 @@ if (!config.token) {
return;
}
}
if (overlayopacity > 100 || overlayopacity < 0) {
await i.editReply("Invalid opacity!");
return;
}
var result = await MakePrediction(election, overlayimage?.url, overlayopacity ? Math.round((overlayopacity / 100) * 255) : 255);
var embed = new EmbedBuilder()
.setTitle(election.title)

View file

@ -47,6 +47,7 @@ export function MakePrediction(election : Election, overlay_image?: string, over
const url = await fetch(overlay_image);
const arrayBuffer = await url.arrayBuffer();
const overlayBuffer = Buffer.from(arrayBuffer);
const { width, height } = await sharp(png).metadata();
const overlay = await sharp(overlayBuffer)
.composite([{
@ -59,6 +60,7 @@ export function MakePrediction(election : Election, overlay_image?: string, over
tile: true,
blend: 'dest-in',
}])
.resize(width, height)
.png()
.toBuffer();