mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 12:17:37 +00:00
chore(misc): normalize logs (#242)
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
import {Link, Store} from '../store/model';
|
||||
import {MessageBuilder, Webhook} from 'discord-webhook-node';
|
||||
import {Config} from '../config';
|
||||
import {Link} from '../store/model';
|
||||
import {Logger} from '../logger';
|
||||
|
||||
const hook = new Webhook(Config.notifications.discord.webHookUrl);
|
||||
const notifyGroup = Config.notifications.discord.notifyGroup;
|
||||
|
||||
export function sendDiscordMessage(cartUrl: string, link: Link) {
|
||||
export function sendDiscordMessage(link: Link, store: Store) {
|
||||
(async () => {
|
||||
try {
|
||||
const embed = new MessageBuilder();
|
||||
embed.setTitle('Stock Notification');
|
||||
embed.addField('URL', cartUrl, true);
|
||||
embed.addField('URL', link.cartUrl ? link.cartUrl : link.url, true);
|
||||
embed.addField('Store', store.name, true);
|
||||
embed.addField('Brand', link.brand, true);
|
||||
embed.addField('Model', link.model, true);
|
||||
|
||||
@@ -22,9 +23,10 @@ export function sendDiscordMessage(cartUrl: string, link: Link) {
|
||||
embed.setColor(0x76B900);
|
||||
embed.setTimestamp();
|
||||
await hook.send(embed);
|
||||
Logger.info(`↗ discord message sent: ${cartUrl}`);
|
||||
|
||||
Logger.info('✔ discord message sent');
|
||||
} catch (error) {
|
||||
Logger.error(error);
|
||||
Logger.error('✖ couldn\'t send discord message', error);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user