Fixed some stability issues when connecting
This commit is contained in:
parent
1e285cc029
commit
3ee51b45ae
@ -196,7 +196,7 @@ export class Bot extends EventEmitter<
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve(this.connect().then(() => this.send(name, ...args)))
|
||||
this.connect().then(() => this.send(name, ...args)).catch(reject).then(resolve)
|
||||
}, 1000)
|
||||
})
|
||||
})
|
||||
@ -251,11 +251,11 @@ export class Bot extends EventEmitter<
|
||||
|
||||
this.#ws = null
|
||||
this.emit("close", { code: event.code, reason: event.reason })
|
||||
this.#processingMessages.forEach((message) => {
|
||||
for (const message of this.#processingMessages.values()) {
|
||||
message.data.reject(
|
||||
new ConnectionClosedError(event.code, event.reason),
|
||||
)
|
||||
})
|
||||
}
|
||||
this.#processingMessages.clear()
|
||||
|
||||
if (this.autoReconnect) {
|
||||
@ -270,7 +270,7 @@ export class Bot extends EventEmitter<
|
||||
return connectedPromise.promise
|
||||
},
|
||||
100,
|
||||
{ leading: true, trailing: false },
|
||||
{ leading: true, trailing: true },
|
||||
)
|
||||
|
||||
sendMessage(channelUID: string, message: string) {
|
||||
@ -280,9 +280,9 @@ export class Bot extends EventEmitter<
|
||||
async uploadFiles(channelUID: string, ...files: File[]) {
|
||||
const imageForm = new FormData()
|
||||
imageForm.append("channel_uid", channelUID)
|
||||
files.forEach((file) => {
|
||||
for (const file of files) {
|
||||
imageForm.append("files[]", file)
|
||||
})
|
||||
}
|
||||
|
||||
return await fetch("https://snek.molodetz.nl/drive.bin", {
|
||||
method: "POST",
|
||||
|
Loading…
Reference in New Issue
Block a user