Skip to content

Commit

Permalink
Add guild navigation mentions (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
cane authored Aug 24, 2023
1 parent 0feca76 commit 16c4e0a
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions discord/mentionable.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ type MentionType struct {
}

var (
MentionTypeUser = MentionType{regexp.MustCompile(`<@!?(\d+)>`)}
MentionTypeRole = MentionType{regexp.MustCompile(`<@&(\d+)>`)}
MentionTypeChannel = MentionType{regexp.MustCompile(`<#(\d+)>`)}
MentionTypeEmoji = MentionType{regexp.MustCompile(`<a?:(\w+):(\d+)>`)}
MentionTypeTimestamp = MentionType{regexp.MustCompile(`<t:(?P<time>-?\d{1,17})(?::(?P<format>[tTdDfFR]))?>`)}
MentionTypeSlashCommand = MentionType{regexp.MustCompile(`</(\w+) ?((\w+)|(\w+ \w+)):(\d+)>`)}
MentionTypeHere = MentionType{regexp.MustCompile(`@here`)}
MentionTypeEveryone = MentionType{regexp.MustCompile(`@everyone`)}
MentionTypeUser = MentionType{regexp.MustCompile(`<@!?(\d+)>`)}
MentionTypeRole = MentionType{regexp.MustCompile(`<@&(\d+)>`)}
MentionTypeChannel = MentionType{regexp.MustCompile(`<#(\d+)>`)}
MentionTypeEmoji = MentionType{regexp.MustCompile(`<a?:(\w+):(\d+)>`)}
MentionTypeTimestamp = MentionType{regexp.MustCompile(`<t:(?P<time>-?\d{1,17})(?::(?P<format>[tTdDfFR]))?>`)}
MentionTypeSlashCommand = MentionType{regexp.MustCompile(`</(\w+) ?((\w+)|(\w+ \w+)):(\d+)>`)}
MentionTypeHere = MentionType{regexp.MustCompile(`@here`)}
MentionTypeEveryone = MentionType{regexp.MustCompile(`@everyone`)}
MentionTypeGuildNavigation = MentionType{regexp.MustCompile("<id:(browse|customize|guide)>")}
)

type Mentionable interface {
Expand Down Expand Up @@ -70,3 +71,15 @@ func FormattedTimestampMention(timestamp int64, style TimestampStyle) string {
func SlashCommandMention(id snowflake.ID, path string) string {
return fmt.Sprintf("</%s:%d>", path, id)
}

func NavigationBrowseMention() string {
return "<id:browse>"
}

func NavigationCustomizeMention() string {
return "<id:customize>"
}

func NavigationGuideMention() string {
return "<id:guide>"
}

0 comments on commit 16c4e0a

Please sign in to comment.