Skip to content

Commit

Permalink
fix: memory leak in event triggers (#1075)
Browse files Browse the repository at this point in the history
  • Loading branch information
niekschoemaker authored Nov 3, 2024
1 parent 82612ac commit 4bf6131
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions packages/discordx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# discordx

## 11.12.2

### Patch Changes

- fix memory leak in event triggers

## 11.12.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/discordx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discordx",
"version": "11.12.1",
"version": "11.12.2",
"private": false,
"description": "Create a discord bot with TypeScript and Decorators!",
"keywords": [
Expand Down
3 changes: 1 addition & 2 deletions packages/discordx/src/logic/metadata/MetadataStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,6 @@ export class MetadataStorage {
* @param options - Even data
*/
trigger(options: ITriggerEventData): (...params: any[]) => any {
const responses: any[] = [];

const eventsToExecute = this._events.filter((on) => {
return (
on.event === options.event &&
Expand All @@ -599,6 +597,7 @@ export class MetadataStorage {
});

return async (...params: any[]) => {
const responses: any[] = [];
await Promise.all(
eventsToExecute.map(async (ev) => {
if (!ev.isBotAllowed(options.client.botId)) {
Expand Down

0 comments on commit 4bf6131

Please sign in to comment.