Skip to content

Commit

Permalink
Don't read body on 204 status (pre4)
Browse files Browse the repository at this point in the history
  • Loading branch information
DEVTomatoCake committed Dec 17, 2023
1 parent 2e16d1c commit fd4c8ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@ class DisStat extends EventEmitter {
this.emit("post", false)
return e
})
const json = await response.json()

this.emit("post", response.ok, json)
if (!response.ok) return json
if (response.status == 204) this.emit("post", true)
else {
const json = await response.json()
this.emit("post", response.ok, json)
return json
}
}

async postCommand(command = "", userId = void 0, guildId = void 0) {
Expand Down
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-pre3",
"version": "1.0.0-pre4",
"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 fd4c8ba

Please sign in to comment.