Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: $roll being 0-indexed #139

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 2023-04-10

- Add basic support for slash commands. (#81)
- Fix: $roll is now 1-"indexed". (#139)

## Undated

Expand Down
10 changes: 5 additions & 5 deletions internal/commands/roll/roll.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/pajbot/basecommand"
"github.com/pajbot/pajbot2-discord/pkg"
"github.com/pajbot/pajbot2-discord/pkg/commands"
"github.com/pajbot/pajbot2-discord/pkg/utils"
)

var _ pkg.Command = &Command{}
Expand All @@ -33,13 +34,12 @@ func (c *Command) Run(s *discordgo.Session, m *discordgo.MessageCreate, parts []
if len(parts) >= 2 {
number, err := strconv.Atoi(parts[1])
if err == nil && number >= 1 {
response := discordgo.MessageSend{
Content: fmt.Sprintf("%s, %d", m.Author.Mention(), rand.Intn(number)),
}
s.ChannelMessageSendComplex(m.ChannelID, &response)
v := 1 + rand.Intn(number)
response := fmt.Sprintf("%d", v)
utils.Reply(s, m, response)
}
}
return pkg.CommandResultFullCooldown
return pkg.CommandResultUserCooldown
}

func (c *Command) Description() string {
Expand Down
Loading