Console logging interaction object returns the raw command string

Instead of the full interaction object I get that.
49 Replies
Grif
Grif•2y ago
everything in red works, but the log in green return the logs in yellow on the right side
space
space•2y ago
This is what the toString method is doing. You probably want to inspect the object instead.
Grif
Grif•2y ago
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
space
space•2y ago
Grif
Grif•2y ago
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...
space
space•2y ago
toString can be called implicitly.
Grif
Grif•2y ago
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?
space
space•2y ago
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.
Grif
Grif•2y ago
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 :)
space
space•2y ago
That is the interaction object.
Grif
Grif•2y ago
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
space
space•2y ago
Exactly like that I think.
Grif
Grif•2y ago
That returns undefined I left my PC but i logged it and it returns undefibed
space
space•2y ago
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.
Grif
Grif•2y ago
Well i can show you the code, but i logged that three different times and it returned undefibed :(
space
space•2y ago
Sure? Although if it's just like you described, there isn't much I can do.
Grif
Grif•2y ago
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 undefined
Grif
Grif•2y ago
hope that makes sense
Grif
Grif•2y ago
original screenshot for refrecnce
space
space•2y ago
Wouldn't this also throw if botConfig is undefined? Oh, you stated that. I'l read, sec ULULU
Grif
Grif•2y ago
yeah, no worries BillyHappy
space
space•2y ago
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.
Grif
Grif•2y ago
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
Grif
Grif•2y ago
space
space•2y ago
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)
Grif
Grif•2y ago
i see hm 🤔 this has not happned to me b4 another log
Grif
Grif•2y ago
the plot thickens
Grif
Grif•2y ago
b4 i would get something like this when logging interaction
space
space•2y ago
Yeah, that's the inspect output.
Grif
Grif•2y ago
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?
space
space•2y ago
This sounds like something goes wrong passing it.
Grif
Grif•2y ago
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)
space
space•2y ago
What's with interaction inside?
Grif
Grif•2y ago
wdym by interaction inside oh like to log the interaction in the consturctor? let's see
Grif
Grif•2y ago
Grif
Grif•2y ago
🤔 waaaaaat the heck is happening here
space
space•2y ago
✨
Grif
Grif•2y ago
soooo, what now lmao ive been stuck on this for a week
Grif
Grif•2y ago
me rn
space
space•2y ago
How are you even getting this error, seeing that you have a try / catch there?
Grif
Grif•2y ago
good question lmao let me see
Grif
Grif•2y ago
space
space•2y ago
Can you get the stacktrace for that too?
Grif
Grif•2y ago
interesting, it seems both my log script and the suggestion manager cant read it
space
space•2y ago
Time to dig deeper
Grif
Grif•2y ago
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
space
space•2y ago
msthumbsup of stacktraces :P
Grif
Grif•2y ago
yup, thank you so much!