#for example im not quite understanding

1 messages · Page 1 of 1 (latest)

opal ibex
#

I assume you are exporting a command object

true coyote
#

i think so

#

like im exporting a command.js

opal ibex
#

Show me your command files

true coyote
#

with 1 "module.exports" it works fine, but as soon as i add another one it gives me error

opal ibex
#

The ones you are loading dynamically

true coyote
opal ibex
#

Yeah

true coyote
#

see it has 2 "module.exports"

#

but if i remove the second "module.exports" it works fine

opal ibex
#

Right. Instead of calling it twice you should only call it once and pass both of your classes in there

#

So, change the module.export for class insertNameHere on both of those

true coyote
#

No errors

#

Lets see if works

opal ibex
#

You need to export it though

true coyote
#

I can't run the command

#

It says this

true coyote
opal ibex
#

Looks like you're missing a bracket somewhere

opal ibex
# true coyote

This last line looks like it's missing a closing bracket

true coyote
#

If i Add a bracket it gives error

#

The brackets are ok

opal ibex
# true coyote How?

Change both module.export for class insertNameHere, and then at the end of the file use export { name1, name2 }

true coyote
#

Like this? But then it gives me a error

opal ibex
#

Remove the =

true coyote
#

It gives even more errors

opal ibex
#

Hmm, nevermind, you'd have to modify more things since you're declaring properties in there

true coyote
#

this is how i separated the modules

opal ibex
#

So, looking at the set of pictures you sent before, it looks like there is no data property for the second export

#

If you try to load that then command.data will always be undefined

#

Because data does not exist in the second module

true coyote
opal ibex
#

Revert back to using module.export

#

So, again, the second module.export does NOT have a data property

true coyote
#

And how to a add a data property to it?

opal ibex
#

When you call require it loads the second module and it tries to index a property inside a non existent property

true coyote
#

When I use the second module it shows this

opal ibex
#

Yeah

true coyote
opal ibex
#

Change your structure

#

You can either put the name property of the second module inside a data object

#

Or you change that commands.set to use command.name instead of command.data.name

true coyote
true coyote
#

here's the code of the handleCommands

opal ibex
#

Yeah, because data still doesn't exist

#

Get rid of data. in all of those

#

You really need to revisit your command structure

true coyote
true coyote
#

Because that will let me do other stuff

opal ibex
true coyote
#

i have this right

#

and i wanna be able to change this embed and make the "Status" "Accepted"

#

and for that I need to access that embed

#

and I can't if the embed creation is on "interactionCreate.js" and if my commands to change that are on "suggestion.js"

opal ibex
#

You can export a function from interactionCreate.js and then use it in suggestion.js

#

Instead of exporting suggestion.js

#

Ideally, you'd save the embed object in interactionCreate.js and then call a function to retrieve it

true coyote
#

Like this?

opal ibex
#

Yeah

true coyote
opal ibex
#

Check the path

true coyote
#

the path was wrong and now is right

#

but it gives me this error..

opal ibex
#

Are you exporting it in interactionCreate?

true coyote
#

I don't think so, how do I do that

#

I want to export this basically

opal ibex
#

Can't quite export that. What you should do is export a function to retrieve that

true coyote
#

How?

opal ibex
#

You could, for example, save the embed in a static dictionary

#

End then export a function that retrieves the embed from the dictionary and returns it

true coyote
#

Hmm I don't know how to do that :((

opal ibex
#

Something like this

#

Though keep in mind this is Typescript

#

So don't copy it directly

true coyote
#

Isn't there any simpler way?

true coyote
#

Im trying like with this command edit the embed that its on "interactionCreate.js"

#

basically

#

is there a easy way to do it :/

opal ibex
#

Well, if you have the message ID you don't need exports

#

If you're passing it into your command you could just get the message itself

true coyote
#

im trying to something like this

true coyote
true coyote
#

How exactly xd?

opal ibex
#

Google is your friend

true coyote
#

How does this help? im not quite understanding

#

sorry if im being kinda annoying

#

is just that im kinda new to djs :/

opal ibex
#

In your command to accept the suggestion or whatever you run code to get the message with the specified ID

true coyote
#

Like this?

opal ibex
#

Yeah

#

Though in there you might get an error, unless you made channel a variable

#

interaction.channel.messages.fetch() would be the whole thing

true coyote
opal ibex
#

In your command

#

Where you want to edit the message

true coyote
#

Okok, so how exactly do I edit an embed that isn't on this json file?

#

That's the part that confuses me :/

