Weeb Wrapper is a simple API wrapper for the weeb api, an api that helps discord bot's and their developers. This is a closed API, details on weeb.sh and docs.weeb.sh.
If you want to host your own instance of this api, have a look at weeb-services.
With npm: npm install --save @tmuniversal/weeb-wrapper
With yarn: yarn add @tmuniversal/weeb-wrapper
constWeebWrapper=require('@tmuniversal/weeb-wrapper')constwrapper=newWeebWrapper('<Your API key>')// Create a new instance of the API wrapper// If you need to change the base url of the api:constwrapper=newWeebWrapper('<You API key>','https://api.example.com')wrapper.accounts// accessing the accounts api.validate('<Your API key>')// Doing something with it, in this case validating your API key.then(...)// Returns a promise, so you can work with the results.catch(e=>{// Catch promise rejectionsconsole.error(e)})Requires API key.
Saving settings of a discord bot: in this example we are creating a setting of the type guilds named <some id>. It contains the guilds command prefix.
constWeebWrapper=require('@tmuniversal/weeb-wrapper')constwrapper=newWeebWrapper('<Your API key>','https://api.example.com')// Create a new instance of the API wrapperwrapper.settings.createSetting('guilds','<some id>',{prefix: '?'})It's easy to retrieve the setting:
// With async/awaitconstresult=awaitwrapper.settings.getSetting('guilds','<some id>')console.log(result)// Will return the settings: { prefix: '?' }// With promiseswrapper.settings.getSetting('guilds','<some id>').then(result=>{console.log(result)// Will return the settings: { prefix: '?' }})Note: Subsettings are not connected to their parent settings, they perform as a full settings themselves and will work even if the parent route doesn't exist. Deleting a parent will not delete it's subsettings.
Requires API key for post requests. Get endpoints are public.
The BotStat API serves as a means of saving certain numbers like the amount of servers a bot is in to be made publicly available.
// Updating the amount of guilds, channels, users your bot is in:wrapper.statistics.updateBot('<id here>',123,456,789)wrapper.statistics.updateBot('<id here>',[123,456,789])// or as an arraywrapper.statistics.updateBot('<id here>',{guilds: 123,channels: 456,users: 789})// or as an object// retrieving this data:constbot=awaitwrapper.statistics.getBot('<id here>')console.log(bot)/* example output:{ userId: '12345678901234545', // a discord user id guilds: 42, channels: 69, users: 420, lastUpdated: '2020-07-26T14:37:37.017Z', owner: { id: '123456781543243534', username: 'A name', discriminator: '0001' }}*/This is a very random collection of some features I wanted to realize. An API key is NOT required for these features.
constWeebWrapper=require('@tmuniversal/weeb-wrapper')constwrapper=newWeebWrapper("<Your API key (or not since you don't need one for this)>")constneko=awaitwrapper.general.getNeko()// Will retrieve a catgirl image url.console.log(neko)// (example) => https://nekos.moe/image/rygkhkosf- Implementation of the Bruh API(Maybe).
Please refer to the LICENSE file.