ReferenceError: [ENV] BOT_OWNER_IDS - The key must be an array, but is empty or undefined.
I am using
@skyra/env-utilities
and when I start up my bot, I get the error reported in the title of this post. I cannot figure out what I am missing. I have a .env.local
file in my src
directory.
It is erroring when it gets to export const OWNERS = envParseArray('BOT_OWNER_IDS');
in my src/lib/constants.ts
file.
This is the contents of my src/lib/setup.ts
file:
contents of my .env.local
:
I am not sure what I am missing or how to resolveSolution:Jump to solution
Okay so the problem is that files are required in order of lines in the file so index calls setup first, but that also first calls constants because it's above the line that calls
setup
. Calling constants means that envParseArray
gets executed, but because setup hasn't ran yet you get the error that you do.
So the fix is to split your constants file in stuff that is needed for env, and stuff that isn't needed. That way you can safely import the former in setup....7 Replies
I think the values are supposed to be separated by a space instead of a newline
So it would be
they are separated by a space
BOT_OWNER_IDS='49242868987990016 253018958536376321'
I even get the same error if I just have 1 id in that listWhat's the content of
constants
file?
And where do you call setup? Also share that file please.constants.ts
index.ts
Solution
Okay so the problem is that files are required in order of lines in the file so index calls setup first, but that also first calls constants because it's above the line that calls
setup
. Calling constants means that envParseArray
gets executed, but because setup hasn't ran yet you get the error that you do.
So the fix is to split your constants file in stuff that is needed for env, and stuff that isn't needed. That way you can safely import the former in setup.Oh my bad, I'm viewing on mobile so it put the second id on the line below
thanks. i kept over looking that