when checking for the number of characters in the argument, I ran into a problem that the bot sends

when checking for the number of characters in the argument, I ran into a problem that the bot sends the error "not such a number of characters in the argument" anyway, even if everything is correct
const { ApplicationCommandOptionType, EmbedBuilder } = require('discord.js');

module.exports = {
name: "test",
usage: "/test",
options: [
{
name: 'option',
description: '43-symbol',
type: ApplicationCommandOptionType.String,
required: true
}
],
category: "test",
description: "test",
ownerOnly: false,
run: async (client, interaction, args) => {

await interaction.deferReply({ephemeral: true});

if(!interaction.options.getString("option").lenght !== 43) {
interaction.editReply({
content: `not 43`
})
} else {

const embed = new EmbedBuilder()
.setThumbnail(client.user.displayAvatarURL())
.addFields([
{name: `yay`, value: `${interaction.options.getString("option")}`}
])
.setColor('#FF8747')
.setFooter({
text: `test`,
iconURL: `${client.user.displayAvatarURL()}`
});

return interaction.reply({
embeds: [embed],
ephemeral: true
});
}
}
}
const { ApplicationCommandOptionType, EmbedBuilder } = require('discord.js');

module.exports = {
name: "test",
usage: "/test",
options: [
{
name: 'option',
description: '43-symbol',
type: ApplicationCommandOptionType.String,
required: true
}
],
category: "test",
description: "test",
ownerOnly: false,
run: async (client, interaction, args) => {

await interaction.deferReply({ephemeral: true});

if(!interaction.options.getString("option").lenght !== 43) {
interaction.editReply({
content: `not 43`
})
} else {

const embed = new EmbedBuilder()
.setThumbnail(client.user.displayAvatarURL())
.addFields([
{name: `yay`, value: `${interaction.options.getString("option")}`}
])
.setColor('#FF8747')
.setFooter({
text: `test`,
iconURL: `${client.user.displayAvatarURL()}`
});

return interaction.reply({
embeds: [embed],
ephemeral: true
});
}
}
}
4 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Syjalo
Syjalo2y ago
Can you show the full error?
d.js docs
d.js docs2y ago
Checking for things to not be equal in JavaScript:
- if (!yourVariable === yourOtherVariable) // !yourVariable is coerced to a boolean value
+ if (yourVariable !== yourOtherVariable) // checks that one is not equal to the other
- if (!yourVariable === yourOtherVariable) // !yourVariable is coerced to a boolean value
+ if (yourVariable !== yourOtherVariable) // checks that one is not equal to the other
• Comparison operators in JavaScript: learn more
Syjalo
Syjalo2y ago
I love line breaks
Want results from more Discord servers?
Add your server