Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda