cmd.HelpCommand   B
last analyzed

Complexity

Conditions 5

Size

Total Lines 36
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 27
nop 1
dl 0
loc 36
rs 8.7653
c 0
b 0
f 0
1
package cmd
2
3
import (
4
	"github.com/FlameInTheDark/dtbot/bot"
5
)
6
7
// HelpCommand shows help
8
func HelpCommand(ctx bot.Context) {
9
	ctx.MetricsCommand("help_command", "main")
10
	if len(ctx.Args) == 0 {
11
		ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_reply"))
12
		return
13
	}
14
15
	commandMap := map[string]string{
16
		"v":         "help_command_!v",
17
		"b":         "help_command_!b",
18
		"y":         "help_command_!y",
19
		"r":         "help_command_!r",
20
		"w":         "help_command_!w",
21
		"n":         "help_command_!n",
22
		"t":         "help_command_!t",
23
		"c":         "help_command_!c",
24
		"p":         "help_command_!p",
25
		"geoip":     "help_command_!geoip",
26
		"twitch":    "help_command_!twitch",
27
		"greetings": "help_command_!greetings",
28
		"bot.admin": "admin_help",
29
	}
30
31
	adminCommandMap := map[string]string{
32
		"b": "help_command_!b_admin",
33
	}
34
35
	if _, ok := commandMap[ctx.Args[0]]; !ok {
36
		ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_reply"))
37
	}
38
39
	ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc(commandMap[ctx.Args[0]]))
40
41
	if ctx.IsAdmin() {
42
		if _, ok := adminCommandMap[ctx.Args[0]]; ok {
43
			ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc(adminCommandMap[ctx.Args[0]]))
44
		}
45
	}
46
}
47