Skip to content

Commit

Permalink
Add total to roll set results
Browse files Browse the repository at this point in the history
Minor change that addes the total value of a roll set. This is on by default with no toggle

closes #124
  • Loading branch information
Humblemonk committed Mar 26, 2024
1 parent d471aa3 commit 9009af8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ https://discord.com/api/oauth2/authorize?client_id=572301609305112596&permission

This will authorize the bot for your server and you should see it in your default public channel. The bot will have permissions to read, send and manage messages.

**NOTE:** When you first add the bot to your server, it may show up as offline. This is normal! It can take some time for your server to be cached by the bot.
**NOTE:** When you first add the bot to your server, it may show up as offline. This is normal! It can take some time for your server to be cached by the bot and Discord API backend.

# Manual Install
If you wish to host this yourself, Dice Maiden requires ruby version 2.4 or higher. Please check the Gemfile for the various gems required. To manage these gems, it is recommended to utilize [Bundler](https://bundler.io/).You will also need to create a bot which can be done at the [discord developer section](https://discordapp.com/developers/applications/me).
Expand Down
7 changes: 4 additions & 3 deletions dice_maiden.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dice bot for Discord
# Author: Humblemonk
# Version: 8.6.4
# Version: 8.7.0
# Copyright (c) 2017. All rights reserved.
# !/usr/bin/ruby
# If you wish to run a single instance of this bot, please follow the "Manual Install" section of the readme!
Expand Down Expand Up @@ -116,6 +116,7 @@
@roll_set_results = ''
@error_check_roll_set = ''
roll_count = 0
@roll_set_total = 0
error_encountered = false
while roll_count < @roll_set.to_i
if do_roll(event) == true
Expand All @@ -135,9 +136,9 @@

log_roll(event) if @launch_option == 'debug'
if @comment.to_s.empty? || @comment.to_s.nil?
event.respond(content: "#{@user} Request: `[#{@roll_request.strip}]` Rolls:\n#{@roll_set_results}")
event.respond(content: "#{@user} Request: `[#{@roll_request.strip}]` Rolls:\n#{@roll_set_results}Results Total: `#{@roll_set_total}`")
else
event.respond(content: "#{@user} Rolls:\n#{@roll_set_results} Reason: `#{@comment}`")
event.respond(content: "#{@user} Rolls:\n#{@roll_set_results}Results Total: `#{@roll_set_total}`\nReason: `#{@comment}`")
end
next
end
Expand Down
6 changes: 6 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 8.7.0 - 2024-03-25
### Added
- Refactored Gemfile
- Added total to roll set results
- Added note to readme regarding time it takes for a new server to be cached by discord

## 8.6.4 - 2024-02-17
### Added
- Refactored Gemfile
Expand Down
9 changes: 7 additions & 2 deletions src/dice_maiden_logic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,12 @@ def do_roll(event)
return true
end

@dice_result = "Result: `#{roll_result}`"
if @roll_set.nil?
@dice_result = "Result: `#{roll_result}`"
else
@roll_set_total += roll_result
@dice_result = "Result: `#{roll_result}`"
end
end

def log_roll(event)
Expand All @@ -287,7 +292,7 @@ def log_roll(event)
end
else
File.open('dice_rolls.log', 'a') do |f|
f.puts "#{@time} Shard: #{@shard} | #{@server}| #{@user} Rolls:\n #{@roll_set_results}"
f.puts "#{@time} Shard: #{@shard} | #{@server}| #{@user} Rolls:\n #{@roll_set_results}Results Total:`#{@roll_set_total}`"
end
end
end
Expand Down

0 comments on commit 9009af8

Please sign in to comment.