Skip to content

Commit 09a3ee5

Browse files
committed
Fix events & posting not working (pre5)
1 parent fd4c8ba commit 09a3ee5

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

index.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const baseURL = "https://disstat-api.tomatenkuchen.com/v1/"
22
const autopostInterval = 90000
33

4-
const EventEmitter = require("node:events")
4+
const { EventEmitter } = require("node:events")
55
const os = require("node:os")
66

77
class DisStat extends EventEmitter {
@@ -29,7 +29,7 @@ class DisStat extends EventEmitter {
2929

3030
this.autoposting = true
3131
this.bot = botInput
32-
setTimeout(this.autopost, 30000)
32+
setTimeout(() => this.autopost(), 30000)
3333
}
3434

3535
this.emit("ready")
@@ -38,7 +38,9 @@ class DisStat extends EventEmitter {
3838
async autopost() {
3939
this.emit("autopostStart")
4040

41-
const data = this.unpostedCustom
41+
const data = {
42+
custom: this.unpostedCustom
43+
}
4244
if (this.bot) {
4345
data.guildCount = this.bot.guilds.cache.size
4446
data.shardCount = this.bot.shard ? this.bot.shard.count : 0
@@ -65,11 +67,11 @@ class DisStat extends EventEmitter {
6567
this.emit("autopostError", e, data)
6668
console.warn("[DisStat " + new Date().toLocaleTimeString() + "] Failed to post data to DisStat API. Error: " + e.message, result)
6769

68-
setTimeout(this.autopost, autopostInterval / 2)
70+
setTimeout(() => this.autopost(), autopostInterval)
6971
return
7072
}
7173

72-
setTimeout(this.autopost, autopostInterval)
74+
setTimeout(() => this.autopost(), autopostInterval)
7375
this.unpostedCustom = []
7476

7577
this.emit("autopostSuccess", data)

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "disstat",
3-
"version": "1.0.0-pre4",
3+
"version": "1.0.0-pre5",
44
"description": "Post data from a discord.js client automatically, or manually to DisStat for Discord bot statistic tracking.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)