0
votes

I'm just returning from a very long hiatus from development and coding/programming in general, so being rusty is a huge understatement.

I'm using a discord bot (discord.js) to handle certain forms filled out and posted by a user, and after said form is collected, it should be posted on a separate hidden channel for archive purposes, then delete the original user post to keep clutter to a minimum. I completely understand that this is a basic way of doing things without args and arrays, but for a first try, it does seem to nearly work as intended.

Nearly all of it works as intended so far, except for when the bot goes to post the contents of the users post into the archive channel, it returns '<@null>'

//Discord, client, and console info up here

client.on('message', message => {
  if (!message.guild) return;
  if (message.content.startsWith('Name:')) {
    message.author.send('Thanks for your interest in the group. Your info will be reviewed shortly')
    message.delete(5000)
  if (message.author.bot) return undefined
  let msg = message.content
  if (message.content.startsWith('Name:')) {
    const generalChannel = message.guild.channels.get('channel-id')
    generalChannel.send(message)
  }
}

//client.login info below here

Ideally, the bot should be able to take the content's of the users post, and post it along with message.author.id into an archived channel, then delete the user's original post.

1

1 Answers

2
votes

Change your quotes in message.author.send('...') - currently you're trying to access the variable n in the middle of the string.

message.author.send("Thanks for your interest in such'n'such. Your info will be reviewed shortly");

Alternatively escape the quotes:

message.author.send('Thanks for your interest in such\'n\'such. Your info will be reviewed shortly');