Skip to content

Commit 1156c21

Browse files
committed
gav
1 parent e8977e4 commit 1156c21

File tree

5 files changed

+62
-100
lines changed

5 files changed

+62
-100
lines changed

Assets/gav.png

246 KB
Loading

Discord_bot/MessageEvent.js

-87
This file was deleted.

Discord_bot/bot.js

-12
This file was deleted.

Routes/Other.js

+62
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const router = require('express').Router();
22
const { Client } = require('eris');
33
const bot = new Client();
4+
const canvas = require('canvas');
5+
const path = require('path');
46

57

68
/**
@@ -98,6 +100,66 @@ router.post('/top.gg_vote', (req, res) => {
98100
});
99101

100102

103+
let gavCahce;
104+
/**
105+
* @swagger
106+
* /other/gav:
107+
* get:
108+
* description: Gav
109+
* tags: [Other]
110+
* parameters:
111+
* - name: key
112+
* description: Your API key, Join our discord server to get one (https://monke.vip/discord)
113+
* in: query
114+
* type: string
115+
* - name: imgUrl
116+
* description: The url of the image to place on gav.
117+
* in: query
118+
* required: true
119+
* type: string
120+
* responses:
121+
* 200:
122+
* description: Success
123+
* 400:
124+
* description: Error
125+
*/
126+
router.get('/gav', async (req, res) => {
127+
128+
const imgUrl = req.urlParams.imgUrl;
129+
130+
if(!imgUrl) return res.json({
131+
error: true,
132+
message: 'Missing imgUrl param'
133+
});
134+
135+
136+
let toPlace;
137+
try{
138+
toPlace = await canvas.loadImage(imgUrl);
139+
} catch (err) {
140+
console.log(err)
141+
return res.status(400).json({
142+
error: true,
143+
message: 'Failed to load image.'
144+
});
145+
};
146+
147+
let gav;
148+
if(gavCahce) gav = gavCahce;
149+
else gav = await canvas.loadImage(path.join(__dirname + '../../Assets', 'gav.png'));
150+
151+
152+
const Canvas = canvas.createCanvas(gav.width, gav.height);
153+
const ctx = Canvas.getContext('2d');
154+
ctx.drawImage(gav, 0, 0, Canvas.width, Canvas.height);
155+
console.log(gav.height, gav.width)
156+
ctx.drawImage(toPlace, 270, 70, 60, 60);
157+
158+
159+
res.set({'Content-Type': 'image/png'});
160+
res.status(200).send(Canvas.toBuffer());
161+
});
162+
101163

102164
module.exports = {
103165
end: '/other/',

index.js

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ const Init = async () => {
7171

7272
app.listen(port, () => console.log('on port: ' + port));
7373

74-
// require('./Discord_bot/bot');
7574
};
7675

7776
Init();

0 commit comments

Comments
 (0)