diff --git a/src/commands/sip.ts b/src/commands/sip.ts index adb0c6f..5754a5c 100644 --- a/src/commands/sip.ts +++ b/src/commands/sip.ts @@ -23,14 +23,20 @@ export default class SIP extends Command { const bridge = await this.client.pbx.ari.Bridge().create(); let receiver: Channel = this.client.pbx.ari.Channel(); - const sender = await this.client.pbx.ari.channels.originate({ - endpoint: `PJSIP/${staff.extension}`, - extension: staff.extension, - callerId: 'LOC PBX AUTO OPERATOR ', - context: 'from-internal', - priority: 1, - app: 'cr-zero', - }); + let sender: Channel = this.client.pbx.ari.Channel(); + + try { + sender = await this.client.pbx.ari.channels.originate({ + endpoint: `PJSIP/${staff.extension}`, + extension: staff.extension, + callerId: 'LOC PBX AUTO OPERATOR ', + context: 'from-internal', + priority: 1, + app: 'cr-zero', + }); + } catch { + return this.error(message.channel, 'Unable to dial your extension.'); + } sender.once('StasisStart', async () => { await Misc.play(this.client.pbx, sender, 'sound:pls-hold-while-try');