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

135
Vistas
Modified data when using sqlite3

I'm a discord bot developer and I use an SQLite database for my bot. I installed sqlite3 by npm command and I worked with it, there was no problem, but now I can't use it because it modifies values. I have a bit of code here:

const ghostChannels = await new Promise((resolve, reject) =>
  client.db.all(`SELECT * FROM "Ghosts"`, (err, rows) =>
    err ? reject(err) : resolve(rows)
  )
);
ghostChannels.forEach(async (channel) => {
  const guildchannel = await message.member.guild.channels.cache.get(
    channel.id
  );
  console.log(channel.id);
  console.log(guildchannel);
  const mess = await guildchannel.send(message.member);
  await mess.delete();
});

Unfortunately it returns an error:

Uncaught TypeError TypeError: channel.send is not a function

enter image description here

So I looked at the id, and saw that it's not the same ID as in the database:

enter image description here

I don't know how to fix it, so if someone knows, tell me :)

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

0

The problem is that you try to store snowflakes as integers (e.g. 988185997772738610), while you should store them as strings ("988185997772738610"). As these IDs are greater than 53 bits (MAX_SAFE_INTEGER), JavaScript has difficulty interpreting them. It can only safely represent integers between -(253 - 1) and 253 - 1.

Max safe integer 9007199254740992
Your integer 988185997772738610
Your integer becomes 988185997772738600

As you can see, every discord ID/snowflake's last two digits become 0 if they're stored as integers. You can even try it below:

console.log(988185997772738610)
// => 988185997772738600
console.log('988185997772738610')
// => "988185997772738610"

So to solve your problem, make sure you insert the channel (and other) IDs as strings into the database.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Maybe you do it in a wrong way? calling in any database need some gateway (idk the exact name). for ex:

const ghostChannels = await new Promise((resolve, reject) =>
  client.db.all(`SELECT * FROM "Ghosts"`, (err, rows) =>
    err ? reject(err) : resolve(rows)
  )
);
ghostChannels.forEach(async (channel) => {
  const guildchannel = await message.member.guild.channels.cache.get(
    channel.id
  );
  console.log(channel.id);
  console.log(guildchannel);
  const mess = await channel.send(message.member);
  await mess.delete();
});

since you called your guildchannel to db your:

const mess = await channel.send(message.member);

should be:

const mess = await guildchannel.send(message.member);

EDIT:

I've seen that guildchannel shows as undefined, you can try:

await guildchannel.channel?.send

or something like this:

const chan = message.guild.channels.cache.get(`${channel.id}`)
chan.send("set")
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