Skip to content

Commit e974e70

Browse files
authored
Prevent TypeError when removing event lPrevent TypeError when removing event listeners in switchWorld (BunJS issue maybe)isteners in switchWorld (#3544)
Added a check to ensure that only valid function listeners are removed using bot.off
1 parent 08b7317 commit e974e70

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/plugins/blocks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ function inject (bot, { version, storageBuilder, hideErrors }) {
511511
}
512512

513513
for (const [name, listener] of Object.entries(bot._events)) {
514-
if (name.startsWith('blockUpdate:')) {
514+
if (name.startsWith('blockUpdate:') && typeof listener === 'function') {
515515
bot.emit(name, null, null)
516516
bot.off(name, listener)
517517
}

0 commit comments

Comments
 (0)