0

My logging command needs a channel to send messages, I do this with a >logging #channel-here command, it stores on better-sqlite3, my issue is I am not sure on how to read the contents and convert it to a channel. logging

I have been working on this for several days, and I have tried several different things, this was my latest attempt

  const id = sql.prepare(`SELECT channel FROM logging WHERE guildid = ${message.guild.id};`).get();
  const logs = client.channels.get(id);
  if (!logs) return;
  logs.send(`A message was deleted`);

const logs = needs to = the channel id that you see in the channel record if the guildid record matches the one that the message was deleted in.

Ragnar Lothbrok
  • 306
  • 1
  • 4
  • 22
  • Can you elaborate what `client.getScore()` actually is? I don't think it's a Discord.js function. Normally you would get the guild via `client.guilds.find()`and then you can do the same for the channel based on the found guild. – Xzandro Jan 08 '19 at 22:22
  • I have no idea why that was there, must have copied the wrong bit. I have updated the question with my current attempt. – Ragnar Lothbrok Jan 08 '19 at 22:50

1 Answers1

0

Instead of saving the channels mention you should save the channels id. <#channel-id> is used to mention a channel, but discord.js <guild>.channels.get(), takes only the ID. So you should only store the Channel Id in the Database, in your code for >logging #channel-here just use const mentionedchannel = message.mentions.channels.first(); and then into your DB just write the mentionedchannel.id, then your .get() should work!

PLASMA chicken
  • 2,777
  • 2
  • 15
  • 25