#Is the interaction update line the line
1 messages · Page 1 of 1 (latest)
Code is a little bit long, sorry.
@spare oasis and yeah, await interaction.update() triggers the error
You're redefining lockButton twice.
I do, but that is the not issue.
I just did that now.
So why are you passing it as a component if it's now an ActionRow
Unless your repo isn't updated then nvm
I like to ordering it as that.
That's not it works...
I do know to create it like:
const row = new ARB().addCom(new BB())
Okay let me update it to old version then.
But still, that won't fix the issue.
It seems like issue is about
You need to rename the ActionRow where you put lockButton in to be like LockButtonRow so it's a new variable
Well errors can be indirect when it's an issue wlike this one
Try to fix one thing first.
but if I create a thread while bot is online
I get no error
Okay, lemme update
I mean
reassigning works well though
Even though I did not create a new variable for it, it is still ref actionrow which is updated row
You make reading your code difficult when you reuse variables like that when a row is not a button for example.. yes, but now your lockButton is an ActionRow inside the addComponents..
Yes, kinda funny and confusing but true. But it works after all
Rename it the the fake lockButton since you're not exporting it anyway
I am exporting it

The FAKE One
Don't forget to update to new name where you use that row,call it lockRow or something. The error is leading to that. Save and try again. Maybe a new error pops up lol
let lockButton = new ButtonBuilder()
.setCustomId("issue-lock-conversation")
.setLabel("Lock Issue")
.setStyle(ButtonStyle.Secondary)
.setDisabled(false)
.setEmoji(":lock_button:");
fakeLockButton = new ActionRowBuilder().addComponents(lockButton);
// ...
export { fakeLockButton };
Now all good
okie now run
Where's the other code ,can you post?
lemme upload on gist
You can log lockbutton and see what it's returning btw
In thr code you use the interaction.update
It returns undefined
used it like:
case "for-each-cases":
console.log(lockButton);
// ...
You're exporting lockButton but importing fakeLockButton
But as I said, if I create thread after restarting the bot, it returns:
ActionRowBuilder {
data: { type: 1 },
components: [ ButtonBuilder { data: [Object] } ]
}
Ah, that is old code.
I reverted everything, let me update again.
Done with updating.
Maybe it is about fetching issue? I don't think so
It is about lockButton but like which part, idk
it only gets triggered whenever I restart the bot and interact with select menu.
Well it's undefined.. you can't export a variable inside the default I'm pretty sure.. you'd have to define lockButton outside the default export.
So it's undefined coz it's literally just let lockButton;
Well, it is defined out of export but updated inside default, and exported then.
Ya but don't think it works the way you think it does if it is exporting undefined
let me give it a boolean value

make it good
just did
let lockButton = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("issue-lock-conversation")
.setLabel("Lock Issue")
.setStyle(ButtonStyle.Secondary)
.setDisabled(false)
.setEmoji(":lock_button:"),
);
``` :P
Yep, now no errors.
Sweet 
But I got a question.
How do we check thread is unarchived by user with threadUpdate event?
I didn't really get old and new part.
import { Events } from "discord.js";
export default {
name: Events.ThreadUpdate,
once: false,
execute: async (oldThread, newThread) => {
if (oldThread.archived) {
newThread.send("This thread has been archived.");
} else {
newThread.send("This thread has been unarchived.");
}
},
};```
Doesn't seem like working :d
oldThread.archived && !newThread.archived
and newThread.channel.send() ig
Well I'm going off of similarities with other Updates.. you compare old thread with new.. so if oldThread.archived is equal to newThread.archived.. then do whatever
Update will emit event if thread got archived and you can check it against the new thread for what's changed. If it wasn't equal to new thread, you know it changed
so:
import { Events } from "discord.js";
export default {
name: Events.ThreadUpdate,
execute: async (oldThread, newThread) => {
if (oldThread.archived == newThread.archived) {
newThread.send("This thread has been unarchived.");
}
},
};
No lol you're comparing true if it's still archived
Ye
I assume new is have to be
!
or old
Also do I need to enable any partials or intents
No idea actually
I thought threads were GuildMessages but I could be wrong. I do think they have their own intents so double check.
They do not have intents but partials, nvm ThreadMember.
So check first if no change.. if old.archived === new.archived , return... Then check
if !old.archived && new.archived then 'thread archived!
From there you should be able to make the rest lol
