Files
bolt/command.go
2026-02-24 18:19:41 -05:00

50 lines
1.4 KiB
Go

package bolt
import (
"time"
)
// custom Discord commands
type Command struct {
Trigger string //command that triggers payload NOT including the indicator
Payload Payload //payload function to run when a command is detected
Timeout time.Duration //the amount of time before command can be run again
lastRun time.Time //timestamp of last command run
Roles []string //roles that can use command, if none are set anyone can run the command
}
// command payload functions, any strings returned are sent as a response to the command
type Payload func(msg *Message, admin AdminToolBox) error
type adminToolbox struct {
*bolt
}
type AdminToolBox interface {
Timeout(userId, serverId string, duration time.Time) error
ClearTimeout(userId, serverId string) error
Mute(userId, serverId string) error
Unmute(userId, serverId string) error
}
func NewToolbox(b *bolt) AdminToolBox {
return &adminToolbox{
bolt: b,
}
}
func (a *adminToolbox) Timeout(userId, serverId string, duration time.Time) error {
return a.GuildMemberTimeout(serverId, userId, &duration)
}
func (a *adminToolbox) ClearTimeout(userId, serverId string) error {
return a.GuildMemberTimeout(serverId, userId, nil)
}
func (a *adminToolbox) Mute(userId, serverId string) error {
return a.GuildMemberMute(serverId, userId, true)
}
func (a *adminToolbox) Unmute(userId, serverId string) error {
return a.GuildMemberMute(serverId, userId, false)
}