mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-27 09:12:53 +00:00
Discord: add Mention method to mentionable Snowflakes
This commit is contained in:
parent
64ab8c4f30
commit
647efb8030
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue