You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

MessageExtensions.cs 733 B

123456789101112131415161718192021
  1. namespace Discord
  2. {
  3. /// <summary>
  4. /// Provides extension methods for <see cref="IMessage"/>.
  5. /// </summary>
  6. public static class MessageExtensions
  7. {
  8. /// <summary>
  9. /// Gets a URL that jumps to the message.
  10. /// </summary>
  11. /// <param name="msg">The message to jump to.</param>
  12. /// <returns>
  13. /// A string that contains a URL for jumping to the message in chat.
  14. /// </returns>
  15. public static string GetJumpUrl(this IMessage msg)
  16. {
  17. var channel = msg.Channel;
  18. return $"https://discordapp.com/channels/{(channel is IDMChannel ? "@me" : $"{(channel as ITextChannel).GuildId}")}/{channel.Id}/{msg.Id}";
  19. }
  20. }
  21. }