Fractune - Hello, I'd like to know why my `if` jum...
Hello, I'd like to know why my
if
jumps straight to else
while !isNaN(parseInt(tags.slice(-1)[0]))
is returning true
when there's a number as the last argument
const tags = await args.repeat('string');
let amount;
br.search("gb", tags, { limit: 3, random: true })
.then((posts) => {
for (let post of posts) {
var output = new MessageEmbed()
.setImage(post.fileUrl)
.setTimestamp()
.setFooter(`prefix > ${args.commandContext.prefix}`, member.displayAvatarURL({ dynamic: true }))
}
if (!isNaN(parseInt(tags.slice(-1)[0]))) {
amount = parseInt(tags.pop());
console.log(`amount check passed`)
if (amount > 3) {
return message.channel.send(`${emoji.SilverHydrate} You can't load too many images!`);
} else {
for (var i = 0; i < amount; i++) {
return message.channel.send({ embeds: [output] });
}
}
} else {
if (posts.length === 0) {
return message.channel.send(`${emoji.SilverLoading} No images found!`)
} else {
amount = 1;
return message.channel.send({ embeds: [output] });
}
}
}
)
const tags = await args.repeat('string');
let amount;
br.search("gb", tags, { limit: 3, random: true })
.then((posts) => {
for (let post of posts) {
var output = new MessageEmbed()
.setImage(post.fileUrl)
.setTimestamp()
.setFooter(`prefix > ${args.commandContext.prefix}`, member.displayAvatarURL({ dynamic: true }))
}
if (!isNaN(parseInt(tags.slice(-1)[0]))) {
amount = parseInt(tags.pop());
console.log(`amount check passed`)
if (amount > 3) {
return message.channel.send(`${emoji.SilverHydrate} You can't load too many images!`);
} else {
for (var i = 0; i < amount; i++) {
return message.channel.send({ embeds: [output] });
}
}
} else {
if (posts.length === 0) {
return message.channel.send(`${emoji.SilverLoading} No images found!`)
} else {
amount = 1;
return message.channel.send({ embeds: [output] });
}
}
}
)
1 Reply
no need anymore