Console logging interaction object returns the raw command string

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