updated to version 0.1.18
This commit is contained in:
parent
f52b7631dd
commit
a5ac5cde0e
@ -6,7 +6,7 @@
|
|||||||
"authors": [
|
"authors": [
|
||||||
{ "name": "Robin Riis" }
|
{ "name": "Robin Riis" }
|
||||||
],
|
],
|
||||||
"version": "0.1.17",
|
"version": "0.1.18",
|
||||||
"socket": true,
|
"socket": true,
|
||||||
"minimumCoreVersion": 10,
|
"minimumCoreVersion": 10,
|
||||||
"compatibility": {
|
"compatibility": {
|
||||||
|
|||||||
@ -6,7 +6,15 @@ export class PuckoPruttApi {
|
|||||||
this.schema = this.apiUrl + "/schema/"
|
this.schema = this.apiUrl + "/schema/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_fetch_json(url) {
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
|
|
||||||
dagens_lunch(spider) {
|
dagens_lunch(spider) {
|
||||||
return fetch(this.apiUrl + "/dagens_lunch/" + spider + "/", {method: "GET"});
|
return this._fetch_json(this.apiUrl + "/dagens_lunch/" + spider + "/?format=json");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,6 +2,35 @@ function test(user) {
|
|||||||
return `hello ${user}`;
|
return `hello ${user}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function dagens(user, message) {
|
||||||
|
let week = game.modules.get("puckoprutt-foundry-module").api.dagens_lunch(message[1]);
|
||||||
|
if (typeof week !== 'object') {
|
||||||
|
return "could not fetch "+message[1];
|
||||||
|
}
|
||||||
|
let today = new Date().getDay();
|
||||||
|
ret = "";
|
||||||
|
switch(today) {
|
||||||
|
case 1:
|
||||||
|
ret = week["monday"];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
ret = week["tuesday"];
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
ret = week["wednesday"];
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
ret = week["thursday"];
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
ret = week["friday"];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = "Ingen dagens under helger."
|
||||||
|
};
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
export default function puckocommand(user, world, log, message, data) {
|
export default function puckocommand(user, world, log, message, data) {
|
||||||
console.log(`user: ${user}`);
|
console.log(`user: ${user}`);
|
||||||
console.log(`world: ${world}`);
|
console.log(`world: ${world}`);
|
||||||
@ -11,5 +40,6 @@ export default function puckocommand(user, world, log, message, data) {
|
|||||||
console.log(`data: `);
|
console.log(`data: `);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
if(message[0] === "test") return test(user.name);
|
if(message[0] === "test") return test(user.name);
|
||||||
|
if(message[0] === "dagens") return dagens(user.name)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user