/
jam.go
67 lines (61 loc) · 1.53 KB
/
jam.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package commands
import (
"fmt"
"github.com/Depado/fox/acl"
"github.com/Depado/fox/player"
"github.com/bwmarrin/discordgo"
"github.com/rs/zerolog"
)
type jam struct {
BaseCommand
}
func (c *jam) Handler(s *discordgo.Session, m *discordgo.Message, args []string) {
size := "1x"
if len(args) > 0 {
switch args[0] {
case "small", "s":
size = "1x"
case "medium", "m":
size = "2x"
case "large", "l":
size = "3x"
}
}
if _, err := s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("<@%s> is jamming!", m.Author.ID)); err != nil {
c.log.Err(err).Msg("unable to send message")
}
if _, err := s.ChannelMessageSend(
m.ChannelID,
fmt.Sprintf("https://cdn.betterttv.net/emote/5f1b0186cf6d2144653d2970/%s.gif", size),
); err != nil {
c.log.Err(err).Msg("unable to send message")
}
}
func NewJamCommand(p *player.Players, log zerolog.Logger) Command {
cmd := "jam"
return &jam{
BaseCommand{
ChannelRestriction: acl.Anywhere,
RoleRestriction: acl.Anyone,
Options: Options{
ArgsRequired: false,
DeleteUserMessage: true,
},
Long: cmd,
Help: Help{
Usage: cmd,
ShortDesc: "CAT. JAM.",
Description: "CAT. JAM.",
Examples: []Example{
{Command: "jam", Explanation: "Normal jam"},
{Command: "jam large", Explanation: "Large jam"},
{Command: "jam small", Explanation: "Small jam"},
{Command: "jam l", Explanation: "Large jam"},
{Command: "jam s", Explanation: "Small jam"},
},
},
Players: p,
log: log.With().Str("command", cmd).Logger(),
},
}
}