Skip to content

Commit

Permalink
add JumpURL() to Message
Browse files Browse the repository at this point in the history
  • Loading branch information
mlnrDev committed Aug 31, 2022
1 parent 6ea9ab4 commit 97dd956
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion discord/message.go
Expand Up @@ -63,7 +63,7 @@ func (t MessageType) Deleteable() bool {
}
}

const MessageURLFmt = "https://discord.com/channels/%d/%d/%d"
const MessageURLFmt = "https://discord.com/channels/%s/%d/%d"

func MessageURL(guildID snowflake.ID, channelID snowflake.ID, messageID snowflake.ID) string {
return fmt.Sprintf(MessageURLFmt, guildID, channelID, messageID)
Expand Down Expand Up @@ -210,6 +210,14 @@ func (m *Message) SelectMenuByID(customID string) *SelectMenuComponent {
return nil
}

func (m *Message) JumpURL() string {
guildID := "@me"
if m.GuildID != nil {
guildID = m.GuildID.String()
}
return fmt.Sprintf(MessageURLFmt, guildID, m.ChannelID, m.ID) // duplicate code, but there isn't a better way without sacrificing user convenience
}

type MessageThread struct {
GuildThread
Member ThreadMember `json:"member"`
Expand Down

0 comments on commit 97dd956

Please sign in to comment.