fetchPrefix not functioning as it should
So i have a default prefix what i am doing is if the author id is x then return a array of prefixes they can use if not just return the default prefix but it's not working as i am only able to use commands with "" meaning no prefix
![No description](https://cdn.answeroverflow.com/1167496397050871818/image.png)
3 Replies
PS: mention prefix works too
Couple of things:
1. You cannot use
this
when inside the closure of an object without using a function expression. If you really want to use this
then you have to use a function expression instead of an arrow function:
2. You should write the fallback return as shown above. this.options.defaultPrefix
is valid and you should ideally try to return it. You then fallback to "?"
manually if for whatever reason something goes wrong. The reason you cannot just write
is because defaultPrefix
can be a readonly string[]
and stringifying that will return item1,item2,item3
https://favna.s-ul.eu/UUKvqf5v.png
3. Flip '?'
and ''
, again as shown above. Then it'll work. The reason is that the first matched prefix will be used and ''
will match everything so when you then write ?command
it'll match and think the command name is ?command
instead of command
oh ok