42 lines
839 B
Go
42 lines
839 B
Go
package discord
|
|
|
|
import (
|
|
"fmt"
|
|
r "math/rand"
|
|
"time"
|
|
)
|
|
|
|
func init() {
|
|
commands["insult"] = command{
|
|
validate: func(cmd commandInit) bool {
|
|
return true
|
|
},
|
|
run: func(cmd commandInit) (string, error) {
|
|
if !memeRateLimit.Try() {
|
|
return "Woah, slow down!", nil
|
|
}
|
|
|
|
args, err := cmd.message.ContentWithMoreMentionsReplaced(cmd.session)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
insult := fmt.Sprintf("%s, your %s looks like %s, you %s %s.",
|
|
args,
|
|
random(cmd.config.Insult.Targets),
|
|
random(cmd.config.Insult.Comparisons),
|
|
random(cmd.config.Insult.Adjectives),
|
|
random(cmd.config.Insult.Nouns),
|
|
)
|
|
return insult, nil
|
|
},
|
|
help: "Insult someone!",
|
|
}
|
|
}
|
|
|
|
var rand = r.New(r.NewSource(time.Now().Unix()))
|
|
|
|
func random(list []string) string {
|
|
idx := rand.Intn(len(list) - 1)
|
|
return list[idx]
|
|
}
|