2020-06-12 16:38:18 +00:00
|
|
|
package discord
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2021-05-04 16:18:15 +00:00
|
|
|
"git.birbmc.com/canopeas/config"
|
2021-02-23 05:53:55 +00:00
|
|
|
|
|
|
|
"github.com/bwmarrin/discordgo"
|
2020-06-12 16:38:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func Echo(cfg *config.Config) {
|
|
|
|
for _, e := range cfg.Echoes {
|
2021-02-23 05:53:55 +00:00
|
|
|
commands = append(commands, &command{
|
|
|
|
name: e.Name,
|
|
|
|
aliases: e.Aliases,
|
2021-05-14 03:10:02 +00:00
|
|
|
child: true,
|
2020-06-12 16:38:18 +00:00
|
|
|
validate: func(cmd commandInit) bool {
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
run: func(cmd commandInit) (string, error) {
|
2021-02-23 05:53:55 +00:00
|
|
|
return e.Message, nil
|
2020-06-12 16:38:18 +00:00
|
|
|
},
|
2021-02-23 05:53:55 +00:00
|
|
|
help: e.Help,
|
|
|
|
})
|
2020-06-12 16:38:18 +00:00
|
|
|
}
|
|
|
|
|
2021-02-23 05:53:55 +00:00
|
|
|
commands = append(commands, &command{
|
|
|
|
deleteInvocation: true,
|
|
|
|
name: "echoes",
|
2020-06-12 16:38:18 +00:00
|
|
|
validate: func(cmd commandInit) bool {
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
run: func(cmd commandInit) (string, error) {
|
2021-02-23 05:53:55 +00:00
|
|
|
embed := &discordgo.MessageEmbed{
|
|
|
|
Title: "Echo Commands",
|
|
|
|
Fields: make([]*discordgo.MessageEmbedField, len(cfg.Echoes)),
|
|
|
|
}
|
|
|
|
for i, echo := range cfg.Echoes {
|
|
|
|
name := echo.Name
|
|
|
|
if len(echo.Aliases) > 0 {
|
|
|
|
name += fmt.Sprintf(" (%s)", strings.Join(echo.Aliases, ", "))
|
|
|
|
}
|
|
|
|
embed.Fields[i] = &discordgo.MessageEmbedField{
|
|
|
|
Name: name,
|
|
|
|
Value: echo.Help,
|
|
|
|
Inline: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
channel, err := cmd.session.UserChannelCreate(cmd.message.Author.ID)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
sendEmbed(cmd.session, channel.ID, embed)
|
|
|
|
return "", nil
|
2020-06-12 16:38:18 +00:00
|
|
|
},
|
|
|
|
help: "Get all dynamic messages",
|
2021-02-23 05:53:55 +00:00
|
|
|
})
|
2020-06-12 16:38:18 +00:00
|
|
|
}
|