Skip to content

Commit

Permalink
fix roll command
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas747 committed May 7, 2021
1 parent 7100b51 commit 76cfffe
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions stdcommands/roll/roll.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package roll
import (
"fmt"
"math/rand"
"strings"

"github.com/jonas747/dcmd/v2"
"github.com/jonas747/dice"
Expand All @@ -24,16 +25,19 @@ var Command = &commands.YAGCommand{
RunFunc: func(data *dcmd.Data) (interface{}, error) {
if data.Args[1].Value != nil {
// Special dice syntax if string
r, _, err := dice.Roll(data.Args[0].Str())
r, _, err := dice.Roll(data.Args[1].Str())
if err != nil {
return err.Error(), nil
}

output := r.String()
if len(output) > 100 {
output = output[:100] + "..."
} else {
output = strings.TrimSuffix(output, "([])")
}
return output, nil

return ":game_die: " + output, nil
}

// normal, n sides dice rolling
Expand Down

0 comments on commit 76cfffe

Please sign in to comment.