-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbannernaruto.js
50 lines (48 loc) · 1.49 KB
/
bannernaruto.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module.exports.config = {
name: "bannernaruto",
version: "1.0.0",
hasPermision: 0,
credit: "",
description: "tạo banner naruto",
commandCategory: "info",
usages: "[text]",
cooldowns: 0,
};
module.exports.run = async function({
api,
event,
args,
utils,
Users,
Threads
}) {
try {
let axios = require('axios');
let fs = require("fs-extra");
let request = require("request")
let {
threadID,
senderID,
messageID
} = event;
var type = args.join("");
if(!type) {
api.sendMessage("Vui lòng nhập chữ in lên banner", threadID, messageID)
}
const res = await axios.get(encodeURI(`http://lawerpr0ject.herokuapp.com/banner/naruto?text=${type}&apikey=lawerteam`));
console.log(res.data);
let data = res.data;
let callback = function() {
return api.sendMessage({
body: `Banner của bạn đây nha\nApi Author: ${data.author}`,
attachment: fs.createReadStream(__dirname + `/cache/naruto.png`)
}, event.threadID, () => fs.unlinkSync(__dirname + `/cache/naruto.png`), event.messageID);
};
return request(encodeURI(data.url))
.pipe(fs.createWriteStream(__dirname + `/cache/naruto.png`))
.on("close", callback);
} catch (err) {
console.log(err)
return api.sendMessage(`Đã xảy ra lỗi`, event.threadID)
}
}