Skip to content

Commit

Permalink
Remove messaging code
Browse files Browse the repository at this point in the history
Finally getting around to removing deprecated code that is no longer
used due to slash commands. So ya, code cleanup to help it be easier to
read dice maiden logic
  • Loading branch information
Humblemonk committed Jun 18, 2024
1 parent bed9a32 commit bec273d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 125 deletions.
11 changes: 1 addition & 10 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.10.1
# Version: 8.10.2
# 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 @@ -54,16 +54,7 @@
mutex.lock
begin
@event_roll = event.options.values.join('')
# handle !dm <command>. DEPRECATED WITH SLASH COMMANDS
# next if check_server_options(event) == true

# check what prefix the server should be using. DEPRECATED WITH SLASH COMMANDS
# check_prefix(event)
# check if input is even valid. DEPRECATED WITH SLASH COMMANDS
# next if input_valid(event) == false
# check_request_option(event)

# check for comment
@do_tally_shuffle = false
check_comment
@roll_request = @event_roll.dup
Expand Down
4 changes: 4 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 8.10.2 -2024-06-18
### Added
- removed deprecated code that is no longer used due to slash commands

## 8.10.1 -2024-06-16
### Added
- fix help rolls
Expand Down
115 changes: 0 additions & 115 deletions src/dice_maiden_logic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -553,121 +553,6 @@ def check_prefix(event)
end
end

# this is now deprecated with slash commands
def handle_prefix(event)
return false if event.channel.pm?

@prefix_setcmd = event.content.strip.to_s
@server = event.server.id
check_user_or_nick(event)

if @prefix_setcmd =~ /^(!dm prefix check)\s*$/i
@prefix_check = $db.execute "select prefix from prefixes where server = #{@server}"
if @prefix_check.empty?
event.respond(content: 'This servers prefix is set to: !roll')
return true
else
event.respond(content: "This servers prefix is set to: #{@prefix_check[0].join(', ')}")
return true
end
end

if @prefix_setcmd =~ /^(!dm prefix reset)\s*$/i
if event.user.defined_permission?(:manage_messages) == true ||
event.user.defined_permission?(:administrator) == true ||
event.user.permission?(:manage_messages, event.channel) == true
$db.execute "delete from prefixes where server = #{@server}"
event.respond(content: 'Prefix has been reset to !roll')
return true
else
event.respond(content: "#{@user} does not have permissions for this command")
return true
end
end

if @prefix_setcmd =~ /^(!dm prefix)/i
if event.user.defined_permission?(:manage_messages) == true ||
event.user.defined_permission?(:administrator) == true ||
event.user.permission?(:manage_messages, event.channel) == true
# remove command syntax and trailing which will be added later
@prefix_setcmd.slice!(/!dm prefix\s*/i)

if @prefix_setcmd.empty?
# do nothing if the set command is empty
return true
end

if @prefix_setcmd.size > 10
event.respond(content: 'Prefix too large. Keep it under 10 characters')
return true
end
@prefix_prune = @prefix_setcmd.delete(' ')
$db.execute "insert or replace into prefixes(server,prefix,timestamp) VALUES (#{@server},\"!#{@prefix_prune}\",CURRENT_TIMESTAMP)"
event.respond(content: "Prefix is now set to: !#{@prefix_prune}")
true
else
event.respond(content: "#{@user} does not have permissions for this command")
true
end
end
end

# this is now deprecated with slash commands
def check_server_options(event)
if event.content =~ /(^!dm prefix)/i
if @launch_option == 'lite'
event.respond(content: 'This option is not supported with Dice Maiden Lite.')
return true
end
handle_prefix(event)
elsif event.content =~ /(^!dm request)/i
if @launch_option == 'lite'
event.respond(content: 'This option is not supported with Dice Maiden Lite.')
return true
end
set_show_request(event)
end
end

# this is now deprecated with slash commands
def set_show_request(event)
return false if event.channel.pm?

request_setcmd = event.content.delete_prefix('!dm request').strip
server = event.server.id
check_user_or_nick(event)

if event.user.defined_permission?(:manage_messages) == true ||
event.user.defined_permission?(:administrator) == true ||
event.user.permission?(:manage_messages, event.channel) == true
if request_setcmd == 'show'
@request_option = true
$db.execute "insert or replace into server_options(server,show_requests,timestamp) VALUES (#{server},\"#{@request_option}\",CURRENT_TIMESTAMP)"
elsif request_setcmd == 'hide'
$db.execute "delete from server_options where server = #{server}"
else
event.respond(content: "'" + request_setcmd + "' is not a valid option. Please use 'show' or 'hide'.")
return true
end
event.respond(content: 'Requests will now be ' + (@request_option ? 'shown' : 'hidden') + ' in responses.')
true
else
event.respond(content: "#{@user} does not have permissions for this command")
true
end
end

def check_request_option(_event)
# deprecating old code and forcing request option to always be true due to slash command implementation
# if event.channel.pm? || @launch_option == 'lite'
# @request_option = false
# return
# end
# server = event.server.id
# @request_option = $db.execute "select show_requests from server_options where server = #{server}"
@request_option = true
end

def input_valid(event)
event_input = event.content
if event_input =~ /\A^(#{@prefix}\s)/i
Expand Down

0 comments on commit bec273d

Please sign in to comment.