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');