0

So I have a table called logging in my database, with a schema of guildid & channel

I need to get the contents of channel if the guildid matches, I ran console.log(logs) to see what was actually happening and it said { channel: '495602952778678274' }

I opted to leave the complete code so you can clearly see what I am trying to accomplish.

client.on('messageDelete', async (message) => {
  const logs = sql.prepare(`SELECT channel FROM logging WHERE guildid = ${message.guild.id};`).get();
  console.log(logs);
  if (!logs) return;
  const entry = await message.guild.fetchAuditLogs({
    type: 'MESSAGE_DELETE'
  }).then(audit => audit.entries.first());
  let user = "";
  if (entry.extra.channel.id === message.channel.id &&
    (entry.target.id === message.author.id) &&
    (entry.createdTimestamp > (Date.now() - 5000)) &&
    (entry.extra.count >= 1)) {
    user = entry.executor.username;
  } else {
    user = message.author.username;
  }
  client.channels.get(logs).send(`A message was deleted in ${message.channel.name} by ${user}`);
});

I also tried just logs.send... and finally I tried

const id = sql.prepare(`SELECT channel FROM logging WHERE guildid = ${message.guild.id};`).get();
const logs = client.channels.get(id);
client.channels.get(logs).send('Send a message');
Federico Grandi
  • 6,785
  • 5
  • 30
  • 50
Ragnar Lothbrok
  • 306
  • 1
  • 4
  • 22

1 Answers1

0

If you did console.log(logs) and it gave { channel: '495602952778678274' } then you should do:

const result = sql.prepare(`SELECT channel FROM logging WHERE guildid = ${message.guild.id};`).get();
const logs = client.channels.get(result.channel);
logs.send('Send a message');
PLASMA chicken
  • 2,777
  • 2
  • 15
  • 25