Console logging interaction object returns the raw command string
Instead of the full interaction object I get that.
49 Replies
everything in red works, but the log in green return the logs in yellow on the right side
This is what the
toString
method is doing.
You probably want to inspect the object instead.I'm just running getString, not toString, I'll check my other scripts but is there a function that can let me inspect the objecct
I don't understand how this can help me, I just checked all my scripts where I process the slashcommand interaction and none of them have toString...
toString
can be called implicitly.Hm, by implicitly you mean, without me doing it myself (not a native speaker), anyhoo I'm supposed to use utils' inspect to give me the interaction obj?
Yes, that's what it means.
Since you didn't state what you want, I just assumed what seems plausible to me and that's util's inspect function.
I see, well I want to get the interaction object, which I seem to get in all lines above the first greenbox, but then after it's the string
I hope im being clear :)
That is the interaction object.
oh, well how do I access interaction.guild.channels then? i thought if i were to log the interaction object it would return a bunch of lines including a lot of shit
Exactly like that I think.
That returns undefined
I left my PC but i logged it and it returns undefibed
A guild with undefined channels sounds like something went quite wrong.
I can't really help when you can't access your code nor run it.
Well i can show you the code, but i logged that three different times and it returned undefibed :(
Sure? Although if it's just like you described, there isn't much I can do.
Well better try something then nothing, so, as seen in the original screenshot the command calls
SuggestionManager
, which in it's constructor has the following (image). Also, botConfig.channels
does not return undefined so the error doesn't originate from there. When logging this.interaction.channels
in SuggestionManager it logs undefined. The funny thing is that all works well when another slash command is run (/suggestion create), but when this command (/suggestion-manage approve) is run it returns undefinedhope that makes sense
original screenshot for refrecnce
Wouldn't this also throw if
botConfig
is undefined?
Oh, you stated that.
I'l read, sec yeah, no worries
I don't know, this seems quite odd to me.
I'd try to log more, e.g. interaction inside the manger too, if that works interaction.guild and so on.
I don't see anything immediately wrong there.
Interaction inside the manager returnes the same as the interaction outside the manger (so the output in the right in the replied image)
also logged literally everywhere interaction appears, and as stated above, interaction itself appears in the raw command output but nothing apart from there. Could have I called inspect in some subscript?
cus i dont use utils anywhere so
Calling inspect doesn't change the object, it just prints you the object (the same as in console.log, as that's what it does internally)
i see
hm
🤔
this has not happned to me b4
another log
the plot thickens
b4 i would get something like this when logging interaction
Yeah, that's the inspect output.
yeah, and so i was confused when i wasnt getting that anymore when logging interaction, but that's besides the point, it seems
interaction.guild.channels
does exist outside the suggestionmanager, but not when i pass it in?This sounds like something goes wrong passing it.
yeah, but in the code, as you said nothing seems wrong, it's literally these two (first one the script that passes it off, the second image is the receiving class)
What's with interaction inside?
wdym by interaction inside
oh like to log the interaction in the consturctor?
let's see
🤔
waaaaaat the heck is happening here
✨
soooo, what now
lmao
ive been stuck on this for a week
me rn
How are you even getting this error, seeing that you have a try / catch there?
good question lmao
let me see
Can you get the stacktrace for that too?
interesting, it seems both my log script and the suggestion manager cant read it
Time to dig deeper
I fixed the error, it wasn't even in the SuggestionManager class! You see, the sendDiscordLog function needs a client passed in to work (to access
client.channels
) and I forgot to pass in the client to the sendDiscordLog function
I'm so sorry of stacktraces :P
yup, thank you so much!