Passed
Push — master ( 5d908c...87bfc6 )
by Viktor
01:59
created

cmd.GreetingCommand   B

Complexity

Conditions 6

Size

Total Lines 17
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 16
nop 1
dl 0
loc 17
rs 8.6666
c 0
b 0
f 0
1
package cmd
2
3
import (
4
	"github.com/FlameInTheDark/dtbot/bot"
5
	"strings"
6
)
7
8
func GreetingCommand(ctx *bot.Context) {
0 ignored issues
show
introduced by
exported function GreetingCommand should have comment or be unexported
Loading history...
9
	if len(ctx.Args) > 0 {
10
		switch ctx.Args[0] {
11
		case "add":
12
			if len(ctx.Args) > 1 {
13
				ctx.MetricsCommand("greetings", "add")
14
				ctx.AddGreeting(strings.Join(ctx.Args[1:], " "))
15
				ctx.ReplyEmbed(ctx.Loc("greetings"), ctx.Loc("greetings_add"))
16
			} else {
17
				ctx.MetricsCommand("greetings", "add_no_text")
18
				ctx.ReplyEmbed(ctx.Loc("greetings"), ctx.Loc("greetings_no_text"))
19
			}
20
		case "remove":
21
			ctx.MetricsCommand("greetings", "remove")
22
			ctx.RemoveGreeting()
23
		case "test":
24
			ctx.ReplyEmbed(ctx.Loc("greetings"), ctx.Loc("greetings_removed"))
25
		}
26
	}
27
}
28