Releases: BLU-Shack/simple.space
Release list
simple.space v3.2.0 Updates
simple.space - v3.2.0
What's Changed?
MultiFetchOptionshas been updated to support new Query Parameters added forv1/bots
As of 2/2/19, there has been 2 new query parameters added to the botlist.space API:
reverseSort and sortBy.
sortBywill take a raw bot object's property and sort it through that property.reverseSortwill requiresortByhave value. When set to true, it will reverse the sorted return value.
EXAMPLE: sortBy is now given a value called server_count. The returned value of the API will output an array of bots that are sorted by bots with greatest server count to least server count. Output Example: [5, 2, 1, null, null] (Some bots do not POST their own number of servers they are in)
EXAMPLE 2: sortBy still has server_count as its value, but the user has decided to make reverseSort true. This resulted in the sorting of bots be made with bots that have server counts from least to greatest. Output Example: [null, null, 1, 2, 5]
- Options are not longer exported from the module.
This was before when it was intended for the src/structures/index.js file to export options. Now that the file has been removed and direct requires from each file is now required, they are no longer exported; An unintended side effect that was planned to be removed later.
createdTimestampfor bothBotandStatsclasses
The createdAt property before was the Timestamp; Now it is the Date, with createdTimestamp for the timestamp.
-
The Tests have been updated.
- No longer has
userTokenin the Options - Timeouts are longer
- Included Statistics Test.
- No longer has
-
Legend has it the
index.d.tsfile has been updated to goodiness.
What's Implemented/New?
Option Checking
Now all options will be checked of their properties each time a fetch or a post is performed.
Minor Notes
Optimizations
.get()and.authGet()- Theheadersparam is now an object.userTokenis no longer mapped out from ClientOptions to all other options.- If you did not know,
ClientOptions.botToken,.version, and.cacheall become the defaults ofFetchOptions,MultiFetchOptions, andPostOptions.userTokenseemingly stayed there, so it was removed from its use.
- If you did not know,
- JSDoc
userTokenin MultiFetchOptions no longer appears. .postCount()in Typings now uses(id?: string, options?: PostOptions)as priority override.index.jsfiles of bothstructures/andutil/directories have been removed. Direct requires are now performed in the files.- If
userTokenappears inClientOptions,FetchOptions, orMultiFetchOptions, a Deprecation Warning will be emitted, as they are now obsolete in the API and have no use. - The
Errors/FetchErrorand/Ratelimitboth have been unified into a singleerrors.jsfile in thestructures/folder. isObject.jsis no longer in its own file.
Bug Fixes
fetchUpvotes()- Used.get()instead ofauthGet()- Rendered unusable.
Deprecations
fetchAllBots()- Pending Removal in Next Minor/Major Update
v3.0.0 - v4 Goodies
v2.3.1 Update Notes (Patch)
IN NO PARTICULAR ORDER!!!
Time of release: 2018-11-25
Generally fixes some bugs and added a little bit of extra things.
Stats.combined- Fixed outputtingNaN- The
postevent now includes a second parameter including the count posted.
v2.3.0 - Cache n' Events
IN NO PARTICULAR ORDER!!!
Time of release: 2018-11-25
Main Part of the Update
index.d.tsis now a thing. That's cool I guess.ClientOptionsnow hascacheandcacheUpdateTimerparameters!- What does this mean? You will no longer have to asynchronously fetch a bot/emoji/guild.
- To use, set
cache: true, and if desired,cacheUpdateTimer: [Number], Number being the # of milliseconds to wait for each automatic cache update; Defaults to180000(3 minutes; Set it as0to disable) - Because
this.bots,this.emojis, andthis.guildswon't be ready right on initialization, you'll be given new events. - Anytime you fetch something, it is automatically cached.
- Every New Event:
ready=> When the first cache is updated, or it was never updated. Runs regardless of which.cacheUpdateAll=> When all of the cache is updated.cacheUpdateBots=> Emitted whenthis.botsis updated.cacheUpdateEmojis=> Emitted whenthis.emojisis updated.cacheUpdateGuilds=> Emitted withthis.guildsis updated.post=> Emitted when a post action is done.
- If
cacheis true, anytime you fetch a bot, emoji, or guild, it updates itself to their corrosponding Stores. this.bots,this.emojis, andthis.guildsall use a newStoreclass, which is generally aMapbut with more methods.
Utilizing Cache and Events
// Returns the bot's username.
Client.on('ready', (bots) => {
console.log(bots.get('BotID').username);
});// You do not require the data value, you can call the Client itself.
// Returns each guild name.
Client.on('ready', () => {
console.log(Client.guilds.map(guild => guild.name).join('\n'));
});// The total amount of animated listed emojis, which logs each time the emoji cache is updated.
Client.on('cacheUpdateEmojis', (bots, emojis, guilds) => {
console.log(Client.emojis.filter(e => e.animated).size);
});// Get the data received when posting.
// Should return "200 Successfully updated server count" into the console.
Client.on('post', info => {
console.log(`${info.code} ${info.message}`);
});Recap, Refactors, and Changes
Assumptions:
const Space = require('simple.space')
Important Notice: You are now to initiate the Client using new Space.Client()
New Structures
- Store - Basically a Map, but with extended methods for usage.
- UpvoteUser - Now, when fetching upvotes a bot has, the responses now have their own class instead of the partially-accepted PartialUser.
Main Features Implemented
Cache
Now synchronously fetch a bot/emoji/guild!
ClientOptionsaccepts new values for use.cache- Whether or not to cache all bots, guilds, and/or emojis.cacheUpdateTimer- The number of milliseconds in which to update the cache. Set to 0 to disable.
- If cache is set to true,
this.bots,.emojis, and.guilds, which are Stores, will be mapped by each respective bot/emoji/guild ID and its contents, and will be updated in an interval/whenever a Fetch is performed.
Events
Partially useful?
ready- Emitted when the Client is initiated. If cache is set to true, this will be emitted when cache is complete. If false, this emits when initiated.cacheUpdate- Emitted when ALL of the cache is updated. Works similarly toready, but emits in a set interval. Never emits ifcacheUpdateTimeris set to 0, nor ifClientOptions.cacheis configured tofalse, its default value.cacheUpdateBots- Emitted when any part ofthis.botsis updated.cacheUpdateEmojis- Emitted when any part ofthis.emojisis updated.cacheUpdateGuilds- Emitted when any part ofthis.guildsis updated.postEmitted whenever posting guild count is performed.
Type Fixes/Changes
- New
index.d.tsfile - Type Fixes where fetching all Bots/Guilds/Emojis claimed to return an array of Bot/Guild/Emoji with no Promise when indeed it would return a Promise.
No promises, though.
Function Reworks
.fetchUpvotes()now returns an array of UpvoteUsers.hasUpvoted()now accepts an array of strings. If an array of strings is passed in the first parameter, it returns a Store mapped by the user ID and whether or not they had upvoted..hasUpvoted()now acceptsUpvoteFetchOptionsas its second parameter, though some values will be ignored, specificallynormal,specified,stringify(It was originally intended forstringifyto be included as a usable parameter, but contributed to code clutter).postCount()- Now accepts number as first parameter (Previously discouraged but I felt it was too annoying :p)
Bug Fixes
- Unsure what to call a bug though...
Deprecations
Client.setCount()- Function rename; Now.postCount()
Misc
- All
FetchOptionsshould now come into use when fetching anything, besides Stats. Space.Classesrework; All classes (and client) now attached toindex.js- Examples:
new Space.Client(),new Space.ClientOptions({}),new Space.Store()
- Examples:
Minor Note: In the future, fetching Bots, Emojis, or Guilds using the fetchAll methods, may return a Store. normal may then have a different use in that case, and FetchOptions will have a new definition regarding getting the plain objects fetched. Not intended, but something to think about.
v2.2.3 New Stuff
v2.2.3
This update includes a lot of changes.
These are the New Changes...in no particular order...
- Now uses
Node-Fetchinstead ofsnekfetch
- New (and changed) Classes!
PartialUser=> This is used whenever a user is fetched from a bot/guild/bot's upvotes, since some values are missing due to circular references.FetchError=> A not-very-polished error class that is thrown when an error on the site is occurred.Emoji=> Used when fetching a Guild's emojis (also new)PostOptions=> Options when posting guild count.UpvoteFetchOptions=> Options when fetching for a bot's upvotes.FetchOptions=> Now includes.stringifyparameter- If set to TRUE, returns the stringifed form of Bots/Users (mention), Guilds (name), or Emoji (text-that-transforms-into-a-readable-emoji-for-Discord)
NonGuildBaseis now dead. Not big soup rice, as Heavy would say.
- Functions Changed!
fetchAll()has now been split.- Use
fetchAllBots()orfetchAllEmojis()
- Use
edit()now only returns the new ClientOptions that have been set.fetchEmoji()=> Fetch an emoji on the site!fetchGuildEmojis()=> Fetches all emojis that a guild has.setGuilds()=> Functionality Now Changed.- Now wants
setGuilds({ guildSize: number | array of numbers }) - You can now use:
setGuilds({ token: 'API_TOKEN', botID: 'BOT_ID' })so you don't have to supply them on initialization(?)
- Now wants
fetchUpvotes()no longer allows to get another bot's because I only figured out now in the past 2 days that you can't fetch other bots' upvotes LOLfetchUpvotes()usage changed. Now usefetchUpvotes({ ids: true })if you want only user IDs.
Usability?
- I do not know if the setGuilds or the fetchUpvotes work, since my bot for testing purposes got died...
Woah v2.2.2
- Created a
Statsclass - Changed the
logproperty; If true, logs anything you fetch, like fetching a bot or user, it console logs what it resolves.
Code Refactors
- Updated and refactored a heck ton of code.
- Fixed the README.md lol
Fixed some things
- Added JSDoc stuff
- Created a NonGuildBase for both Bot and User.
- Fixed the setGuilds function.
v2.1.0
Too many reworks! God!
- Initialization has been updated. You now are to input an object in the options parameter.
edit()function has changed. You are now to input an object in the options parameter.- Custom-made Bot/Server/User Classes have been created. Super special stuff.
- Most "specified" parameters have changed. They are now FetchOptions, and are still optional. { normal: false, specified: false } (normal: TRUE if you want it to be not the custom made class, and specified, if you want a specific value)
Minor Notes
setCount()is now removed..fetchAll('servers')is now deprecated; Use'guilds'instead.
v2.0.0 - The Guilds Update
- Servers on the site have been introduced, and this update grants support just for Servers! Use
fetchGuild(guildID, ?specified)to fetch a guild (server in the API) on the site. - Introduced the
fetchAll(kind, ?specified)function => Fetches all bots/guilds (supply "servers") that has been submitted onto the site. - You can now edit values in the instance with
.edit(key, value). Returns itself so you can chain edits. - IDs no longer check if the ID length is 18 because that's kind of stupid tbh.
Minor Notes
- Fixed a couple descriptions as they were slightly confusing.
- The reason these guilds are named a "Guild" is what Discord calls "guilds" in the API.
setCount(serverSize)is now deprecated. UsesetGuilds(guildSize)instead. BONUS: Go here to say what you think whether I should revert/change/leave it.