Browse Source

Added GetJumpUrl() as an extension method for IMessage (#1102)

* Added GetJumpUrl() as an IMessage extension method

* Removed extra line for consistency

* Moved the namespace from Discord.Commands to Discord

* lint: remove eof newline

* lint: use TextChannel to get GuildID
tags/2.0
Casino Boyale Christopher F 6 years ago
parent
commit
afc3a9d063
2 changed files with 13 additions and 2 deletions
  1. +2
    -2
      src/Discord.Net.Commands/Extensions/MessageExtensions.cs
  2. +11
    -0
      src/Discord.Net.Core/Extensions/MessageExtensions.cs

+ 2
- 2
src/Discord.Net.Commands/Extensions/MessageExtensions.cs View File

@@ -1,4 +1,4 @@
using System;
using System;

namespace Discord.Commands
{
@@ -43,4 +43,4 @@ namespace Discord.Commands
return false;
}
}
}
}

+ 11
- 0
src/Discord.Net.Core/Extensions/MessageExtensions.cs View File

@@ -0,0 +1,11 @@
namespace Discord
{
public static class MessageExtensions
{
public static string GetJumpUrl(this IMessage msg)
{
var channel = msg.Channel;
return $"https://discordapp.com/channels/{(channel is IDMChannel ? "@me" : $"{(channel as ITextChannel).GuildId}")}/{channel.Id}/{msg.Id}";
}
}
}

Loading…
Cancel
Save