forked from Minecraft/canopeas
43 lines
878 B
Go
43 lines
878 B
Go
|
package discord
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
commands["compliment"] = command{
|
||
|
validate: func(cmd commandInit) bool {
|
||
|
return true
|
||
|
},
|
||
|
run: func(cmd commandInit) (string, error) {
|
||
|
if !memeRateLimit.Try() {
|
||
|
return "", nil
|
||
|
}
|
||
|
|
||
|
fields := strings.Fields(cmd.message.Content)
|
||
|
|
||
|
var target string
|
||
|
if len(fields) > 1 {
|
||
|
target = strings.Join(fields[1:], " ")
|
||
|
} else if cmd.message.Member.Nick != "" {
|
||
|
target = cmd.message.Member.Nick
|
||
|
} else {
|
||
|
target = cmd.message.Author.Username
|
||
|
}
|
||
|
|
||
|
compliment := fmt.Sprintf("%s, I would %s my %s just to %s.",
|
||
|
target,
|
||
|
random(cmd.config.Compliment.Verbs),
|
||
|
random(cmd.config.Compliment.Nouns),
|
||
|
random(cmd.config.Compliment.MinorThings),
|
||
|
)
|
||
|
|
||
|
sendMessage(cmd.session, cmd.message.ChannelID, compliment, true)
|
||
|
|
||
|
return "", nil
|
||
|
},
|
||
|
help: "Compliment someone!",
|
||
|
}
|
||
|
}
|