-
Notifications
You must be signed in to change notification settings - Fork 6
Roll reason support #21
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,6 +99,13 @@ func (p *Plugin) generateDicePost(query, userID, channelID, rootID string) (*mod | |
| displayName = user.Username | ||
| } | ||
|
|
||
| reason := "" | ||
| queries := strings.SplitN(query, "\n", 2) | ||
| if len(queries) == 2 { | ||
| reason = queries[1] | ||
| } | ||
| query = queries[0] | ||
|
|
||
| text := fmt.Sprintf("**%s** rolls *%s* = ", displayName, query) | ||
| sum := 0 | ||
| rollRequests := strings.Fields(query) | ||
|
|
@@ -142,6 +149,11 @@ func (p *Plugin) generateDicePost(query, userID, channelID, rootID string) (*mod | |
| text += fmt.Sprintf("\n- %s", strings.Join(formattedRollDetails, "\n- ")) | ||
| } | ||
|
|
||
| // Display roll reason | ||
| if reason != "" { | ||
| text += fmt.Sprintf("\n```\n%s\n```", reason) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another look and feel question: why the codeblock with empty lines around? You'll find more examples on this documentation page. Do tell if that looks interesting for your use case.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This might just be my habit—my Markdown auto-formatting and linting tools (based on MD031 rule) require me to add blank lines around code blocks.
This looks really cool—I wasn’t aware of this plugin before. It appears much better-looking than
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for all your answers.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is certainly ok, thank you for the effort. If you have submitted the code, feel free to close this PR. |
||
| } | ||
|
|
||
| return &model.Post{ | ||
| UserId: p.diceBotID, | ||
| ChannelId: channelID, | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering, is it be better to show the roll reason before or after the roll? Eg.


VS
Instinctively, I think I would prefer have it before but may be missing something!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't seem to care about this; it makes no difference to me. :)