mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-12-02 09:47:52 +00:00
discord: add URL method to Channel
This commit is contained in:
parent
5d7b2e3fd0
commit
0ec9fe5ace
|
|
@ -1,6 +1,7 @@
|
||||||
package discord
|
package discord
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -161,6 +162,20 @@ func (ch Channel) Mention() string {
|
||||||
return ch.ID.Mention()
|
return ch.ID.Mention()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// URL generates a Discord client URL to the channel. If the channel doesn't
|
||||||
|
// have a GuildID, it will generate a URL with the guild "@me".
|
||||||
|
func (c Channel) URL() string {
|
||||||
|
var guildID = "@me"
|
||||||
|
if c.GuildID.IsValid() {
|
||||||
|
guildID = c.GuildID.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"https://discord.com/channels/%s/%s",
|
||||||
|
guildID, c.ID.String(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// IconURL returns the URL to the channel icon in the PNG format.
|
// IconURL returns the URL to the channel icon in the PNG format.
|
||||||
// An empty string is returned if there's no icon.
|
// An empty string is returned if there's no icon.
|
||||||
func (ch Channel) IconURL() string {
|
func (ch Channel) IconURL() string {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue