This repository has been archived by the owner on Aug 28, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Settings delete core event (#477)
* fix: Added core event handler for settingsDelete * docs: Updated IncludedEvents * docs: Correct changelog PR number * fix: Don't check this.client.shard in both core settings event handlers * misc: Add IS support for both core settings events handlers * misc: Much better and faster shard check for both settings events
- Loading branch information
Showing
5 changed files
with
46 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { Event } = require('klasa'); | ||
const gateways = ['users', 'clientStorage']; | ||
|
||
module.exports = class extends Event { | ||
|
||
constructor(...args) { | ||
super(...args, { event: 'settingsDelete' }); | ||
} | ||
|
||
run(settings) { | ||
if (gateways.includes(settings.gateway.name)) { | ||
this.client.shard.broadcastEval(` | ||
if (String(this.shard.id) === '${this.client.shard.id}') return; | ||
const entry = this.gateways.get('${settings.gateway.name}').get('${settings.id}'); | ||
if (entry && entry.existenceStatus) { | ||
this.emit('settingsDelete', settings); | ||
entry.init(entry, entry.schema); | ||
entry.existenceStatus = false; | ||
} | ||
`); | ||
} | ||
} | ||
|
||
init() { | ||
if (!this.client.shard) this.disable(); | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters