-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: list mutes command for discord
- Loading branch information
1 parent
a974c98
commit 82d06c2
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package discord | ||
|
||
import ( | ||
"github.com/bwmarrin/discordgo" | ||
mutes "main/pkg/mutes" | ||
"main/pkg/utils" | ||
) | ||
|
||
func (reporter *Reporter) GetMutesCommand() *Command { | ||
return &Command{ | ||
Info: &discordgo.ApplicationCommand{ | ||
Name: "proposals_mutes", | ||
Description: "List all active mutes.", | ||
}, | ||
Handler: func(s *discordgo.Session, i *discordgo.InteractionCreate) { | ||
filteredMutes := utils.Filter(reporter.MutesManager.Mutes.Mutes, func(m *mutes.Mute) bool { | ||
return !m.IsExpired() | ||
}) | ||
|
||
template, err := reporter.TemplatesManager.Render("mutes", filteredMutes) | ||
if err != nil { | ||
reporter.Logger.Error().Err(err).Str("template", "mutes").Msg("Error rendering template") | ||
return | ||
} | ||
|
||
reporter.BotRespond(s, i, template) | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{- if eq (len .) 0 }} | ||
No active mutes. | ||
{{- end }} | ||
{{ range . }} | ||
{{- if .Chain }} | ||
**Chain:** {{ .Chain }} | ||
{{- else }} | ||
**Chain:** all chains | ||
{{- end }} | ||
{{- if .ProposalID }} | ||
**Proposal ID:** {{ .ProposalID }} | ||
{{- else }} | ||
**Proposal ID:** all proposals | ||
{{- end }} | ||
**Expires: **{{ SerializeDate .Expires }} | ||
{{ end }} |