canopeas/discord/unbans.go

36 lines
824 B
Go
Raw Permalink Normal View History

package discord
import (
"github.com/bwmarrin/discordgo"
)
func init() {
commands["unbans"] = command{
staffOnly: true,
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: "Unban a player",
}
}