mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-11-26 14:16:43 +00:00
Discord: Updated message's URL
This commit is contained in:
parent
35e143a99f
commit
d18298aca9
|
|
@ -1,6 +1,10 @@
|
||||||
package discord
|
package discord
|
||||||
|
|
||||||
import "github.com/diamondburned/arikawa/utils/json/enum"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/diamondburned/arikawa/utils/json/enum"
|
||||||
|
)
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
ID Snowflake `json:"id,string"`
|
ID Snowflake `json:"id,string"`
|
||||||
|
|
@ -53,14 +57,15 @@ type Message struct {
|
||||||
// URL generates a Discord client URL to the message. If the message doesn't
|
// URL generates a Discord client URL to the message. If the message doesn't
|
||||||
// have a GuildID, it will generate a URL with the guild "@me".
|
// have a GuildID, it will generate a URL with the guild "@me".
|
||||||
func (m Message) URL() string {
|
func (m Message) URL() string {
|
||||||
var head = "https://discordapp.com/channels/"
|
var guildID = "@me"
|
||||||
var tail = "/" + m.ChannelID.String() + "/" + m.ID.String()
|
if m.GuildID.Valid() {
|
||||||
|
guildID = m.GuildID.String()
|
||||||
if !m.GuildID.Valid() {
|
|
||||||
return head + "@me" + tail
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return head + m.GuildID.String() + tail
|
return fmt.Sprintf(
|
||||||
|
"https://discord.com/channels/%s/%s/%s",
|
||||||
|
guildID, m.ChannelID.String(), m.ID.String(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageType uint8
|
type MessageType uint8
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue