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
This commit is contained in:
Casino Boyale
2018-07-21 01:31:30 +01:00
committed by Christopher F
parent aadd6f639f
commit afc3a9d063
2 changed files with 13 additions and 2 deletions

View File

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

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}";
}
}
}