Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@the-convocation/venat-module-xiv-market

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@the-convocation/venat-module-xiv-market - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

dist/src/data/listings.d.ts

4

CHANGELOG.md

@@ -6,2 +6,6 @@ # Change Log

## [0.1.5](https://github.com/the-convocation/venat/compare/v0.1.4...v0.1.5) (2022-05-16)
**Note:** Version bump only for package @the-convocation/venat-module-xiv-market
## [0.1.4](https://github.com/the-convocation/venat/compare/v0.1.3...v0.1.4) (2022-05-16)

@@ -8,0 +12,0 @@

50

dist/src/commands/market.command.js

@@ -22,50 +22,16 @@ "use strict";

const xivapi_1 = require("../data/xivapi");
const table_1 = require("table");
const market_dto_1 = require("../dto/market.dto");
const listings_1 = require("../data/listings");
let MarketCommand = class MarketCommand {
logger = new common_2.Logger('MarketCommand');
async handler(dto) {
const itemLookup = await (0, xivapi_1.getItemIdByName)(dto.item);
if (itemLookup.err != null) {
this.logger.error(itemLookup.err.message, itemLookup.err.stack);
return {
content: 'Failed to access XIVAPI; please try again later.',
};
const getMarketInfoPartial = (0, listings_1.getMarketInfoByName)(xivapi_1.getItemIdByName, universalis_1.getMarketInfo, this.logger.error);
const marketInfo = await getMarketInfoPartial(dto.item, dto.server);
if (typeof marketInfo === 'string') {
return { content: marketInfo };
}
if (!itemLookup.success) {
return {
content: 'The item could not be found; please check your spelling and try again.',
};
}
const item = itemLookup.value;
const marketLookup = await (0, universalis_1.getMarketListings)(item.ID, dto.server);
if (marketLookup.err != null) {
this.logger.error(marketLookup.err.message, marketLookup.err.stack);
return {
content: 'The item could not be found; please check your spelling of the server and try again.',
};
}
if (!marketLookup.success) {
return {
content: 'The item could not be found; please check your spelling and try again.',
};
}
const { lastUploadTime, listings, worldName, dcName } = marketLookup.value;
const { lastUploadTime, listings, worldName, dcName, itemName } = marketInfo;
const listingsEmbed = new discord_js_1.MessageEmbed()
.setTitle(`Cheapest listings for ${item.Name} on ${dcName ?? worldName}`)
.setDescription('```' +
(0, table_1.table)([
['HQ', 'Unit Price', 'Quantity', 'Total', 'World'],
...listings
.sort((a, b) => a.pricePerUnit - b.pricePerUnit)
.slice(0, 10)
.map((l) => [
l.hq ? 'Yes' : 'No',
l.pricePerUnit.toLocaleString('en'),
l.quantity.toLocaleString('en'),
l.total.toLocaleString('en'),
worldName ?? l.worldName,
]),
]) +
'```')
.setTitle(`Cheapest listings for ${itemName} on ${dcName ?? worldName}`)
.setDescription('```' + (0, listings_1.buildTextTable)(listings, worldName) + '```')
.setColor('#a58947')

@@ -72,0 +38,0 @@ .setFooter({

@@ -14,2 +14,2 @@ import { LookupResult } from '@the-convocation/venat-core';

}
export declare function getMarketListings(itemId: number, server: string): Promise<LookupResult<UniversalisMarketInfo>>;
export declare function getMarketInfo(itemId: number, server: string): Promise<LookupResult<UniversalisMarketInfo>>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMarketListings = void 0;
exports.getMarketInfo = void 0;
const axios_1 = require("axios");
async function getMarketListings(itemId, server) {
async function getMarketInfo(itemId, server) {
let res;

@@ -15,3 +15,3 @@ try {

}
exports.getMarketListings = getMarketListings;
exports.getMarketInfo = getMarketInfo;
//# sourceMappingURL=universalis.js.map
{
"name": "@the-convocation/venat-module-xiv-market",
"version": "0.1.4",
"version": "0.1.5",
"packageManager": "yarn@3.2.1",

@@ -16,3 +16,3 @@ "main": "dist/src/module.js",

},
"gitHead": "520c73c0ce8eca2129ba98d0e9bf9039c85c2f4b"
"gitHead": "2a5d1f6edc628f28472af65422ffcaa6d46b9bac"
}

@@ -10,6 +10,6 @@ import { TransformPipe } from '@discord-nestjs/common';

import { InteractionReplyOptions, MessageEmbed } from 'discord.js';
import { getMarketListings } from '../data/universalis';
import { getMarketInfo } from '../data/universalis';
import { getItemIdByName } from '../data/xivapi';
import { table } from 'table';
import { MarketDto } from '../dto/market.dto';
import { buildTextTable, getMarketInfoByName } from '../data/listings';

@@ -27,54 +27,17 @@ @Command({

): Promise<InteractionReplyOptions> {
const itemLookup = await getItemIdByName(dto.item);
if (itemLookup.err != null) {
this.logger.error(itemLookup.err.message, itemLookup.err.stack);
return {
content: 'Failed to access XIVAPI; please try again later.',
};
const getMarketInfoPartial = getMarketInfoByName(
getItemIdByName,
getMarketInfo,
this.logger.error,
);
const marketInfo = await getMarketInfoPartial(dto.item, dto.server);
if (typeof marketInfo === 'string') {
return { content: marketInfo };
}
if (!itemLookup.success) {
return {
content:
'The item could not be found; please check your spelling and try again.',
};
}
const item = itemLookup.value;
const marketLookup = await getMarketListings(item.ID, dto.server);
if (marketLookup.err != null) {
this.logger.error(marketLookup.err.message, marketLookup.err.stack);
return {
content:
'The item could not be found; please check your spelling of the server and try again.',
};
}
if (!marketLookup.success) {
return {
content:
'The item could not be found; please check your spelling and try again.',
};
}
const { lastUploadTime, listings, worldName, dcName } = marketLookup.value;
const { lastUploadTime, listings, worldName, dcName, itemName } =
marketInfo;
const listingsEmbed = new MessageEmbed()
.setTitle(`Cheapest listings for ${item.Name} on ${dcName ?? worldName}`)
.setDescription(
'```' +
table([
['HQ', 'Unit Price', 'Quantity', 'Total', 'World'],
...listings
.sort((a, b) => a.pricePerUnit - b.pricePerUnit)
.slice(0, 10)
.map((l) => [
l.hq ? 'Yes' : 'No',
l.pricePerUnit.toLocaleString('en'),
l.quantity.toLocaleString('en'),
l.total.toLocaleString('en'),
worldName ?? l.worldName,
]),
]) +
'```',
)
.setTitle(`Cheapest listings for ${itemName} on ${dcName ?? worldName}`)
.setDescription('```' + buildTextTable(listings, worldName) + '```')
.setColor('#a58947')

@@ -81,0 +44,0 @@ .setFooter({

@@ -18,3 +18,3 @@ import axios, { AxiosResponse } from 'axios';

export async function getMarketListings(
export async function getMarketInfo(
itemId: number,

@@ -21,0 +21,0 @@ server: string,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc