Skip to content

Commit

Permalink
Remove ramTotal for now (pre8)
Browse files Browse the repository at this point in the history
  • Loading branch information
DEVTomatoCake committed Dec 19, 2023
1 parent 2dfbaa7 commit 4d6be26
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
15 changes: 6 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@ class DisStat extends EventEmitter {
data.guilds = this.bot.guilds.cache.size
data.shards = this.bot.shard ? this.bot.shard.count : 0
data.users = this.bot.guilds.cache.filter(guild => guild.available).reduce((acc, cur) => acc + cur.memberCount, 0)
data.apiPing = this.bot.ws.ping > 0 ? this.bot.ws.ping : void 0
data.apiPing = this.bot.ws && this.bot.ws.ping > 0 ? this.bot.ws.ping : null
}

const memory = process.memoryUsage()
data.ramUsage = memory.heapUsed
data.ramTotal = memory.heapTotal
data.ramUsage = process.memoryUsage.rss()

const endUsage = process.cpuUsage()
const elapTime = endUsage.user - this.startUsage.user + endUsage.system - this.startUsage.system
Expand Down Expand Up @@ -89,7 +86,7 @@ class DisStat extends EventEmitter {
async postData(data = {}) {
if (this.autoposting && !this.noManualWarningSent) {
console.warn("[DisStat " + new Date().toLocaleTimeString() +
"] You are using autoposting, but you are still manually posting data. This is not recommended, as it can cause duplication and data loss due to overwriting.")
"] You are using autoposting, but still manually posting data. This is not recommended, as it can cause duplication and data loss due to overwriting.")
this.noManualWarningSent = true
}

Expand All @@ -116,12 +113,12 @@ class DisStat extends EventEmitter {
}
}

async postCommand(command = "", userId = void 0, guildId = void 0) {
postCommand(command = "", userId = void 0, guildId = void 0) {
if (!command || command.trim() == "") return new TypeError("No command name provided to postCommand().")
this.postCustom("command", command, userId, guildId)
}

async postCustom(type = "", value1 = void 0, value2 = void 0, value3 = void 0) {
postCustom(type = "", value1 = void 0, value2 = void 0, value3 = void 0) {
if (!type || type.trim() == "") return new TypeError("No custom graph type provided to postCustom().")

const body = {
Expand All @@ -131,7 +128,7 @@ class DisStat extends EventEmitter {
value3
}
if (this.autoposting) this.unpostedCustom.push(body)
else await fetch(baseURL + "bot/" + this.botId + "/custom", {
else fetch(baseURL + "bot/" + this.botId + "/custom", {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
12 changes: 4 additions & 8 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,20 @@ test("postData with valid api key", async () => {

test("postCommand empty", async () => {
const disstat = new DisStat("DS-jest", "jest")
const data = await disstat.postCommand()
expect(data).toBeInstanceOf(TypeError)
expect(disstat.postCommand()).toBeInstanceOf(TypeError)
})

test("postCommand with content", async () => {
const disstat = new DisStat("DS-jest", "jest")
const data = await disstat.postCommand("jest")
expect(data).toBeUndefined()
expect(disstat.postCommand("jest")).toBeUndefined()
})

test("postCustom empty", async () => {
const disstat = new DisStat("DS-jest", "jest")
const data = await disstat.postCustom()
expect(data).toBeInstanceOf(TypeError)
expect(disstat.postCustom()).toBeInstanceOf(TypeError)
})

test("postCustom with all four args", async () => {
const disstat = new DisStat("DS-jest", "jest")
const data = await disstat.postCustom("jest", "jest", "jest", "jest")
expect(data).toBeUndefined()
expect(disstat.postCustom("jest", "jest", "jest", "jest")).toBeUndefined()
})
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "disstat",
"version": "1.0.0-pre7",
"version": "1.0.0-pre8",
"description": "Post data from a discord.js client automatically, or manually to DisStat for Discord bot statistic tracking.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 4d6be26

Please sign in to comment.