Reputation:
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:
However, it's not actually sent as a tag, just plain text.
Is there a way to actually ding the user with a notification?
Upvotes: 6
Views: 32931
Reputation: 605
One of my favorite things about C# 6 is that you can also use String Interpolation. Very useful in Discord.Net!
var id = Context.Message.Author.Id;
await Context.Channel.SendMessageAsync($"<@{id}> \n {imageNode.Attributes["src"].Value}";
Upvotes: 2
Reputation: 3424
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>"
Upvotes: 8