2021-02-22 18:27:49 +00:00
|
|
|
package discord
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
2021-07-09 20:23:40 +00:00
|
|
|
"git.canopymc.net/Etzelia/canopeas/database"
|
2021-02-22 18:27:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2021-02-23 05:53:55 +00:00
|
|
|
commands = append(commands, &command{
|
2021-02-22 18:27:49 +00:00
|
|
|
staffOnly: true,
|
2021-02-23 05:53:55 +00:00
|
|
|
name: "unban",
|
2021-02-22 18:27:49 +00:00
|
|
|
validate: func(cmd commandInit) bool {
|
|
|
|
return isStaff(cmd.message.Member.Roles, cmd.config.StaffRoles)
|
|
|
|
},
|
|
|
|
run: func(cmd commandInit) (string, error) {
|
|
|
|
args := strings.Fields(cmd.message.Content)
|
|
|
|
|
|
|
|
if len(args) < 3 {
|
|
|
|
return "This command requires an in-game username and number of days (use 0 days to unban on next schedule).", nil
|
|
|
|
}
|
|
|
|
days, err := strconv.Atoi(args[2])
|
|
|
|
if err != nil {
|
|
|
|
return "number of days must be an integer", nil
|
|
|
|
}
|
|
|
|
target := args[1]
|
|
|
|
expiration := time.Now().Add(time.Hour * 24 * time.Duration(days))
|
|
|
|
record := database.UnbanRecord{
|
|
|
|
Username: target,
|
|
|
|
Expiration: expiration,
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("%s will be unbanned on %s", target, record.ExpirationString()),
|
|
|
|
cmd.database.AddUnban(record)
|
|
|
|
},
|
|
|
|
help: "Unban a player",
|
2021-02-23 05:53:55 +00:00
|
|
|
})
|
2021-02-22 18:27:49 +00:00
|
|
|
}
|