forked from Sorok-Dva/allods-web-library
-
Notifications
You must be signed in to change notification settings - Fork 1
/
examples.js
61 lines (52 loc) · 1.71 KB
/
examples.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
require('dotenv').config();
const { Account } = require('./index');
let account = new Account('Sorok');
// User Login
account.checkPassword('42').then(async result => {
// Login abort because user not found or wrong password
if (result.status !== 'SUCCESS')
console.log('Login failed: ' + result.reason);
// Login abort because account is not Active
let status = await account.status();
if (status.accountStatus !== 'Active')
console.log('Login failed: Account Inactive');
// Login abort because player is banned
let sData = await account.Sanction().get();
let isBanned = sData.sanctions
.map(s => s.sanctionType === 'Ban' && s.isOn === true)
.filter(v => v === true)[0];
if (isBanned)
console.log('Login failed: User is banned');
let details = await account.get();
console.log(details)
});
/*account.get()
.then(account => console.log(account))
.catch(error => console.log(error));*/
/*account.create({
password: 'password',
accessLevel: 'User',
accountStatus: 'Active'
}).then(result => {
console.log(result);
account.get()
.then(account => console.log(account))
.catch(error => console.error(error));
}).catch(error => console.error(error));*/
/*account.Sanction().set({
type: 'TotalTradeBan',
reason: 'API TEST',
gmName: 'Website',
expireTime: 1586965256
}).then(data => {
console.log(data);
account.Sanction().get().then(sanctions => console.log(sanctions));
}).catch(error => console.error(error));*/
/*account.Sanction().delete({
type: 'TotalTradeBan',
reason: 'API TEST Unban',
gmName: 'Website'
}).then(data => {
console.log(data);
account.Sanction().get().then(sanctions => console.log(sanctions));
}).catch(error => console.error(error));*/