I have been trying to code a bot that copies 1 embed from 1 channel to another channel.
But what I want it to do before posting it to the other channel, I want it to remove 1 element from the embed object.
How I have it currently:
JavaScript
x
19
19
1
client.on("message", (message) => {
2
if (message.channel.id == channel1) {
3
const embed = message.embeds[0];
4
5
var params = {
6
embeds: ,
7
};
8
9
fetch("WEBHOOK URL", {
10
//send channel 2
11
method: "POST",
12
headers: {
13
"Content-type": "application/json",
14
},
15
body: JSON.stringify(params),
16
}).then((res) => {});
17
}
18
});
19
As you can see i straight use message.embeds[0].
So i don’t even know if it possible to remove 1 element from it like the footer text for example.
If anyone knows if it can be done or not, please say so.
Thank you for reading.
EDIT:
Would it be something like:
JavaScript
1
6
1
const embed = message.embeds[0];
2
3
embed.footer.text = [];
4
// or
5
embed.footer[0].text
6
Advertisement
Answer
You can use the delete
operator to remove a property from an object.
JavaScript
1
10
10
1
const embed = message.embeds[0];
2
if (!embed) return;
3
4
delete embed.footer;
5
6
message.channel.send({
7
content: "Footer removed!",
8
embeds:
9
});
10
Note that you can’t remove only the text
property and keep the icon. The footer won’t show without a text
property.
These work too:
JavaScript
1
8
1
// Remove only text from footer (footer won't be visible including icon)
2
embed.footer.text = "";
3
// Or
4
embed.footer = {};
5
// Or
6
embed.footer = null;
7
// Or ...
8