Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ksoft.js

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ksoft.js

Official API Wrapper for KSoft.Si API, written in Node.js

  • 1.2.7
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ksoft.js

Official API Wrapper for KSoft API, written in Node.js

Getting Started

installing...

npm install ksoft.js --save

initializing...

const Ksoft = require('ksoft.js');
const ksoft = new Ksoft(yourtoken, webhookOptions); // webhook options will be reviewed below

Note: When you see a paremeter like this: (value: DataType) I am just defining the type of value it takes. That does not mean it's an object. If it has {} around it then it is an object.

All functions

Images Api

ksoft.images.getRandomMeme();
ksoft.images.getRandomImage(tag: String);
ksoft.images.getTags();
ksoft.images.searchTags(tag: String);
ksoft.images.getImageFromId(snowflake: String);
ksoft.images.getRandomWikiHow(nsfw: Boolean);
ksoft.images.getRandomCutePicture();
ksoft.images.getRandomNSFW();
ksoft.images.getRandomReddit(subReddit: String, removeNSFW: Boolean, span: String); //span is how far back you wanna go into the past to find a post

Bans Api

ksoft.bans.add({
	user: String,
	mod: String,
	user_name: String,
	user_discriminator: String,
	reason: String,
	proof: String,
	appeal_possible: Boolean
});
ksoft.bans.getBanInfo(userID: String);
ksoft.bans.check(userID: String);
ksoft.bans.list(page: Number, perPage: Number);
ksoft.bans.getUpdate(epochDate: String);

advancedBannedOnly is a special option I added that will read through all of the ids given and filter out the people that aren't banned and will only return the ones that are banned. It will also return their whole ban object. It will throw an error if there are no people banned in the list. Use .catch() if you want to handle the error.

ksoft.bans.bulkCheck(ids, {
	moreInfo: Boolean,
	bannedOnly: Boolean,
	advancedBannedOnly: Boolean // this can only be used by itself
});
ksoft.bans.guildMembersCheck(guildMemberCollection, {
	// The guildMemberCollection is the discord.js/eris guildMemberCollection that I can go through and check to see if they are banned
	moreInfo: Boolean,
	ignoreBots: Boolean
});

Kumo Api

ksoft.kumo.search(query: String, {
	fast: Boolean,
	more: Boolean,
	mapZoom: Number,
	includeMap: Boolean,
});
ksoft.kumo.getSimpleWeather(reportType: String, query: String, units: String, lang: String, icons: String);
ksoft.kumo.getAdvancedWeather(latitude: Number, longitude: Number, reportType: String, units: String, lang: String, icons: String)
ksoft.kumo.geoip(ip: String);
ksoft.kumo.convertCurrency(from: String, to: String, value: Number); // From and to are the type of currency you are converting. And value is the value you are converting. (ex: ksoft.kumo.convertCurrency("usd", "eur", 100).then(res => {"value": 88.6129, "pretty": "88.61 EUR"}))

Lyrics Api

ksoft.lyrics.search(query: String, {
	textOnly: Boolean,
	limit: Number,
});
ksoft.lyrics.getArtistById(id: Number);
ksoft.lyrics.getAlbumById(id: Number);
ksoft.lyrics.getTrackById(id: Number);

voiceConnection is the discord.js/eris voiceConnection object you get when you connect to a voice channel. This command will search both youtube and the api for a song and if you provide a voice channel connection it will start playing the song and in the promise return the lyrics. This isn't 100% accurate so use at your own risk.

Please note: To play music with this feature you are going to need to have ffmpeg, node-opus/opuscript, and ytdl-core installed

ksoft.lyrics.searchAndPlay(query: String, voiceConnection);

Music api

ksoft.music.recommendations(provider: String, tracks: String | Array<String>)

Webhook feature

This just requires adding a few things when we initiate ksoft.js

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 :)

// 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
});

Using the BanCreator utility

// the ksoft variable I am using is the initialized Ksoft class
const ban = new ksoft.CreateBan()
	.setUserID('1234567892355822') // required
	.setModID('44457845784574578')
	.setUserName('blahblahblah')
	.setUserDiscriminator('1234')
	.setReason('testing123') // required
	.setProof('proof') // required
	.isAppealable(true);

ksoft.bans.add(ban).then(res => {
	console.log(res); // { success: true}
});

Special thanks to sdf for helping me troubleshoot some stuff :)

Keywords

FAQs

Package last updated on 03 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc