/** * POST YOUR BOTS STATS * @param apiKey Your bots infinity api token found in your bot settings * @param botID Your bots discord id. Can be found on the discord dev portal * @requires servers The user count of your bot/client. * @requires shards * @requires users */ public async postBotStats(servers?: Bot, shards?: Bot, users?: Bot) { if (!this.apiKey) return log('Please provide a valid bot api token', { header: '@INFINITYBOTS/NODE-SDK: REFERENCE_ERROR', type: 'error' }); else if (!this.botID) return log('Please provide a valid bot id', { header: '@INFINITYBOTS/NODE-SDK: REFERENCE_ERROR', type: 'error' }); else if (!servers) return log('Please provide a valid server count, should be a integer of 1 or greater!', { header: '@INFINITYBOTS/NODE-SDK: REFERENCE_ERROR', type: 'error' }); else if (typeof servers !== 'number') return log('Please provide a valid server count, should be a integer of 1 or greater!', { header: '@INFINITYBOTS/NODE-SDK: REFERENCE_ERROR', type: 'error' }); else if (!shards) return log('Please provide a valid shard count, should be a integer of 1 or greater!', { header: '@INFINITYBOTS/NODE-SDK: REFERENCE_ERROR', type: 'error' }); else if (typeof shards !== 'number') return log('Please provide a valid shard count, should be a integer of 1 or greater!', { header: '@INFINITYBOTS/NODE-SDK: REFERENCE_ERROR', type: 'error' }); else if (!users) return log('Please provide a valid user count, should be a integer of 1 or greater!', { header: '@INFINITYBOTS/NODE-SDK: REFERENCE_ERROR', type: 'error' }); else if (typeof users !== 'number') return log('Please provide a valid user count, should be a integer of 1 or greater!', { header: '@INFINITYBOTS/NODE-SDK: REFERENCE_ERROR', type: 'error' }); else { await fetch(`${this.url}/bots/stats`, { method: 'POST', headers: { 'Authorization': `${this.apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ servers: servers, shards: shards, users: users }) }) .then(() => log('Hooray, your bot stats were successfully posted.', { header: '@INFINITYBOTS/NODE-SDK: STATS_POST_SUCCESS', type: 'success' })) .catch((e) => { return log(`Whoops, your bot stats post failed: ${e.stack}`, { header: '@INFINITYBOTS/NODE-SDK: STATS_POST_FAILURE', type: 'error' }) }) } }