Estoy tratando de agregar un acortador de URL a mi bot de discordia. Hasta ahora, he encontrado este paquete npm. Lo he aplicado a mi código aquí:
async execute(interaction) { let longURL = interaction.options.getString("url"); var shortenedURL; isgd.shorten(longURL, function (url) { shortenedURL = url; console.log(shortenedURL); }); const embed = new MessageEmbed() .setColor("#0099ff") .setTitle("🔍 Shortened URL") .setDescription(`${shortenedURL}`); if (!longURL) { await interaction.reply({ embeds: [embed.setDescription("Please enter a valid URL to shorten")], ephemeral: true, }); } else { await interaction.reply({ embeds: [embed.setDescription(`${shortenedURL}`)], }); } }Cuando hago console.log(shortenedURL) dentro de isgd.shorten, recibo un valor. Sin embargo, siempre me quedo indefinido cuando aparece el mensaje en el servidor. ¿Por qué no pasa correctamente el valor que obtengo al mensaje?