mirror of
https://github.com/danbulant/discord.js
synced 2026-07-08 04:31:05 +00:00
fix(WebSocketShard): add websocket send error handling (#2981)
* websocket send error handling * fix: emit only when error is present * refactor: use an if instead
This commit is contained in:
parent
b5d5c699e6
commit
5cbdf38028
2 changed files with 4 additions and 1 deletions
|
|
@ -437,7 +437,9 @@ class WebSocketShard extends EventEmitter {
|
||||||
this.debug(`Tried to send packet ${data} but no WebSocket is available!`);
|
this.debug(`Tried to send packet ${data} but no WebSocket is available!`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.ws.send(WebSocket.pack(data));
|
this.ws.send(WebSocket.pack(data), err => {
|
||||||
|
if (err) this.manager.client.emit(Events.ERROR, err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ client.on('ready', () => {
|
||||||
log('READY', client.user.tag, client.user.id);
|
log('READY', client.user.tag, client.user.id);
|
||||||
});
|
});
|
||||||
client.on('rateLimit', log);
|
client.on('rateLimit', log);
|
||||||
|
client.on('error', console.error);
|
||||||
|
|
||||||
const commands = {
|
const commands = {
|
||||||
eval: message => {
|
eval: message => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue