Passed
Push — master ( c1aba5...3364d3 )
by Viktor
01:30
created

cmd.DebugCommand   C

Complexity

Conditions 9

Size

Total Lines 25
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 21
nop 1
dl 0
loc 25
rs 6.6666
c 0
b 0
f 0
1
package cmd
2
3
import (
4
	"strings"
5
	"time"
6
7
	"github.com/FlameInTheDark/dtbot/bot"
8
)
9
10
// DebugCommand special bot commands handler
11
func DebugCommand(ctx bot.Context) {
12
	ctx.MetricsCommand("debug", "admin")
13
	if ctx.GetRoles().ExistsName("bot.admin") {
14
		if len(ctx.Args) == 0 {
15
			return
16
		}
17
		switch ctx.Args[0] {
18
		case "roles":
19
			var roles []string
20
			for _, val := range ctx.GetRoles().Roles {
21
				roles = append(roles, val.Name)
22
			}
23
			ctx.ReplyEmbedPM("Debug", strings.Join(roles, ", "))
24
		case "time":
25
			ctx.ReplyEmbedPM("Debug", time.Now().String())
26
		case "session":
27
			sess := ctx.Sessions.GetByGuild(ctx.Guild.ID)
28
			if sess != nil {
29
				ctx.ReplyEmbed("Debug", sess.ChannelID)
30
			} else {
31
				ctx.ReplyEmbed("Debug", "Session is nil")
32
			}
33
		}
34
	} else {
35
		ctx.ReplyEmbedPM("Debug", "Not a Admin")
36
	}
37
}
38