Discord.Net -- How to make Bot Ping users with "@"

user9377936 picture user9377936 · Feb 18, 2018 · Viewed 18k times · Source

I'm working on coding a bot that will retrieve an image based on search parameters. When the bot returns the message after the command, I want the bot to alert the user that sent the command with a ping. (the notification of a message using the "@" symbol in discord).

Here's what I've got so far:

await Context.Channel.SendMessageAsync("@" + Context.Message.Author + "\n" + imageNode.Attributes["src"].Value);

I'm able to correctly grab the author of the command and it sends as it should--

Output in channel:

enter image description here

However, it's not actually sent as a tag, just plain text.

Is there a way to actually ding the user with a notification?

Answer

Wright picture Wright · Feb 18, 2018

Yes, using User.Mention.

await Context.Channel.SendMessageAsync(Context.Message.Author.Mention + "\n" + imageNode.Attributes["src"].Value);

You can also just put their id in between <@>. For example, "Hello <@1234>"