opal ibex
#

You don't need a json file to edit an embed

true coyote
#

So like what do I need to add to edit the embed with the messageId

true coyote
opal ibex
#

You get the embed from the existing message and then edit it and pass it back

true coyote
#

That seems easy to say but not do :/

#

Is there any guide or something on google to that

opal ibex
#

Haven't looked, but there should be

true coyote
#

Tried this didn't work

opal ibex
#
const message = interaction.channel.messages.fetch(messageId)
const tempEmbed = new EmbedBuilder(message .embeds[0])

// Cycle through the embed's fields here and edit the one you want

message .edit({ embeds: [tempEmbed] });
true coyote
opal ibex
#

Something like this

true coyote
#

Like this?

opal ibex
#

No

#

tempEmbed.setDescription

#

And change MessageEmbed for EmbedBuilder

#

MessageEmbed is for v13, v14 uses EmbedBuilder

true coyote
true coyote
opal ibex
#

V14 might have changed something else with messages

#

Check the documentation to see how to retrieve embeds from a message

true coyote
#

In here?

opal ibex
#

Yeah

#

There's also tutorials on how to do things like these on youtube

true coyote
#

someone might know

#

because im almost there

#

i just need to find out how to edit it :((

opal ibex
#

Oh, one more thing

#

That command only works if you send it in the same channel where the embed is

true coyote
#

By doing that it gave me this error

opal ibex
#

Add a check to see if message.embeds has any items in it

#

The console error is pretty clear

opal ibex
#

Google

#

message.embeds is an array

#

Don't want to sound like an ass, but Google is your best friend

true coyote
#

Like this?

opal ibex
#

Not quite

#

With that you will iterate over all the embeds in a message

#

You need to do fetch().then() by the way

true coyote
opal ibex
#

Yeah, he said the same

#

.fetch() returns a promise

true coyote
#

like this?

opal ibex
#

You can either use .then() and put all the subsequent code in there, or you use await

#

Yeah

true coyote
#

This is the code I have

opal ibex
#

No

true coyote
#

Then how?

#

WORKEDDDDDDDDDDDDDDDDDD

#

FINALLLYYYY

opal ibex
#
.then((message) => {
// Do stuff in here
})
true coyote
#

oh okay

#

but i wanted to edit the description not remove all the embed and just let it with description

opal ibex
#

How does your code look now

true coyote
#

like this

opal ibex
#

Ok, that works too

opal ibex
#

Remove the new from EmbedBuilder

true coyote
#

Now worked adding EmbedBuilder.from(...

opal ibex
#

const tempEmbed = EmbedBuilder.from()

#

Yeah

true coyote
#

how do i edit a field?

opal ibex
#

You need to get all the fields of the embed

#

Actually, hang on

#

It might have fetch as well

true coyote
#

Doing this doesn't work :/

opal ibex
#

I mean, you're just adding new embeds with that

#

And variables in there are undefined

#

So no, it's not gonna work

#

Run this

#
for (const field of message.embeds[0].fields) {
            console.log(field)
        }
true coyote
#

where?

#

in what part on my code

opal ibex
#

Put it under const tempEmbed

#

And remove the addFields call

true coyote
#

i assume it worked?

opal ibex
#

Yes

true coyote
#

But I just wanna change the one that has a name of 'Status'

opal ibex
#

I know

#

Give me a second

true coyote
#

This almost worked

#

But setvalue isn't working

opal ibex
#

You have to modify it in tempEmbed

#
for (const field of tempEmbed.data.fields) {
            if (field.name != "Status") continue;
            field.value = "Accepted"
            break;
        }
true coyote
#

finalllyyyy

#

but one thing

#

how can i make it to use the command on a separated channel?

opal ibex
#

You'll need to add a channel ID option to your command

#

Or you can iterate through all of your discord channels

#

But that is not exactly efficient

true coyote
#

one opinion

#

what u think it would cooler

#

this or the / command

opal ibex
#

Buttons

true coyote
#

what if i let both of them?

#

buttons and / commands

#

isn't that more "efficient"?

opal ibex
#

Idk, your choice my man

#

Buttons are much more efficient

true coyote
#

I know but having / is also great

#

So both would be the best case scenario in my opinion

true coyote
#

@opal ibex how do i make a system that gets a message from someone only after clicking a button?
i have tried everything with interactionCreate and messageCreate..

true coyote
#

@opal ibex im trying to do what we did yesterday with embeds, but this time with editing buttons

#

what could possibly be wrong in here :/