Skip to content

Commit

Permalink
feat(bin): notice user when host is unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
JiPaix committed Aug 7, 2021
1 parent b0ad141 commit bd452d5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/bin/xdccjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,19 @@ export class XdccJSbin extends Profiles {
const wait = opts[1].wait || 0
if (!bot) throw new Error('Control flow error: downloadwith()')
const xdccJS = new XDCC(opts[0])
xdccJS.on('ready', () => {
.on('ready', () => {
this.waitMessage(wait, xdccJS, bot, download)
})
xdccJS.on('can-quit', () => {
.on('can-quit', () => {
xdccJS.quit()
})
.on('error', e => {
if((e as Error).message.includes('UNREACHABLE')) {
// trick to avoid "hard" throws
const error = new BinError(`%danger% Connection to ${opts[0].host}:${opts[0].port ? opts[0].port : 6667} failed`)
console.error(error.message)
}
})
}
}
}

0 comments on commit bd452d5

Please sign in to comment.