decoupled some stuffs, news related tests, new commands file
This commit is contained in:
61
core/commands.go
Normal file
61
core/commands.go
Normal file
@ -0,0 +1,61 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Command struct {
|
||||
name string
|
||||
desc string
|
||||
example string
|
||||
command func(
|
||||
s *discordgo.Session,
|
||||
m *discordgo.MessageCreate,
|
||||
message string)
|
||||
}
|
||||
|
||||
var CommandRegister = make(
|
||||
map[string]Command)
|
||||
|
||||
func SetCommand(
|
||||
aliases []string,
|
||||
desc string,
|
||||
example string,
|
||||
command func(s *discordgo.Session, m *discordgo.MessageCreate, message string)) {
|
||||
for _, alias := range aliases {
|
||||
c := Command{
|
||||
name: alias,
|
||||
desc: desc,
|
||||
example: example,
|
||||
command: command}
|
||||
CommandRegister[alias] = c
|
||||
log.Printf("added %s to Register", alias)
|
||||
}
|
||||
}
|
||||
|
||||
func CommandInit() {
|
||||
SetCommand(
|
||||
[]string{"/ggd audio", "/ggd tts"},
|
||||
"*Attach a TTS version of the message on the channel*",
|
||||
"`/ggd [audio|tts] hello everyone`",
|
||||
MessageAudio)
|
||||
|
||||
SetCommand(
|
||||
[]string{"ping", "pong"},
|
||||
"*Check if the bot is alive*",
|
||||
"`[ping|pong]`",
|
||||
MessagePing)
|
||||
|
||||
SetCommand(
|
||||
[]string{"/ggd help", "/ggd info"},
|
||||
"*Display the available list of commands*",
|
||||
"`/ggd [help|info]`",
|
||||
MessageHelp)
|
||||
|
||||
SetCommand(
|
||||
[]string{"/ggd hat", "/ggd chapeau", "/ggd chapo"},
|
||||
"*Hand over a set of fancy hats*",
|
||||
"`/ggd [hat|chapeau|chapo]`",
|
||||
MessageHat)
|
||||
}
|
||||
Reference in New Issue
Block a user