Passed
Push — master ( d2824e...c8dbbf )
by Viktor
01:38
created

cmd/greetingscommand.go   A

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 24
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B cmd.GreetingsCommand 0 23 8
1
package cmd
2
3
import (
4
	"github.com/FlameInTheDark/dtbot/bot"
5
	"strings"
6
)
7
8
func GreetingsCommand(ctx bot.Context) {
0 ignored issues
show
introduced by
exported function GreetingsCommand should have comment or be unexported
Loading history...
9
	if ctx.GetRoles().ExistsName("bot.admin") || ctx.IsAdmin() {
10
		if len(ctx.Args) > 0 {
11
			switch ctx.Args[0] {
12
			case "add":
13
				if len(ctx.Args) > 1 {
14
					ctx.MetricsCommand("greetings", "add")
15
					ctx.AddGreetings(strings.Join(ctx.Args[1:], " "))
16
					ctx.ReplyEmbed(ctx.Loc("greetings"), ctx.Loc("greetings_add"))
17
				} else {
18
					ctx.MetricsCommand("greetings", "add_no_text")
19
					ctx.ReplyEmbed(ctx.Loc("greetings"), ctx.Loc("greetings_no_text"))
20
				}
21
			case "remove":
22
				ctx.MetricsCommand("greetings", "remove")
23
				ctx.RemoveGreetings()
24
			case "test":
25
				ctx.ReplyEmbed(ctx.Loc("greetings"), ctx.Loc("greetings_removed"))
26
			}
27
		}
28
	} else {
29
		ctx.ReplyEmbed("Greetings", ctx.Loc("admin_require"))
30
		ctx.MetricsCommand("greetings", "error")
31
	}
32
}
33