Hi there, I need help!

I am trying to make a submission command for my discord bot, it’s like when I user uses the command; !submit {#channel} + attachment

Once the use the command there will need to be an attachment with it, here is what I have done so far, the problem is that it isn’t showing the image in the embed.

if(message.content.toLowerCase().startsWith(prefix + 'submit')){
    if(message.mentions.channels.first()){
      if(message.attachments.first()){
        message.delete()
        var channel = message.mentions.channels.first()
        let image = message.attachments.first().url
        
        let submission = new Discord.RichEmbed()
        .setTitle('Submission')
        .setColor('RANDOM')
        .setImage(image)
        .setFooter('by '+message.author.tag)
        .setTimestamp()
        channel.send(submission);
      }else{
        message.reply('you'll need an attachment.')
      }
    }else{
      message.reply('you need to mention a channel to submit in.')
    }
  }

MOD EDIT: formatting

What is image defined as?

Well I try to get the attachment url and then put it in the embed but it just doesn’t work out.

Yes, but can you please show me what you have “image” defined as, because all we can see is the embed code, could you show the rest?

Maybe the message.delete() should come after the other lines that use message?

Hello @dev!

Like @mishavee said

You might want to move it lower, since discord api doesn’t allows us to see deleted messages.

And an another issue was on

you have to add \' if you want to use another ’ before ending your string.

Here is the complete code:

   if (message.content.toLowerCase().startsWith(prefix + 'submit')){
       if (message.mentions.channels.first()) {
         if (message.attachments.first()) {
            const channel = message.mentions.channels.first()
            const image = message.attachments.first().url

            const submission = new Discord.RichEmbed()
           .setTitle('Submission')
           .setColor('RANDOM')
           .setImage(image)
           .setFooter('by '+message.author.tag)
           .setTimestamp()
           channel.send(submission)

           message.delete()
         } else {
           message.reply('You\'ll need an attachment.')
         }
       } else {
         message.reply('You need to mention a channel to submit in.')
       }
    }

Have a nice day!