#Is the interaction update line the line

1 messages · Page 1 of 1 (latest)

fresh cave
#

Code is a little bit long, sorry.

#

@spare oasis and yeah, await interaction.update() triggers the error

frank moss
#

You're redefining lockButton twice.

fresh cave
#

I just did that now.

frank moss
#

So why are you passing it as a component if it's now an ActionRow

#

Unless your repo isn't updated then nvm

fresh cave
frank moss
#

That's not it works...

fresh cave
#

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

frank moss
#

You need to rename the ActionRow where you put lockButton in to be like LockButtonRow so it's a new variable

fresh cave
#

When I restart the bot,

#

and interact with the select menu

#

it sends that

frank moss
#

Well errors can be indirect when it's an issue wlike this one

#

Try to fix one thing first.

fresh cave
#

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

frank moss
#

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..

fresh cave
#

Yes, kinda funny and confusing but true. But it works after all

frank moss
#

Rename it the the fake lockButton since you're not exporting it anyway

fresh cave
#

I am exporting it

frank moss
fresh cave
#

export { lockButton };

#

zzzz

frank moss
#

The FAKE One

fresh cave
#

okay gosh

#

xd

frank moss
#

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

fresh cave
#
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

frank moss
#

KekDoge okie now run

fresh cave
#

Nope, still same error :d

#

I told you it got nothing to do with this code xd

frank moss
#

Where's the other code ,can you post?

fresh cave
#

lemme upload on gist

spare oasis
#

You can log lockbutton and see what it's returning btw

#

In thr code you use the interaction.update

fresh cave
fresh cave
#

used it like:

case "for-each-cases":
  console.log(lockButton);
 // ...
spare oasis
fresh cave
#

But as I said, if I create thread after restarting the bot, it returns:

ActionRowBuilder {
  data: { type: 1 },
  components: [ ButtonBuilder { data: [Object] } ]
}
fresh cave
#

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.

frank moss
#

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;

fresh cave
#

Well, it is defined out of export but updated inside default, and exported then.

frank moss
#

Ya but don't think it works the way you think it does if it is exporting undefined

fresh cave
#

let me give it a boolean value

frank moss
fresh cave
#

yep, it seems like because of that

#

I guess, I have to create fakeButton huh :)

frank moss
#

hmmmCoffeeSmile make it good

fresh cave
#

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.

frank moss
#

Sweet dogeHaHa

fresh cave
#

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

frank moss
#

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

fresh cave
#

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.");
        }
    },
};
frank moss
#

No lol you're comparing true if it's still archived

fresh cave
#

!

#

f

frank moss
#

Ye

fresh cave
#

I assume new is have to be

#

!

#

or old

#

Also do I need to enable any partials or intents

frank moss
#

No idea actually

#

I thought threads were GuildMessages but I could be wrong. I do think they have their own intents so double check.

fresh cave
#

can you tell me what is the condition of if btw

#

Bot does not response aksdjakjsda

fresh cave
frank moss
#

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

fresh cave
#

I guess I forgot to "return" something 💀

#

bro

#

wtf

frank moss