qeled / discordie

Predictable JavaScript abstractions for Discord API.
https://qeled.github.io/discordie/
BSD 2-Clause "Simplified" License
190 stars 45 forks source link

Mentioning a User in bot response. #90

Closed mattburchett closed 7 years ago

mattburchett commented 7 years ago

Hi,

I'm rather new to javascript/node, so please bear with me, but I could be overlooking this ability entirely.

I'm currently trying to have the bot parse the input of a command use it to highlight a member in the response.

As an example:

      // !cookie
      if (e.message.content.indexOf("!cookie") >=0) {
        if (e.message.content !== "!cookie") {
          var input = e.message.content
          var fields = input.split(' ', 2)
          var user = client.Users.find(u => u.username == fields[1]);
          e.message.channel.sendMessage("*gives " + user.mention[fields[1] + " a freshly made cookie.*")
      } else {
          e.message.channel.sendMessage("*gives " + e.message.author.nickMention + " a freshly made cookie.*")
        }
      }

Ideally, I want to run "!cookie WARBIRD199" and it respond with "gives @WARBIRD199 a freshly made cookie." but with a highlight of the user.

Am I close to achieving this with my current code? I apologize if it's a noob question. :)

mattburchett commented 7 years ago

I figured it out, I was missing an additional bracket. Oops.