Compare commits
2 commits
ef2ccf95f4
...
1ebd111e85
Author | SHA1 | Date | |
---|---|---|---|
|
1ebd111e85 | ||
|
49c6282784 |
4 changed files with 19 additions and 0 deletions
10
README.md
Normal file
10
README.md
Normal 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
3
config.example.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"token": "INSERT_TOKEN_HERE"
|
||||||
|
}
|
|
@ -153,6 +153,10 @@ if (!config.token) {
|
||||||
return;
|
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 result = await MakePrediction(election, overlayimage?.url, overlayopacity ? Math.round((overlayopacity / 100) * 255) : 255);
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.setTitle(election.title)
|
.setTitle(election.title)
|
||||||
|
|
|
@ -47,6 +47,7 @@ export function MakePrediction(election : Election, overlay_image?: string, over
|
||||||
const url = await fetch(overlay_image);
|
const url = await fetch(overlay_image);
|
||||||
const arrayBuffer = await url.arrayBuffer();
|
const arrayBuffer = await url.arrayBuffer();
|
||||||
const overlayBuffer = Buffer.from(arrayBuffer);
|
const overlayBuffer = Buffer.from(arrayBuffer);
|
||||||
|
const { width, height } = await sharp(png).metadata();
|
||||||
|
|
||||||
const overlay = await sharp(overlayBuffer)
|
const overlay = await sharp(overlayBuffer)
|
||||||
.composite([{
|
.composite([{
|
||||||
|
@ -59,6 +60,7 @@ export function MakePrediction(election : Election, overlay_image?: string, over
|
||||||
tile: true,
|
tile: true,
|
||||||
blend: 'dest-in',
|
blend: 'dest-in',
|
||||||
}])
|
}])
|
||||||
|
.resize(width, height)
|
||||||
.png()
|
.png()
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue