Completed
Push — master ( cb5d8b...ad7957 )
by Viktor
01:46
created

cmd.FUCommand   A

Complexity

Conditions 4

Size

Total Lines 13
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 12
nop 1
dl 0
loc 13
rs 9.8
c 0
b 0
f 0
1
package cmd
2
3
import (
4
	"fmt"
5
	"github.com/FlameInTheDark/dtbot/api/fun"
6
	"github.com/FlameInTheDark/dtbot/bot"
7
)
8
9
// SlapCommand returns slap image
10
func SlapCommand(ctx bot.Context) {
11
	if len(ctx.Args) > 0 {
12
		ctx.MetricsCommand("fun", "slap")
13
		url, err := fun.GetImageURL("slap")
14
		if err == nil {
15
			user := ctx.GetGuildUser(ctx.Args[0][2 : len(ctx.Args[0])-1])
16
			var mention = ctx.Args[0]
17
			if user != nil {
18
				mention = user.Username
19
			}
20
			ctx.ReplyEmbedAttachmentImageURL("", fmt.Sprintf(ctx.Loc("slapping"), ctx.User.Username, mention), url)
0 ignored issues
show
introduced by
can't check non-constant format in call to Sprintf
Loading history...
21
		} else {
22
			fmt.Printf(err.Error())
0 ignored issues
show
introduced by
can't check non-constant format in call to Printf
Loading history...
23
		}
24
	}
25
}
26
27
func FUCommand(ctx bot.Context) {
0 ignored issues
show
introduced by
exported function FUCommand should have comment or be unexported
Loading history...
28
	if len(ctx.Args) > 0 {
29
		ctx.MetricsCommand("fun", "fu")
30
		url, err := fun.GetImageURL("fu")
31
		if err == nil {
32
			user := ctx.GetGuildUser(ctx.Args[0][2 : len(ctx.Args[0])-1])
33
			var mention = ctx.Args[0]
34
			if user != nil {
35
				mention = user.Username
36
			}
37
			ctx.ReplyEmbedAttachmentImageURL("", fmt.Sprintf(ctx.Loc("send_fu"), ctx.User.Username, mention), url)
0 ignored issues
show
introduced by
can't check non-constant format in call to Sprintf
Loading history...
38
		} else {
39
			fmt.Printf(err.Error())
0 ignored issues
show
introduced by
can't check non-constant format in call to Printf
Loading history...
40
		}
41
	}
42
}