Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: TypeError: Cannot read properties of undefined (reading '0') #363

Open
koderbilal opened this issue Jul 6, 2023 · 1 comment
Open

Comments

@koderbilal
Copy link

When I type owo h it gives the following error

how can i solve this error?

Unhandled rejection at: Promise  [object Promise] reason:  TypeError: Cannot read properties of undefined (reading '0')

image

@Wifus
Copy link

Wifus commented Jul 6, 2023

By checking out animalUtil.js:116:39, the top of the error stack trace, it is clear that the cpatreon property of the animals object is undefined.

let patreonPercent = animals.cpatreon[0] + animals.patreon[0];

Looking at where animals is initialized at the top of animalUtil.js, it seems like animals gets its data from owo-animals.json.

let animals;
try {
        animals = require('../../../../../tokens/owo-animals.json');
} catch (err) {
        console.error('Could not find owo-animals.json, attempting to use ./secret file...');
        animals = require('../../../../secret/owo-animals.json');
        console.log('Found owo-animals.json file in secret folder!');
}

Based on the other issues you have opened, it seems you've just copy pasted the owo-animals.json file from the secret folder into the tokens folder. This file is incomplete on purpose and does not include the most of the animal tiers, including cpatreon. This is the source of your issue. It can be fixed by either adding the missing tiers to owo-animals.json or removing the logic for those extra tiers (by commenting out lines 89-148 and 180-199 and fixing the if statements).

It's unlikely that somebody will be able to help you out with every issue like this you come across. Not many people have tried hosting their own instance of the bot. There are many things in the codebase excluded from the public repository. Also keep in mind the license this code is subject to. Commercial use of derivatives of the code is strictly prohibited.

All that being said have fun tinkering with the codebase, there are a lot of interesting things in here. If you run into any more issues, then giving a bit more information such as what you are trying to do or what you've done to try to fix the issue would be appreciated. I am not promising to hold your hand like I've done here though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants