-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
153 lines (137 loc) · 6.36 KB
/
app.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// const webshot = require('webshot') //https://www.npmjs.com/package/webshot-node
var fs = require('fs')
const axios = require('axios');
const Discord = require('discord.js')
const bot = new Discord.Client()
const auth = require("./auth")
const token = auth.token
const PREFIX = '!'
const puppeteer = require('puppeteer');
bot.on('ready', () => {
console.log('Bot is online!')
bot.channels.cache.get('737744651498291308').send(`Hello, I'm Emi, Money Guild regear assistance.
Send me a **private message** to begin a regear request (**!deaths** *IGN*)
Type **!info** or **!help** for more informations.`);
})
//737744651498291308 FUYU
//737024926057365504 MG
bot.on('message', message => {
if(message.content === "HELLO") {
message.reply('HELLO FRIEND') // TAG THE PERSON
}
let args = message.content.substring(PREFIX.length).split(" ")
switch(args[0]) {
case 'deaths':
(async () => {
await axios.get('https://gameinfo.albiononline.com/api/gameinfo/search?q=Fuyuh')
.then( async (response) => {
let playerData = response.data.players
bot.channels.cache.get('737744651498291308').send(`IGN : ${playerData[0].Name}
Guild : ${playerData[0].GuildName}
Your current PVP Fameratio is ${playerData[0].FameRatio}
Looking for your deaths ...`)
await axios.get('https://gameinfo.albiononline.com/api/gameinfo/players/lC75WrGoR5mz5iEImipTqw/deaths')
.then( response => {
// console.log(response.data[0])
let battles = []
response.data.forEach( battle => {
let bat = {name : `ID : ${battle.EventId}`, value: `Date : ${new Date(battle.TimeStamp).toUTCString()}
Killer (Guild) : ${battle.Killer.Name} (${battle.Killer.GuildName})
Your Item Power : ${battle.Victim.AverageItemPower}
Killboard : https://handholdreport.com/#/killboard/${battle.BattleId}`}
battles.push(bat)
})
let embedDeaths = { embed: {
color: 3447003,
title: `${message.author.username} Deaths`,
description: "**Type !regear <deathID> to launch your regear request**",
fields: battles,
// timestamp: new Date(),
// image: {
// url: currentApplication[message.author.id].image,
// },
}
}
message.channel.send(embedDeaths);
})
})
.catch(function (error) {
console.log(error);
})
.catch( err => {
bot.channels.cache.get('737744651498291308').send('The request failed. Please try again')
})
})()
bot.channels.cache.get('737744651498291308').send('Looking for your profile ...')
break
case 'regear':
bot.channels.cache.get('737744651498291308').send('Looking for your death screenshot ...');
let deathID = args[1];
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width: 2560, height: 1780 })
await page.goto(`https://albiononline.com/en/killboard/kill/${deathID}`);
await page.waitForSelector(".end .item-list__body .item--MainHand img")
setTimeout(async () => {
await page.screenshot({
path: 'example.png',
// fullPage: false,
clip: {
x: 1370,
y: 490,
width: 430,
height: 1100
}
});
await browser.close();
// message.channel.send(exampleEmbed);
message.channel.send('pong!', {files : ["./example.png"]}) // NO TAG
// fs.unlink('example.png')
setTimeout(async () => {
fs.unlink('example.png', (err) => {
if (err) {
throw err;
}
console.log("File is deleted.");
});
}, 2000)
}, 5000)
})()
break
/* case 'ping':
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width: 2560, height: 1780 })
await page.goto('https://albiononline.com/en/killboard/kill/103773175').catch(message.channel.send('pong!'));
await page.waitForSelector(".end .item-list__body .item--MainHand img").catch(message.channel.send('pong!'))
setTimeout(async () => { ;
await page.screenshot({
path: 'example.png',
// fullPage: false,
clip: {
x: 1370,
y: 490,
width: 430,
height: 1100
}
});
await browser.close();
message.channel.send(exampleEmbed);
message.channel.send('pong!', {files : ["./example.png"]}) // NO TAG
setTimeout(async () => {
fs.unlink('example.png', (err) => {
if (err) {
throw err;
}
console.log("File is deleted.");
});
}, 2000)
}, 5000)
})();
bot.channels.cache.get('737744651498291308').send('Hello here!') // CHOOSE CHANNEL + NO TAG
break; */
}
})
bot.login(token)