diff --git a/src/domain/bot/commands/my-alert-price.command.ts b/src/domain/bot/commands/my-alert-price.command.ts index 544b255..15b4574 100644 --- a/src/domain/bot/commands/my-alert-price.command.ts +++ b/src/domain/bot/commands/my-alert-price.command.ts @@ -1,6 +1,6 @@ import { Command, DiscordCommand } from '@discord-nestjs/core' import { CommandInteraction } from 'discord.js' -import { createResponse, defaultResponse } from 'src/utils/default-response' +import { createResponse } from 'src/utils/default-response' import { Injectable } from '@nestjs/common' import { MurrayServiceRepository } from '../repositories' @@ -14,20 +14,24 @@ export class MyAlertPriceCommand implements DiscordCommand { constructor(private readonly repository: MurrayServiceRepository) {} async handler(interaction: CommandInteraction): Promise { - const userId = interaction.user.id - const { data: alertInfo } = await this.repository.getPriceAlertList({ userId }) + try { + const userId = interaction.user.id + const { data: alertInfo } = await this.repository.getPriceAlertList({ userId }) - alertInfo.fields.alerts.value = Object.keys(alertInfo.fields.alerts.value) - .map( - (k) => - `${alertInfo.fields.alerts.value[k].description} ${alertInfo.fields.alerts.value[k].value}`, - ) - .join('\n') + alertInfo.fields.alerts.value = Object.keys(alertInfo.fields.alerts.value) + .map( + (k) => + `${alertInfo.fields.alerts.value[k].description} ${alertInfo.fields.alerts.value[k].value}`, + ) + .join('\n') - alertInfo.fields.current.value = Object.keys(alertInfo.fields.current.value) - .map((k) => alertInfo.fields.current.value[k].value) - .join('\n') + alertInfo.fields.current.value = Object.keys(alertInfo.fields.current.value) + .map((k) => alertInfo.fields.current.value[k].value) + .join('\n') - return createResponse(alertInfo) + return createResponse(alertInfo) + } catch (error) { + console.log(error) + } } } diff --git a/src/domain/bot/repositories/murrayservice.repository.ts b/src/domain/bot/repositories/murrayservice.repository.ts index 9cc42d6..30e773a 100644 --- a/src/domain/bot/repositories/murrayservice.repository.ts +++ b/src/domain/bot/repositories/murrayservice.repository.ts @@ -153,10 +153,14 @@ export class MurrayServiceRepository { return this.postData(url, bodyData) } - getPriceAlertList({ userId }): Promise { - const webhook = this.createWebhookURL('price', userId) - const url = `${this.baseUrl}/alert/price/?webhook=${encodeURIComponent(webhook)}` - return this.getData(url) + getPriceAlertList({ userId }): any { + try { + const webhook = this.createWebhookURL('price', userId) + const url = `${this.baseUrl}/alert/price/?webhookUrl=${encodeURIComponent(webhook)}` + return this.getData(url) + } catch (error) { + console.log(error) + } } createTransactionAlert({ userId, transaction, confirmations }): Promise { @@ -232,7 +236,7 @@ export class MurrayServiceRepository { map((response: AxiosResponse) => { return response.data }), - catchError(async () => { + catchError(async (err) => { Logger.error(`GET ${url}`) throw this.defaultError }),