yuko1101 / enka-network-api

A Node.js Enka.Network API wrapper for Genshin Impact.
https://enka-network-api.vercel.app
MIT License
96 stars 7 forks source link

name.get("jp") is not work #8

Closed lisxck closed 1 year ago

lisxck commented 1 year ago
import { EnkaClient } from "enka-network-api";

const enka = new EnkaClient({ defaultLanguage: "jp"});
const characters = enka.getAllCharacters();
console.log(characters.map(x => ({ [x.id]: x.name.get("jp") })));
// is work
const weapons = enka.getAllWeapons();
console.log(weapons.map(x => x.name.get("jp")));
// is not work

Error

        if (!text) throw new AssetsNotFoundError("Text Assets", this.id);
                         ^
AssetsNotFoundError: Text Assets 1135130229 was not found. Try to update cached assets using EnkaClient#cachedAssetsManager#fetchAllContents

I've been trying to figure out why these are not working.

Not sure if they are related. https://github.com/Dimbreath/GenshinData The above repositories are 404'd. https://i.imgur.com/NMl7oSr.png The enka-network document mentions https://github.com/Dimbreath/GenshinData/blob/master/ExcelBinOutput/WeaponExcelConfigData.json also returns 404 as a matter of course.

11101

This is the same as

Enka.getAllWeapons()

The id obtained. node_modules\enka-network-api\cache\langs\jp.json I tried to find the target id (11101), but it did not exist My guess is that when the cache is created, it is trying to get all the weapons information from enka-network in some way. but because it could not be retrieved, the cache of weapon information is not generated. That is why I guessed the above error occurs.

To fix this, you need to get the weapons information for all languages from another service or from another source.

If you can find a service that can retrieve the weapons information in all languages, please update the module. Also, if you have difficulty updating the module, please let me know. I look forward to hearing from you!

yuko1101 commented 1 year ago

Thank you for your issue.

Weapons which getAllWeapons() returns include some weird ones, whose names, icons, or other properties do not exist.

We will make getAllWeapons() return valid weapons.

Temporarily, you can do like this.

weapons.map(x => {
    try {
        return x.name.get("jp");
    } catch (e) {
        return null;
    }
}).filter(x => x !== null)
yuko1101 commented 1 year ago

Don't worry about the excluded weapons. They don't actually exist in the game.

lisxck commented 1 year ago

Thank you. I was able to do what I wanted to do with the above code.

But it is not in jp.json 11101 which is not in jp.json?

yuko1101 commented 1 year ago

11101 is weapon id. A weapon has other ids, which are for its name or description.

lisxck commented 1 year ago

I see! I understand. Thank you!

yuko1101 commented 1 year ago

次からは日本語でも大丈夫ですよ! こちらからしても楽なので

yuko1101 commented 1 year ago

バージョン 1.6.6 からEnkaClient#getAllWeapons()は実在する武器のみ返すようになりました。 先述したコード

weapons.map(x => {
    try {
        return x.name.get("jp");
    } catch (e) {
        return null;
    }
}).filter(x => x !== null)

では、余計な武器が除かれずに残っていたりしたため、 新しいバージョンのEnkaClient#getAllWeapons()を使用することをおすすめします。

yuko1101 commented 1 year ago

不明な点があれば、気軽に質問してください!