src/index.js
/**
	 * Post datas directly to the api (not recommanded to use !)
	 * This method isn't tested and developed to be used in production !
	 */
Post datas directly to the api (not recommanded to use !)
This method isn't tested and developed to be used in production !
Post datas directly to the api ( not recommanded to use ! ) This method isn ' t tested and developed to be used in production !
_postStats()
    {
		let body = {
			"server_count": this._bot._serverCount||null,
			"shard_count": this._bot._shardCount||null
		}
		this.emit("debug", "[Debug] Preparing the posting...");
		fetch(`https://disforge.com/api/botstats/${this._bot._id}`, {
        method: 'POST',
        body:    JSON.stringify(body),
        headers: { 'Content-Type': 'application/json', "Authorization": this._bot._token },
    })
    .then(res => res.json())
	.then(json => {
		if(json.error){
			this.emit("debug", "[\x1b[31mError\x1b[0m] An error has occurred while updating stats on \x1b[36mBladeBotList\x1b[0m !");
				return this.emit("error", `An error occured while tring to post stats: ${json.error}`);
		}
			this.emit("debug", "[\x1b[32mSuccess\x1b[0m] Stats posted to \x1b[36mDisforge!\x1b[0m !");
			this.emit("post");
	})
	.catch((err) => {
			this.emit("debug", "[\x1b[31mError\x1b[0m] An error has occurred while updating stats on \x1b[36mDisforge\x1b[0m !");
			this.emit("error", `An error occured while tring to post stats: ${err}`);
	})
}
_postStats ( ) { let body = { "server_count" : this . _bot . _serverCount || null , "shard_count" : this . _bot . _shardCount || null } this . emit ( "debug" , "[Debug] Preparing the posting..." ) ; fetch ( ` ${ this . _bot . _id } ` , { method : 'POST' , body : JSON . stringify ( body ) , headers : { 'Content-Type' : 'application/json' , "Authorization" : this . _bot . _token } , } ) . then ( res => res . json ( ) ) . then ( json => { if ( json . error ) { this . emit ( "debug" , "[\x1b[31mError\x1b[0m] An error has occurred while updating stats on \x1b[36mBladeBotList\x1b[0m !" ) ; return this . emit ( "error" , ` ${ json . error } ` ) ; } this . emit ( "debug" , "[\x1b[32mSuccess\x1b[0m] Stats posted to \x1b[36mDisforge!\x1b[0m !" ) ; this . emit ( "post" ) ; } ) . catch ( ( err ) => { this . emit ( "debug" , "[\x1b[31mError\x1b[0m] An error has occurred while updating stats on \x1b[36mDisforge\x1b[0m !" ) ; this . emit ( "error" , ` ${ err } ` ) ; } ) }
Post datas directly to the api (not recommanded to use !)
Post datas directly to the api ( not recommanded to use ! )