Comparing version 1.0.9 to 1.1.0
25
index.js
@@ -5,4 +5,25 @@ const { images } = require("./lib/apis/images") | ||
const { lyrics } = require("./lib/apis/lyrics") | ||
const ksoftAPI = class ksoftAPI { | ||
constructor(token){ | ||
const Webhook = require("./lib/webhook/server") | ||
/** | ||
* @typedef {Object} webhookOptions webhook options | ||
* @prop {Boolean} useWebhooks whether to use the webhook feature | ||
* @prop {number} port webhook http server port | ||
* @prop {String} Authentication Your webhook authentication | ||
*/ | ||
class ksoftAPI{ | ||
/** | ||
* @constructor | ||
* @param {number} token Your ksoft api token | ||
* @param {boolean} useWebhooks Whether you want to use the webhook feature | ||
* @param {webhookOptions} webhookOptions webhook options | ||
*/ | ||
constructor(token, webhookOptions){ | ||
/** | ||
* The webhook class if useWebhooks is true | ||
* @type {Webhook?} | ||
*/ | ||
this.webhook = null | ||
if(webhookOptions.useWebhooks){ | ||
this.webhook = new Webhook(webhookOptions.port, webhookOptions.Authentication) | ||
} | ||
this.images = new images(token) | ||
@@ -9,0 +30,0 @@ this.bans = new bans(token) |
{ | ||
"name": "ksoft.js", | ||
"version": "1.0.9", | ||
"version": "1.1.0", | ||
"description": "Official API Wrapper for KSoft.Si API, written in Node.js", | ||
@@ -29,3 +29,6 @@ "main": "index.js", | ||
"axios": "^0.18.0", | ||
"form-data": "^2.3.3" | ||
"body-parser": "^1.18.3", | ||
"express": "^4.16.4", | ||
"form-data": "^2.3.3", | ||
"public-ip": "^2.4.0" | ||
}, | ||
@@ -32,0 +35,0 @@ "devDependencies": { |
@@ -54,9 +54,9 @@ # ksoft.js | ||
ksoft.bans.add({ | ||
user: "123456789741" , | ||
mod: "123456789742" , | ||
user_name: "SomeBadUsername" , | ||
user_discriminator: "#1234" , | ||
reason: "Your descriptive reason" , | ||
proof: "Your proof", | ||
appeal_possible: true | ||
user: String , | ||
mod: String , | ||
user_name: String , | ||
user_discriminator: String , | ||
reason: String , | ||
proof: String, | ||
appeal_possible: Boolean | ||
}) | ||
@@ -125,3 +125,30 @@ ``` | ||
## Webhook feature | ||
This just requires adding a few things when we initiate ksoft.js | ||
```javascript | ||
const Ksoft = require("ksoft.js") | ||
const ksoft = new Ksoft("your ksoft token", { | ||
useWebhooks: true, | ||
port: 2000, // this is the port the http server is going to run on. This can be whatever port you want I am just using 2000 as an example | ||
Authentication: "your webhook authentication token" | ||
}) | ||
ksoft.webhook.on("ready", info => { | ||
console.log(info) // this will return the host your http server is running on. This is what you will give to ksoft to send the info to. { "host": "yourpublicip:theportyouspecified"} | ||
}) | ||
``` | ||
that was just to get everything up and running now let's see how we can actually access that data. It's really simple :) | ||
```javascript | ||
// this is an extension of the previous example. Everything works on events so you can simply do this | ||
ksoft.webhook.on('ban', banData => { | ||
console.log(banData) // there you simply get the banInfo sent from ksoft. All the event names are the same as on the ksoft documentation so if you want more info just go to https://docs.ksoft.si/api/webhooks | ||
}) | ||
``` | ||
Special thanks to sdf for helping me troubleshoot some stuff :) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76898
9
828
153
5
+ Addedbody-parser@^1.18.3
+ Addedexpress@^4.16.4
+ Addedpublic-ip@^2.4.0
+ Added@sindresorhus/is@0.7.0(transitive)
+ Addedaccepts@1.3.8(transitive)
+ Addedarray-flatten@1.1.1(transitive)
+ Addedbody-parser@1.20.3(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcacheable-request@2.1.4(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedclone-response@1.0.2(transitive)
+ Addedcontent-disposition@0.5.4(transitive)
+ Addedcontent-type@1.0.5(transitive)
+ Addedcookie@0.7.1(transitive)
+ Addedcookie-signature@1.0.6(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addeddecompress-response@3.3.0(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addeddns-packet@1.3.4(transitive)
+ Addeddns-socket@1.6.3(transitive)
+ Addedduplexer3@0.1.5(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedencodeurl@1.0.22.0.0(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedescape-html@1.0.3(transitive)
+ Addedetag@1.8.1(transitive)
+ Addedexpress@4.21.1(transitive)
+ Addedfinalhandler@1.3.1(transitive)
+ Addedforwarded@0.2.0(transitive)
+ Addedfresh@0.5.2(transitive)
+ Addedfrom2@2.3.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedget-stream@3.0.0(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedgot@8.3.2(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbol-support-x@1.4.2(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-to-string-tag-x@1.4.1(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-cache-semantics@3.8.1(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedinto-stream@3.1.0(transitive)
+ Addedip@1.1.9(transitive)
+ Addedip-regex@2.1.0(transitive)
+ Addedipaddr.js@1.9.1(transitive)
+ Addedis-ip@2.0.0(transitive)
+ Addedis-object@1.0.2(transitive)
+ Addedis-plain-obj@1.1.0(transitive)
+ Addedis-retry-allowed@1.2.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisurl@1.0.0(transitive)
+ Addedjson-buffer@3.0.0(transitive)
+ Addedkeyv@3.0.0(transitive)
+ Addedlowercase-keys@1.0.01.0.1(transitive)
+ Addedmedia-typer@0.3.0(transitive)
+ Addedmerge-descriptors@1.0.3(transitive)
+ Addedmethods@1.1.2(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedmimic-response@1.0.1(transitive)
+ Addedms@2.0.02.1.3(transitive)
+ Addednegotiator@0.6.3(transitive)
+ Addednormalize-url@2.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedon-finished@2.4.1(transitive)
+ Addedp-cancelable@0.4.1(transitive)
+ Addedp-finally@1.0.0(transitive)
+ Addedp-is-promise@1.1.0(transitive)
+ Addedp-timeout@2.0.1(transitive)
+ Addedparseurl@1.3.3(transitive)
+ Addedpath-to-regexp@0.1.10(transitive)
+ Addedpify@3.0.0(transitive)
+ Addedprepend-http@2.0.0(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedproxy-addr@2.0.7(transitive)
+ Addedpublic-ip@2.5.0(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedquery-string@5.1.1(transitive)
+ Addedrange-parser@1.2.1(transitive)
+ Addedraw-body@2.5.2(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedresponselike@1.0.2(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsend@0.19.0(transitive)
+ Addedserve-static@1.16.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedsort-keys@2.0.0(transitive)
+ Addedstatuses@2.0.1(transitive)
+ Addedstrict-uri-encode@1.1.0(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedtimed-out@4.0.1(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedtype-is@1.6.18(transitive)
+ Addedunpipe@1.0.0(transitive)
+ Addedurl-parse-lax@3.0.0(transitive)
+ Addedurl-to-options@1.0.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedutils-merge@1.0.1(transitive)
+ Addedvary@1.1.2(transitive)