Commands for everyone
This commit is contained in:
@ -13,6 +13,7 @@ import (
|
||||
func setupCommands() {
|
||||
reboot := Command{
|
||||
Name: "Reboot",
|
||||
RequiresAdmin: true,
|
||||
Help: "Reboot me, requires token from logs.",
|
||||
Keywords: []string{"reboot", "re", "restart"},
|
||||
Exec: Reboot,
|
||||
@ -21,6 +22,7 @@ func setupCommands() {
|
||||
|
||||
bumpset := Command{
|
||||
Name: "BumpSet",
|
||||
RequiresAdmin: true,
|
||||
Help: "Set the bump timer (requires time in minutes until next bump).",
|
||||
Keywords: []string{"bs", "bumpset", "bumps"},
|
||||
Exec: BumpSet,
|
||||
@ -29,6 +31,7 @@ func setupCommands() {
|
||||
|
||||
retrieveVerification := Command{
|
||||
Name: "Retrieve Verification",
|
||||
RequiresAdmin: true,
|
||||
Help: "Retrieve verification either by discord ID or by nickname",
|
||||
Keywords: []string{"veri", "verification", "retrieve"},
|
||||
Exec: RetrieveVerification,
|
||||
@ -37,6 +40,7 @@ func setupCommands() {
|
||||
|
||||
addQuote := Command{
|
||||
Name: "Add Quote",
|
||||
RequiresAdmin: true,
|
||||
Keywords: []string{"quote", "addq", "q"},
|
||||
Exec: AddQuote,
|
||||
}
|
||||
@ -51,6 +55,7 @@ func setupCommands() {
|
||||
|
||||
status := Command{
|
||||
Name: "Status",
|
||||
RequiresAdmin: true,
|
||||
Keywords: []string{"st", "status", "stats"},
|
||||
Exec: Status,
|
||||
}
|
||||
|
||||
@ -52,15 +52,23 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
if time.Since(config.BumpTime) > 2*time.Hour {
|
||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%+v please say \"!d bump\" without the quotes to bump our server :)", m.Author.Mention()))
|
||||
}
|
||||
if m.ChannelID == config.AdminChannel {
|
||||
if strings.HasPrefix(m.Content, s.State.User.Mention()) {
|
||||
for _, cmd := range commands {
|
||||
for _, keyword := range cmd.Keywords {
|
||||
if strings.Contains(m.Content, keyword) {
|
||||
b.Command = keyword
|
||||
if !cmd.RequiresAdmin {
|
||||
if !cmd.Exec(b) {
|
||||
s.ChannelMessageSend(config.AdminChannel, fmt.Sprintf("There was an error running %+v\n%+v", cmd.Name, cmd.Help))
|
||||
}
|
||||
} else {
|
||||
for role := range m.Member.Roles {
|
||||
if fmt.Sprintf("%+v", role) == config.AdminRole {
|
||||
if !cmd.Exec(b) {
|
||||
s.ChannelMessageSend(config.AdminChannel, fmt.Sprintf("There was an error running %+v\n%+v", cmd.Name, cmd.Help))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user