Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
Discord.js no está enviando la inserción debido a un error de cadena no vacía
const { SlashCommandBuilder } = require('@discordjs/builders') const discord = require('discord.js') const open = require('openweather-api-node'); module.exports = { data: new SlashCommandBuilder() .setName('weather') .setDescription('Shows the Weather condition of a place') .addStringOption(option => option.setName('city') .setDescription('Name of the city') .setRequired(true)), async execute(Discord, client, interaction) { let city = interaction.options.getString('city'); let weather = new open({ key: process.env.WEATHER, units: 'metric' }) weather.setLanguage('en') let info = await weather.getCurrent({ locationName: city }) if(!info) return interaction.reply({content:"Oops "}) //location var lon = info.lon.toString() var lat = info.lat.toString() let Timezone = info.timezone //Temperature var temp = info.weather.temp.cur.toString() let feel_like = info.weather.feels_like.cur let min = info.weather.temp.min let max =info.weather.temp.max //air condition let pressure = info.weather.pressure let humidity = info.weather.humidity + '%' let wind = info.weather.wind.speed + 'km/h' //description let sky = info.weather.description let status = info.weather.main console.log(temp) console.log(lon) console.log(lat) let new1 = new discord.MessageEmbed() new1.setTitle(city + `'s Weather`) new1.setDescription('bruh pls work') new1.setColor('#0099ff') new1.addFields('**Location**', `Latitude:`+ lat,true) new1.addFields('**Temperature**', `${temp}℃`,true) new1.setTimestamp() new1.setFooter({ text: 'Information by Open-Weather' }) interaction.reply({embeds:[new1]}) } }

Así que este es mi código, las variables temp, lan, lat eran números, pero las cambié a una cadena e incluso verifiqué con el método typeof Me dio una cadena

Pero aún me encuentro con este error llamado RangeError [EMBED_FIELD_NAME]: los nombres de los campos de MessageEmbed no deben ser una cadena vacía

Por favor ayúdame si sabes cuál es la solución.

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Prueba este formato:

 .addFields( { name: 'string', value: 'string', inline: true } )

Para múltiples:

 .addFields( { name: 'string', value: 'string' } { name: 'string', value: 'string' } )

O consulte la otra respuesta.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Está intentando agregar un campo usando Embed#addFields . Embed#addFields toma 25 parámetros de EmbedFieldData . La sintaxis correcta usando Embed#addFields sería:

 foo.addFields( { name: 'foo', value: 'bar' }, { name: 'egg', value: 'spam' } )

También puede usar Embed#addField para agregar un campo.

 foo.addField('bar', 'baz')
about 4 years ago · Juan Pablo Isaza Denunciar

0

 let new1 = new discord.MessageEmbed() new1.setTitle(city + `'s Weather`) new1.setDescription('bruh pls work') new1.setColor('#0099ff') new1.addFields('**Location**', `Latitude:`+ lat,true) new1.addFields('**Temperature**', `${temp}℃`,true) new1.setTimestamp() new1.setFooter({ text: 'Information by Open-Weather' }) interaction.reply({embeds:[new1]})

reemplazar con:

 let new1 = new discord.MessageEmbed() new1.setTitle(city + `'s Weather`) new1.setDescription('bruh pls work') new1.setColor('#0099ff') new1.addFields( {name:'**Location**', value: `Latitude:+ lat`, inline: true }, {name:'**Temperature**', value: `${temp}℃`, inline: true }, ) new1.setTimestamp() new1.setFooter({ text: 'Information by Open-Weather' }) interaction.reply({embeds:[new1]})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda