canopeas/discord/unbans.go

37 lines
867 B
Go
Raw Permalink Normal View History

package discord
import (
"github.com/bwmarrin/discordgo"
)
func init() {
commands = append(commands, &command{
staffOnly: true,
name: "unbans",
validate: func(cmd commandInit) bool {
return isStaff(cmd.message.Member.Roles, cmd.config.StaffRoles)
},
run: func(cmd commandInit) (string, error) {
unbans := cmd.database.ListUnbans()
if len(unbans) == 0 {
return "There are no pending unbans", nil
}
embed := &discordgo.MessageEmbed{
Fields: make([]*discordgo.MessageEmbedField, len(unbans)),
}
for i, record := range cmd.database.ListUnbans() {
embed.Fields[i] = &discordgo.MessageEmbedField{
Name: record.Username,
Value: record.ExpirationString(),
Inline: true,
}
}
sendEmbed(cmd.session, cmd.message.ChannelID, embed)
return "", nil
},
help: "Check the unban scheduler",
})
}