1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-16 03:44:26 +00:00

Added Mention methods to arguments

This commit is contained in:
diamondburned (Forefront) 2020-01-23 20:54:46 -08:00
parent 586c6ceaa4
commit 4dcb6178c8

View file

@ -13,6 +13,8 @@ var (
RoleRegex = regexp.MustCompile(`<@&(\d+)>`) RoleRegex = regexp.MustCompile(`<@&(\d+)>`)
) )
//
type ChannelMention discord.Snowflake type ChannelMention discord.Snowflake
func (m *ChannelMention) Parse(arg string) error { func (m *ChannelMention) Parse(arg string) error {
@ -28,6 +30,12 @@ func (m *ChannelMention) ID() discord.Snowflake {
return discord.Snowflake(*m) return discord.Snowflake(*m)
} }
func (m *ChannelMention) Mention() string {
return "<#" + m.ID().String() + ">"
}
//
type UserMention discord.Snowflake type UserMention discord.Snowflake
func (m *UserMention) Parse(arg string) error { func (m *UserMention) Parse(arg string) error {
@ -43,6 +51,12 @@ func (m *UserMention) ID() discord.Snowflake {
return discord.Snowflake(*m) return discord.Snowflake(*m)
} }
func (m *UserMention) Mention() string {
return "<@" + m.ID().String() + ">"
}
//
type RoleMention discord.Snowflake type RoleMention discord.Snowflake
func (m *RoleMention) Parse(arg string) error { func (m *RoleMention) Parse(arg string) error {
@ -58,6 +72,12 @@ func (m *RoleMention) ID() discord.Snowflake {
return discord.Snowflake(*m) return discord.Snowflake(*m)
} }
func (m *RoleMention) Mention() string {
return "<&" + m.ID().String() + ">"
}
//
func grabFirst(reg *regexp.Regexp, func grabFirst(reg *regexp.Regexp,
item, input string, output *discord.Snowflake) error { item, input string, output *discord.Snowflake) error {