| Conditions | 4 |
| Total Lines | 13 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | package cmd |
||
| 12 | func DiceCommand(ctx bot.Context) { |
||
| 13 | ctx.MetricsCommand("dice", "main") |
||
| 14 | if len(ctx.Args) > 0 { |
||
| 15 | val, err := strconv.Atoi(ctx.Args[0]) |
||
| 16 | if err != nil { |
||
| 17 | return |
||
| 18 | } |
||
| 19 | if val <= 0 { |
||
| 20 | return |
||
| 21 | } |
||
| 22 | ctx.Reply(fmt.Sprintf("Dice: %v", rand.Intn(val)+1)) |
||
| 23 | } else { |
||
| 24 | ctx.Reply(fmt.Sprintf("Dice: %v", rand.Intn(6)+1)) |
||
| 25 | } |
||
| 27 |