diff --git a/discord/channel.go b/discord/channel.go index 171c71f..8de7538 100644 --- a/discord/channel.go +++ b/discord/channel.go @@ -57,7 +57,7 @@ type Channel struct { // Mention returns a mention of the channel. func (ch Channel) Mention() string { - return "<#" + ch.ID.String() + ">" + return ch.ID.Mention() } // IconURL returns the URL to the channel icon in the PNG format. diff --git a/discord/guild.go b/discord/guild.go index e291071..1b71c23 100644 --- a/discord/guild.go +++ b/discord/guild.go @@ -307,7 +307,7 @@ type Role struct { // Mention returns the mention of the Role. func (r Role) Mention() string { - return "<@&" + r.ID.String() + ">" + return r.ID.Mention() } // https://discord.com/developers/docs/topics/gateway#presence-update @@ -375,7 +375,7 @@ type Member struct { // Mention returns the mention of the role. func (m Member) Mention() string { - return "<@!" + m.User.ID.String() + ">" + return m.User.Mention() } // https://discord.com/developers/docs/resources/guild#ban-object diff --git a/discord/snowflake.go b/discord/snowflake.go index 358770e..dcb403e 100644 --- a/discord/snowflake.go +++ b/discord/snowflake.go @@ -149,6 +149,7 @@ func (s ChannelID) Time() time.Time { return Snowflake(s).Time() } func (s ChannelID) Worker() uint8 { return Snowflake(s).Worker() } func (s ChannelID) PID() uint8 { return Snowflake(s).PID() } func (s ChannelID) Increment() uint16 { return Snowflake(s).Increment() } +func (s ChannelID) Mention() string { return "<#" + s.String() + ">" } type EmojiID Snowflake @@ -219,6 +220,7 @@ func (s RoleID) Time() time.Time { return Snowflake(s).Time() } func (s RoleID) Worker() uint8 { return Snowflake(s).Worker() } func (s RoleID) PID() uint8 { return Snowflake(s).PID() } func (s RoleID) Increment() uint16 { return Snowflake(s).Increment() } +func (s RoleID) Mention() string { return "<@&" + s.String() + ">" } type UserID Snowflake @@ -233,6 +235,7 @@ func (s UserID) Time() time.Time { return Snowflake(s).Time() } func (s UserID) Worker() uint8 { return Snowflake(s).Worker() } func (s UserID) PID() uint8 { return Snowflake(s).PID() } func (s UserID) Increment() uint16 { return Snowflake(s).Increment() } +func (s UserID) Mention() string { return "<@" + s.String() + ">" } type WebhookID Snowflake diff --git a/discord/user.go b/discord/user.go index 98eb26a..a03b3f7 100644 --- a/discord/user.go +++ b/discord/user.go @@ -27,7 +27,7 @@ type User struct { } func (u User) Mention() string { - return "<@" + u.ID.String() + ">" + return u.ID.Mention() } // AvatarURL returns the URL of the Avatar Image. It automatically detects a