I have a problem with my discord bot and several commands it has. I have this error when running while it worked fine before.
const {
SlashCommandBuilder
} = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('remboursementoui')
.setDescription('demande de remboursement accepter !'),
async execute(interaction, client) {
const chan = client.channels.cache.get(interaction.channelId);
const newname = "Accepter";
const embed = new client.discord.MessageEmbed()
.setColor('49ff00')
.setTitle(' remboursement accepter !')
.setDescription('Félicitation à toi ta demande de remboursement à été accepter !')
.setFooter(client.config.footerText, client.user.avatarURL())
.setTimestamp();
if (chan.name.includes('ticket')) {
chan.setName("ticket-" + newname)
interaction.reply({
ephemeral: false,
embeds: [embed]
});
} else {
interaction.reply({
content: 'Vous n\'êtes pas dans un ticket !',
ephemeral: true
});
};
},
};
I don't know where the problem is.
You'll need to check the value of client.config.footerText
According to your error message it's undefined
.
If you check the discord.js source code you can see that if the first argument (options
) is a string, it creates a new object where the text
is the value of options
. Later, it tries to destructure it but if the first argument is undefined
, it can't and will throw a TypeError.
options = { text: options, iconURL: deprecatedIconURL };
// ...
const { text, iconURL } = options;
So to fix this, you'll need to set the correct value for client.config.footerText
. Also, you can see that passing strings for MessageEmbed#setFooter
is deprecated. You should pass an object with a text
and an iconURL
, like this:
.setFooter({
// make sure client.config.footerText is a string
text: client.config.footerText,
iconURL: client.user.displayAvatarURL(),
})
It's probably also better to use .displayAvatarURL()
as it returns a default avatar if the user doesn't have any.