Skip to content

Commit c6bef59

Browse files
committed
Fix ncc not casted on relogin
1 parent 13908ca commit c6bef59

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/discord/runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default class Runtime extends EventEmitter {
144144
for (const plugin of this.plugins) {
145145
await plugin.onDestroy()
146146
}
147-
this.ncc.disconnect()
147+
this.ncc.destory()
148148
} catch (err) {
149149
Log.e(err)
150150
process.exit(-1)

src/ncc/ncc.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,23 +355,31 @@ export default class Ncc extends NcFetch {
355355
return Promise.resolve()
356356
}
357357
/**
358-
* Remove autoSync
358+
* Clear connected and joined channels (Cache)
359359
*
360-
* This is not removing AUTH! (see `ncc.logout()`)
360+
* This doesn't effect on naver ID
361361
*/
362-
public disconnect() {
362+
public clearChannels() {
363363
if (this.syncTask != null) {
364364
clearTimeout(this.syncTask)
365365
}
366366
this.connectedChannels.forEach((v) => v.disconnect())
367367
this.connectedChannels = []
368368
this.joinedChannels = []
369+
}
370+
/**
371+
* Destory Ncc
372+
*
373+
* Unusable this object if call.
374+
*/
375+
public destory() {
376+
this.clearChannels()
369377
for (const e of Object.values(this.events)) {
370378
if (typeof e["clear"] === "function") {
371379
e.clear()
372380
}
373381
}
374-
// this.credit = new NCredit()
382+
this.credit = new NCredit()
375383
}
376384
/**
377385
* Sync Channels and fetch auto
@@ -512,7 +520,7 @@ export default class Ncc extends NcFetch {
512520
return super.onLogin(username)
513521
}
514522
protected async onLogout():Promise<void> {
515-
this.disconnect()
523+
this.clearChannels()
516524
return super.onLogout()
517525
}
518526
/**

0 commit comments

Comments
 (0)