#for example im not quite understanding
1 messages · Page 1 of 1 (latest)
Show me your command files
with 1 "module.exports" it works fine, but as soon as i add another one it gives me error
The ones you are loading dynamically
the one that i have 2 "module.exports"?
Yeah
see it has 2 "module.exports"
but if i remove the second "module.exports" it works fine
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
You need to export it though
How?
Looks like you're missing a bracket somewhere
This last line looks like it's missing a closing bracket
Change both module.export for class insertNameHere, and then at the end of the file use export { name1, name2 }
Remove the =
It gives even more errors
Hmm, nevermind, you'd have to modify more things since you're declaring properties in there
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
when i load this it gives me this error
Revert back to using module.export
So, again, the second module.export does NOT have a data property
And how to a add a data property to it?
When you call require it loads the second module and it tries to index a property inside a non existent property
When I use the second module it shows this
Yeah
So how exactly would I fix that?
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
now it gives me this error by doing this
here's the code of the handleCommands
Yeah, because data still doesn't exist
Get rid of data. in all of those
You really need to revisit your command structure
Everything was perfectly fine and all commands were working but I wanna figure out how to make 2 modules work
Because that will let me do other stuff
What are you trying to do by exporting two modules from the same command file
Let me show u
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"
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
Yeah
Check the path
Are you exporting it in interactionCreate?
Can't quite export that. What you should do is export a function to retrieve that
How?
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
Hmm I don't know how to do that :((
Something like this
Though keep in mind this is Typescript
So don't copy it directly
Isn't there any simpler way?
I really don't understand this
Im trying like with this command edit the embed that its on "interactionCreate.js"
basically
is there a easy way to do it :/
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
yes but how do i edit with the command then if I don't access to the embed it self
You retrieve it first
How exactly xd?
Google is your friend
How does this help? im not quite understanding
sorry if im being kinda annoying
is just that im kinda new to djs :/
In your command to accept the suggestion or whatever you run code to get the message with the specified ID
Yeah
Though in there you might get an error, unless you made channel a variable
interaction.channel.messages.fetch() would be the whole thing
But this should be in my command or where I create the embed?
Okok, so how exactly do I edit an embed that isn't on this json file?
That's the part that confuses me :/
You don't need a json file to edit an embed
I only want to edit the Pending to Accepted
You get the embed from the existing message and then edit it and pass it back
That seems easy to say but not do :/
Is there any guide or something on google to that
Haven't looked, but there should be
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] });
Something like this
Like this?
No
tempEmbed.setDescription
And change MessageEmbed for EmbedBuilder
MessageEmbed is for v13, v14 uses EmbedBuilder
It gives this error, after fixing this
V14 might have changed something else with messages
Check the documentation to see how to retrieve embeds from a message
In here?
i asked on #djs-help-v14
someone might know
because im almost there
i just need to find out how to edit it :((
Oh, one more thing
That command only works if you send it in the same channel where the embed is
Add a check to see if message.embeds has any items in it
The console error is pretty clear
How?
message.embeds is an array
Don't want to sound like an ass, but Google is your best friend
Not quite
With that you will iterate over all the embeds in a message
You need to do fetch().then() by the way
Look at the "pat" guy on #djs-help-v14
You can either use .then() and put all the subsequent code in there, or you use await
Yeah
This is the code I have
No
.then((message) => {
// Do stuff in here
})
oh okay
but i wanted to edit the description not remove all the embed and just let it with description
How does your code look now
Ok, that works too
It's what I said here
Remove the new from EmbedBuilder
how do i edit a field?
You need to get all the fields of the embed
Actually, hang on
It might have fetch as well
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)
}
Yes
But I just wanna change the one that has a name of 'Status'
You have to modify it in tempEmbed
for (const field of tempEmbed.data.fields) {
if (field.name != "Status") continue;
field.value = "Accepted"
break;
}
finalllyyyy
but one thing
how can i make it to use the command on a separated channel?
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
Buttons
I know but having / is also great
So both would be the best case scenario in my opinion
@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..
You need to use the collector