Просмотр исходного кода

Lint all files (`rubocop --auto-correct`)

Andrew Swistak 5 лет назад
Родитель
Сommit
c3c24538ff
73 измененных файлов с 947 добавлено и 868 удалено
  1. 2 2
      app/app_forms/app_form.rb
  2. 1 1
      app/app_forms/character_app.rb
  3. 13 13
      app/app_forms/confirm_archive.rb
  4. 2 2
      app/app_forms/fable_app.rb
  5. 1 1
      app/app_forms/image_app.rb
  6. 1 1
      app/app_forms/item_app.rb
  7. 1 1
      app/app_forms/landmark_app.rb
  8. 1 1
      app/app_forms/reactivate_app.rb
  9. 1 1
      app/app_forms/team_app.rb
  10. 2 2
      app/app_forms/team_join_app.rb
  11. 1 1
      app/carousels/fable.rb
  12. 1 1
      app/carousels/guild.rb
  13. 2 2
      app/carousels/image.rb
  14. 1 1
      app/carousels/landmark.rb
  15. 2 2
      app/carousels/member.rb
  16. 4 4
      app/carousels/user.rb
  17. 7 7
      app/commands/afflict.rb
  18. 42 38
      app/commands/app.rb
  19. 1 1
      app/commands/base_command.rb
  20. 7 7
      app/commands/cure.rb
  21. 12 10
      app/commands/fable.rb
  22. 1 1
      app/commands/hello.rb
  23. 7 7
      app/commands/help.rb
  24. 19 19
      app/commands/image.rb
  25. 6 5
      app/commands/inv.rb
  26. 8 8
      app/commands/item.rb
  27. 14 15
      app/commands/landmark.rb
  28. 8 7
      app/commands/matchup.rb
  29. 39 41
      app/commands/member.rb
  30. 11 10
      app/commands/poll.rb
  31. 5 5
      app/commands/raffle.rb
  32. 20 20
      app/commands/roll.rb
  33. 6 8
      app/commands/stats.rb
  34. 7 7
      app/commands/status.rb
  35. 34 33
      app/commands/team.rb
  36. 3 3
      app/controllers/bot_controller.rb
  37. 5 9
      app/controllers/character_controller.rb
  38. 3 3
      app/controllers/dice_controller.rb
  39. 1 1
      app/controllers/fable_controller.rb
  40. 16 13
      app/controllers/image_controller.rb
  41. 1 1
      app/controllers/inventory_controller.rb
  42. 1 1
      app/controllers/item_controller.rb
  43. 1 1
      app/controllers/landmark_controller.rb
  44. 3 1
      app/controllers/status_controller.rb
  45. 17 17
      app/controllers/user_controller.rb
  46. 5 5
      app/embeds/app.rb
  47. 1 1
      app/embeds/application_responses.rb
  48. 167 120
      app/embeds/character.rb
  49. 3 3
      app/embeds/dice.rb
  50. 1 1
      app/embeds/fable.rb
  51. 12 12
      app/embeds/global.rb
  52. 27 26
      app/embeds/help.rb
  53. 8 5
      app/embeds/item.rb
  54. 30 20
      app/embeds/landmark.rb
  55. 23 23
      app/embeds/poll.rb
  56. 19 19
      app/embeds/reject.rb
  57. 1 2
      app/embeds/requests.rb
  58. 11 7
      app/embeds/status.rb
  59. 21 17
      app/embeds/team.rb
  60. 1 1
      app/embeds/users.rb
  61. 1 1
      app/models/bot_response.rb
  62. 1 1
      app/models/carousels.rb
  63. 7 7
      app/models/char_images.rb
  64. 60 60
      app/models/characters.rb
  65. 3 7
      app/models/commands.rb
  66. 13 9
      app/models/embed.rb
  67. 20 21
      app/models/fables.rb
  68. 33 37
      app/models/image_merger.rb
  69. 20 20
      app/models/item.rb
  70. 38 38
      app/models/landmarks.rb
  71. 8 8
      app/models/teams.rb
  72. 15 15
      app/models/users.rb
  73. 57 47
      bot.rb

+ 2 - 2
app/app_forms/app_form.rb

@@ -45,7 +45,7 @@ class ApplicationForm
 
   def self.majority(event)
     # The total number of voters, divided by 2, +1
-    (event.server.roles.find{ |r| r.id == ENV['ADMINS'].to_i }.members.count / 2) + 1
+    (event.server.roles.find { |r| r.id == ENV['ADMINS'].to_i }.members.count / 2) + 1
   end
 
   def self.star(event)
@@ -54,7 +54,7 @@ class ApplicationForm
       member = event.server.member(star.id)
       return true if Util::Roles.admin?(member)
     end
-    return false
+    false
   end
 
   def self.remove(event)

+ 1 - 1
app/app_forms/character_app.rb

@@ -45,7 +45,7 @@ class CharacterApplication < ApplicationForm
     # Create App Rejection
     reply = BotResponse.new(
       embed: reject_app(event.message.embeds.first, :character),
-      reactions: CharApp::REJECT_MESSAGES.map{ |k,v| k }.push(Emoji::CHECK)
+      reactions: CharApp::REJECT_MESSAGES.map { |k, _v| k }.push(Emoji::CHECK)
     )
 
     # Delete app, and reply

+ 13 - 13
app/app_forms/confirm_archive.rb

@@ -25,20 +25,20 @@ class ConfirmArchive < ApplicationForm
     ys = event.message.reacted_with(Emoji::Y)
     ys.each do |y|
       member = event.server.member(y.id)
-      if character.user_id = y.id || Util::Roles.admin?(member)
-        char_teams = CharTeam.where(char_id: character.id)
-        char_teams.each do |ct|
-          team = Team.find(ct.team_id)
-          team.leave(character)
-        end
-
-        character.update(active: 'Archived')
-
-        embed = success_embed("Successfully Archived #{character.name}")
-        event.message.delete
-        [BotResponse.new(destination: ENV['APP_CH'], embed: embed),
-         BotResponse.new(embed: embed)]
+      next unless character.user_id = y.id || Util::Roles.admin?(member)
+
+      char_teams = CharTeam.where(char_id: character.id)
+      char_teams.each do |ct|
+        team = Team.find(ct.team_id)
+        team.leave(character)
       end
+
+      character.update(active: 'Archived')
+
+      embed = success_embed("Successfully Archived #{character.name}")
+      event.message.delete
+      [BotResponse.new(destination: ENV['APP_CH'], embed: embed),
+       BotResponse.new(embed: embed)]
     end
   end
 

+ 2 - 2
app/app_forms/fable_app.rb

@@ -2,7 +2,7 @@ require './app/app_forms/app_form.rb'
 
 class FableApplication < ApplicationForm
   def self.process
-    @process||= Application.new('Fable Application') do |event|
+    @process ||= Application.new('Fable Application') do |event|
       # Calculate majority, and check votes
       maj = majority(event)
       check_votes(event, maj)
@@ -31,7 +31,7 @@ class FableApplication < ApplicationForm
   def self.deny(event)
     reply = BotResponse.new(
       embed: reject_app(event.message.embeds.first, :fable),
-      reactions: FableApp::REJECT_MESSAGES.map{ |k,v| k }.push(Emoji::CHECK)
+      reactions: FableApp::REJECT_MESSAGES.map { |k, _v| k }.push(Emoji::CHECK)
     )
 
     # Delete message and reply

+ 1 - 1
app/app_forms/image_app.rb

@@ -43,7 +43,7 @@ class ImageApplication < ApplicationForm
     # Create App Rejection
     reply = BotResponse.new(
       embed: reject_app(event.message.embeds.first, :image),
-      reactions: ImgApp::REJECT_MESSAGES.map{ |k,v| k }.push(Emoji::CHECK)
+      reactions: ImgApp::REJECT_MESSAGES.map { |k, _v| k }.push(Emoji::CHECK)
     )
 
     # Delete app, and reply

+ 1 - 1
app/app_forms/item_app.rb

@@ -31,7 +31,7 @@ class ItemApplication < ApplicationForm
   def self.deny(event)
     reply = BotResponse.new(
       embed: reject_app(event.message.embeds.first, :item),
-      reactions: ItemApp::REJECT_MESSAGES.map{ |k,v| k }.push(Emoji::CHECK)
+      reactions: ItemApp::REJECT_MESSAGES.map { |k, _v| k }.push(Emoji::CHECK)
     )
 
     # Delete message and reply

+ 1 - 1
app/app_forms/landmark_app.rb

@@ -31,7 +31,7 @@ class LandmarkApplication < ApplicationForm
   def self.deny(event)
     reply = BotResponse.new(
       embed: reject_app(event.message.embeds.first, :landmark),
-      reactions: LmApp::REJECT_MESSAGES.map{ |k,v| k }.push(Emoji::CHECK)
+      reactions: LmApp::REJECT_MESSAGES.map { |k, _v| k }.push(Emoji::CHECK)
     )
 
     # Delete message and reply

+ 1 - 1
app/app_forms/reactivate_app.rb

@@ -45,7 +45,7 @@ class ReactivationApplication < ApplicationForm
     # Create App Rejection
     reply = BotResponse.new(
       embed: reject_app(event.message.embeds.first, :reactivation),
-      reactions: CharApp::REJECT_MESSAGES.map{ |k,v| k }.push(Emoji::CHECK)
+      reactions: CharApp::REJECT_MESSAGES.map { |k, _v| k }.push(Emoji::CHECK)
     )
 
     # Delete app, and reply

+ 1 - 1
app/app_forms/team_app.rb

@@ -19,7 +19,7 @@ class TeamApplication < ApplicationForm
     # Create Role
     role = event.server.create_role(
       name: app.title,
-      colour: 3447003,
+      colour: 3_447_003,
       hoist: true,
       mentionable: true,
       reason: 'New Team'

+ 2 - 2
app/app_forms/team_join_app.rb

@@ -63,7 +63,7 @@ class TeamJoinApplication < ApplicationForm
     team = Team.find_by!(channel: event.channel.id)
 
     # The total number of voters, divided by 2, +1
-    (event.server.roles.find{ |r| r.id == team.role.to_i }.
-      members.count / 2) + 1
+    (event.server.roles.find { |r| r.id == team.role.to_i }
+      .members.count / 2) + 1
   end
 end

+ 1 - 1
app/carousels/fable.rb

@@ -11,7 +11,7 @@ class FableCarousel < Carousel
   def self.update_embed(event, carousel)
     # Save reactions and determine section
     reactions = event.message.reactions
-    section = sections.filter{ |k,v| reactions[k]&.count.to_i > 1 }.values.first
+    section = sections.filter { |k, _v| reactions[k]&.count.to_i > 1 }.values.first
 
     # Close the embed if that is chosen
     return carousel.close(event) if reactions[Emoji::CROSS]&.count.to_i > 1

+ 1 - 1
app/carousels/guild.rb

@@ -2,7 +2,7 @@ class GuildCarousel < Carousel
   def self.update_embed(event, carousel)
     # Save reactions and determine section
     reactions = event.message.reactions
-    reaction = Emoji::NUMBERS.filter{ |n| reactions[n]&.count.to_i > 1 }.first
+    reaction = Emoji::NUMBERS.filter { |n| reactions[n]&.count.to_i > 1 }.first
     list_index = Emoji::NUMBERS.index(reaction)
 
     # Close if X is chosen

+ 2 - 2
app/carousels/image.rb

@@ -13,7 +13,7 @@ class ImageCarousel < Carousel
   def self.update_embed(event, carousel)
     # Save reactions and determine section
     reactions = event.message.reactions
-    direction = sections.filter{ |k,v| reactions[k]&.count.to_i > 1 }.values.first
+    direction = sections.filter { |k, _v| reactions[k]&.count.to_i > 1 }.values.first
 
     # Close if X is chosen
     return carousel.close(event) if reactions[Emoji::CROSS]&.count.to_i > 1
@@ -72,7 +72,7 @@ class ImageCarousel < Carousel
     )
 
     # Array of section reactions and an X
-    img_reactions = sections.map{ |k,v| k }
+    img_reactions = sections.map { |k, _v| k }
     img_reactions.push(Emoji::CROSS)
 
     # Update reply

+ 1 - 1
app/carousels/landmark.rb

@@ -12,7 +12,7 @@ class LandmarkCarousel < Carousel
   def self.update_embed(event, carousel)
     # Save reactions and determine section
     reactions = event.message.reactions
-    section = sections.filter{ |k,v| reactions[k]&.count.to_i > 1 }.values.first
+    section = sections.filter { |k, _v| reactions[k]&.count.to_i > 1 }.values.first
 
     # Close the embed if that is chosen
     return carousel.close(event) if reactions[Emoji::CROSS]&.count.to_i > 1

+ 2 - 2
app/carousels/member.rb

@@ -12,7 +12,7 @@ class CharacterCarousel < Carousel
   def self.update_embed(event, carousel)
     # Save reactions and determine section
     reactions = event.message.reactions
-    section = sections.filter{ |k,v| reactions[k]&.count.to_i > 1 }.values.first
+    section = sections.filter { |k, _v| reactions[k]&.count.to_i > 1 }.values.first
 
     # Close if X is chosen
     return carousel.close(event) if reactions[Emoji::CROSS]&.count.to_i > 1
@@ -61,7 +61,7 @@ class CharacterCarousel < Carousel
     # Update reply
     BotResponse.new(
       carousel: carousel,
-      reactions: sections.map{ |k,v| k }.push(Emoji::CROSS),
+      reactions: sections.map { |k, _v| k }.push(Emoji::CROSS),
       embed: character_embed(
         character: character,
         event: event

+ 4 - 4
app/carousels/user.rb

@@ -2,7 +2,7 @@ class UserCarousel < Carousel
   def self.update_embed(event, carousel)
     # Save reactions and determine section
     reactions = event.message.reactions
-    reaction = Emoji::NUMBERS.filter{ |n| reactions[n]&.count.to_i > 1 }.first
+    reaction = Emoji::NUMBERS.filter { |n| reactions[n]&.count.to_i > 1 }.first
     char_index = Emoji::NUMBERS.index(reaction)
 
     # Close if X is chosen
@@ -21,8 +21,8 @@ class UserCarousel < Carousel
     all_chars = Character.where(user_id: user.id).order(:rating)
 
     # Handle nsfw chars in sfw channels
-    active_chars = all_chars.filter{ |c| c.active == 'Active' }
-    sfw_chars = active_chars.filter{ |c| c.rating != 'NSFW' }
+    active_chars = all_chars.filter { |c| c.active == 'Active' }
+    sfw_chars = active_chars.filter { |c| c.rating != 'NSFW' }
 
     sfw = !event.channel.nsfw?
     chars = sfw ? sfw_chars : active_chars
@@ -32,7 +32,7 @@ class UserCarousel < Carousel
       char_id: nil,
       image_id: nil,
       landmark_id: nil,
-      options: chars.map{ |c| c.id }
+      options: chars.map { |c| c.id }
     )
 
     # Array of section reactions and an X

+ 7 - 7
app/commands/afflict.rb

@@ -4,9 +4,9 @@ class AfflictCommand < BaseCommand
   def self.opts
     {
       usage: {
-        character: "Searches for the character by name, can only afflict your own characters",
-        status: "Searches for a status effect by name",
-        amount: "Applies a percentage amount of the status, should only be used if status is stackable",
+        character: 'Searches for the character by name, can only afflict your own characters',
+        status: 'Searches for a status effect by name',
+        amount: 'Applies a percentage amount of the status, should only be used if status is stackable'
       }
     }
   end
@@ -31,21 +31,21 @@ class AfflictCommand < BaseCommand
       )
 
     rescue ActiveRecord::RecordNotFound => e
-      error_embed("Record not Found!", e.message)
+      error_embed('Record not Found!', e.message)
     rescue StandardError => e
       error_embed(e.message)
     end
   end
 
-  def self.example_command(event=nil)
-    case ['unstackable', 'stackable'].sample
+  def self.example_command(_event = nil)
+    case %w[unstackable stackable].sample
     when 'unstackable'
       [Character.where(active: 'Active').order('RANDOM()').first.name,
        Status.where(amount: false).order('RANDOM()').first.name]
     when 'stackable'
       [Character.where(active: 'Active').order('RANDOM()').first.name,
        Status.where(amount: true).order('RANDOM()').first.name,
-       rand(1 .. 100)]
+       rand(1..100)]
     end
   end
 end

+ 42 - 38
app/commands/app.rb

@@ -5,16 +5,16 @@ class ApplicationCommand < BaseCommand
     {
       usage: {
         type: "Specifies which type of form you're looking for. Options include:" +
-        " character, and landmark. If omitted, defaults to characters",
-        name: "Searches for a character or landmark belonging to the user by name",
-        flag: "If a character is being updated, they may be flagged as active, archived, or deleted"
+          ' character, and landmark. If omitted, defaults to characters',
+        name: 'Searches for a character or landmark belonging to the user by name',
+        flag: 'If a character is being updated, they may be flagged as active, archived, or deleted'
       }
     }
   end
 
   def self.cmd
-    desc = "Create new or edit your existing applications for characters " +
-      "and landmarks!"
+    desc = 'Create new or edit your existing applications for characters ' +
+           'and landmarks!'
 
     @cmd ||= Command.new(:app, desc, opts) do |event, type, name, status|
       # Save the requester of the app
@@ -36,29 +36,33 @@ class ApplicationCommand < BaseCommand
       else
         character_form(event, author, type, name)
       end
-    #rescue ActiveRecord::RecordNotFound => e
-      #error_embed("Record not Found!", e.message)
-    #rescue StandardError => e
-      #error_embed(e.message)
+      # rescue ActiveRecord::RecordNotFound => e
+      # error_embed("Record not Found!", e.message)
+      # rescue StandardError => e
+      # error_embed(e.message)
     end
   end
 
   # -- Method to create replies for form requests
-  def self.send_forms(author, app_type, model=nil)
+  def self.send_forms(author, app_type, model = nil)
     # To be shown as confirmation
-    request_embed = model ?
-      edit_app_request(author, model.name) :
-      new_app_request(author, app_type)
+    request_embed = if model
+                      edit_app_request(author, model.name)
+                    else
+                      new_app_request(author, app_type)
+                    end
 
     # To be DM'd to the user
-    form_embed = model ?
-      edit_app_form(author, model) :
-      new_app_form(author, app_type)
+    form_embed = if model
+                   edit_app_form(author, model)
+                 else
+                   new_app_form(author, app_type)
+                 end
 
     phone = model ? [] : [Emoji::PHONE]
 
-    [ BotResponse.new(embed: request_embed),
-      BotResponse.new(destination: author.dm, embed: form_embed, reactions: phone) ]
+    [BotResponse.new(embed: request_embed),
+     BotResponse.new(destination: author.dm, embed: form_embed, reactions: phone)]
   end
 
   def self.character_form(event, author, name=nil, status=nil)
@@ -75,8 +79,8 @@ class ApplicationCommand < BaseCommand
         character.reload
 
         embed = success_embed("Successfully archived #{character.name}")
-        [ BotResponse.new(destination: ENV['APP_CH'], embed: embed),
-          BotResponse.new(embed: embed) ]
+        [BotResponse.new(destination: ENV['APP_CH'], embed: embed),
+         BotResponse.new(embed: embed)]
       else
         teams = Team.where(id: in_team.map(&:team_id)).map(&:name)
         embed = team_alert(character, teams)
@@ -100,14 +104,14 @@ class ApplicationCommand < BaseCommand
       if cap - current > 0
         # Submit reactivation application
         embed = character_embed(character: character, event: event)
-        embed.author = { name: "Reactivation Application" }
+        embed.author = { name: 'Reactivation Application' }
 
-        [ BotResponse.new(destination: ENV['APP_CH'], embed: embed, reactions: Emoji::APPLICATION),
-          BotResponse.new(embed: success_embed("Successfully requested #{character.name} to be reactivated!"))]
+        [BotResponse.new(destination: ENV['APP_CH'], embed: embed, reactions: Emoji::APPLICATION),
+         BotResponse.new(embed: success_embed("Successfully requested #{character.name} to be reactivated!"))]
       # If they have no open slots
       else
         # Error
-        error_embed("You can't do that", "You have too many active characters!")
+        error_embed("You can't do that", 'You have too many active characters!')
       end
 
     # Delete* character -- not actually deleted
@@ -118,7 +122,7 @@ class ApplicationCommand < BaseCommand
       if in_team
         # Fetch list of teams the character is in, and leave each one
         teams = Team.where(id: in_team.map(&:team_id))
-        teams.each{ |t| t.leave(character) }
+        teams.each { |t| t.leave(character) }
       end
 
       # Update character
@@ -128,15 +132,15 @@ class ApplicationCommand < BaseCommand
       # Create alert message
       embed = Embed.new(
         title: "Deleted #{character.name}",
-        description: "This character can only be recovered by an admin"
+        description: 'This character can only be recovered by an admin'
       )
 
       # Reply
-      [ BotResponse.new(destination: ENV['APP_CH'], embed: embed),
-        BotResponse.new(embed: embed) ]
+      [BotResponse.new(destination: ENV['APP_CH'], embed: embed),
+       BotResponse.new(embed: embed)]
 
     when /legend/i, /legendary/i
-      return command_error("Uknown Status", ApplicationCommand) unless Util::Roles.admin?(author)
+      return command_error('Uknown Status', ApplicationCommand) unless Util::Roles.admin?(author)
 
       # Add the flag to the character
       character.update(special: 'legend')
@@ -144,7 +148,7 @@ class ApplicationCommand < BaseCommand
 
       success_embed("Updated #{character.name} to be #{status}")
     when /guild/i, /employee/i
-      return command_error("Uknown Status", ApplicationCommand) unless Util::Roles.admin?(author)
+      return command_error('Uknown Status', ApplicationCommand) unless Util::Roles.admin?(author)
 
       # Add the flag to the character
       character.update(special: 'guild')
@@ -152,7 +156,7 @@ class ApplicationCommand < BaseCommand
 
       success_embed("Updated #{character.name} to be #{status}")
     when /nil/i, /null/i, /none/i
-      return command_error("Uknown Status", ApplicationCommand) unless Util::Roles.admin?(author)
+      return command_error('Uknown Status', ApplicationCommand) unless Util::Roles.admin?(author)
 
       # Remove flag from the character
       character.update(special: nil)
@@ -165,17 +169,17 @@ class ApplicationCommand < BaseCommand
 
     # Uknown status
     else
-      command_error("Uknown Status", ApplicationCommand)
+      command_error('Uknown Status', ApplicationCommand)
 
     end
   end
 
-  def self.example_command(event=nil)
+  def self.example_command(_event=nil)
     case ['', 'type', 'name', 'flag'].sample
     when ''
       []
     when 'type'
-      [['character', 'landmark'].sample]
+      [%w[character landmark].sample]
     when 'name'
       case ['', 'character', 'landmark'].sample
       when 'landmark'
@@ -190,11 +194,11 @@ class ApplicationCommand < BaseCommand
       case ['', 'character'].sample
       when ''
         [Character.where.not(active: 'Deleted').order('RANDOM()').first.name,
-         ['active', 'inactive', 'archive', 'delete'].sample]
+         %w[active inactive archive delete].sample]
       when 'character'
         ['character',
          Character.where.not(active: 'Deleted').order('RANDOM()').first.name,
-         ['active', 'inactive', 'archive', 'delete'].sample]
+         %w[active inactive archive delete].sample]
       end
     end
   end
@@ -202,8 +206,8 @@ class ApplicationCommand < BaseCommand
   def self.admin_opts
     {
       usage: {
-        id: "Character ID, name is functional if the character is yours",
-        flag: "Flags: Active, Archived, Deleted, Legend, Guild, None"
+        id: 'Character ID, name is functional if the character is yours',
+        flag: 'Flags: Active, Archived, Deleted, Legend, Guild, None'
       }
     }
   end

+ 1 - 1
app/commands/base_command.rb

@@ -15,7 +15,7 @@ class BaseCommand
     nil
   end
 
-  def self.example_command(event=nil)
+  def self.example_command(_event=nil)
     nil
   end
 

+ 7 - 7
app/commands/cure.rb

@@ -4,15 +4,15 @@ class CureCommand < BaseCommand
   def self.opts
     {
       usage: {
-        character: "Searches for the character by name, can only cure your own characters",
-        status: "Searches for a status effect by name",
-        amount: "Removes a percentage amount of the status, should only be used if status is stackable",
+        character: 'Searches for the character by name, can only cure your own characters',
+        status: 'Searches for a status effect by name',
+        amount: 'Removes a percentage amount of the status, should only be used if status is stackable'
       }
     }
   end
 
   def self.cmd
-    desc = "Cure characters of afflicted statuses"
+    desc = 'Cure characters of afflicted statuses'
 
     @cmd ||= Command.new(:cure, desc, opts) do |event, name, status, amount|
       # Find the Character and Status
@@ -37,15 +37,15 @@ class CureCommand < BaseCommand
     end
   end
 
-  def self.example_command(event=nil)
-    case ['unstackable', 'stackable'].sample
+  def self.example_command(_event=nil)
+    case %w[unstackable stackable].sample
     when 'unstackable'
       [Character.where(active: 'Active').order('RANDOM()').first.name,
        Status.where(amount: false).order('RANDOM()').first.name]
     when 'stackable'
       [Character.where(active: 'Active').order('RANDOM()').first.name,
        Status.where(amount: true).order('RANDOM()').first.name,
-       rand(1 .. 100)]
+       rand(1..100)]
     end
   end
 end

+ 12 - 10
app/commands/fable.rb

@@ -4,8 +4,8 @@ class FableCommand < BaseCommand
   def self.opts
     {
       usage: {
-        title: "Searches for the fable by title or keyword. If none is given, " +
-        "R0ry will start with the first story"
+        title: 'Searches for the fable by title or keyword. If none is given, ' +
+          'R0ry will start with the first story'
       }
     }
   end
@@ -18,18 +18,20 @@ class FableCommand < BaseCommand
       when /all/i
       when String
         # Search for Fable
-        fable =
-          Fable.find_by('title ilike ?', title) ||
-          Fable.where('? ilike any(keywords)', title) if title
+        if title
+          fable =
+            Fable.find_by('title ilike ?', title) ||
+            Fable.where('? ilike any(keywords)', title)
+        end
 
         raise 'Fable not found' if fable.empty?
 
         # Display
-        #embed = fable.lenth > 1 ? fable_list(fable) : fable_embed(fable, event)
+        # embed = fable.lenth > 1 ? fable_list(fable) : fable_embed(fable, event)
         BotResponse.new(
           embed: fable_embed(fable.first, event),
           carousel: fable.first,
-          reactions: FableCarousel.sections.map{ |k,v| k }.push(Emoji::CROSS)
+          reactions: FableCarousel.sections.map { |k, _v| k }.push(Emoji::CROSS)
         )
       when nil
         # Display first Fable
@@ -37,19 +39,19 @@ class FableCommand < BaseCommand
         BotResponse.new(
           embed: fable_embed(fable, event),
           carousel: fable,
-          reactions: FableCarousel.sections.map{ |k,v| k }.push(Emoji::CROSS)
+          reactions: FableCarousel.sections.map { |k, _v| k }.push(Emoji::CROSS)
         )
 
       end
 
     rescue ActiveRecord::RecordNotFound => e
-      error_embed("Record Not Found!", e.message)
+      error_embed('Record Not Found!', e.message)
     rescue StandardError => e
       error_embed(e.message)
     end
   end
 
-  def self.example_command(event=nil)
+  def self.example_command(_event=nil)
     case ['', 'title', 'keyword'].sample
     when ''
       []

+ 1 - 1
app/commands/hello.rb

@@ -2,7 +2,7 @@ require './app/commands/base_command.rb'
 
 class HelloCommand < BaseCommand
   def self.cmd
-    @cmd ||= Command.new(:hello, "Says hello!") do |event|
+    @cmd ||= Command.new(:hello, 'Says hello!') do |event|
       author = event.author.nickname || event.author.name
       img = ImageUrl.find_by(name: 'happy')
 

+ 7 - 7
app/commands/help.rb

@@ -4,8 +4,8 @@ class HelpCommand < BaseCommand
   def self.opts
     {
       usage: {
-        command: "Searches for a command based on its name, the part that " +
-        "comes after `pkmn-`. If no command is given, R0ry will list available commands"
+        command: 'Searches for a command based on its name, the part that ' +
+          'comes after `pkmn-`. If no command is given, R0ry will list available commands'
       }
     }
   end
@@ -24,8 +24,8 @@ class HelpCommand < BaseCommand
       when /admin/i && event.channel.id == ENV['ADMIN_CH']
       when nil
         # List of commands, by restrictions: server, and pm
-        server_commands = all_cmds.filter{ |bc| bc.restricted_to == nil }
-        pm_commands = all_cmds.filter{ |bc| bc.restricted_to == :pm }
+        server_commands = all_cmds.filter { |bc| bc.restricted_to.nil? }
+        pm_commands = all_cmds.filter { |bc| bc.restricted_to == :pm }
 
         reply = []
         reply.push(BotResponse.new(embed: command_list_embed(pm_commands, :pm)))
@@ -39,12 +39,12 @@ class HelpCommand < BaseCommand
         command_help(cmd, event)
 
       end
-    rescue
-      command_error("Command not found!", HelpCommand)
+    rescue StandardError
+      command_error('Command not found!', HelpCommand)
     end
   end
 
-  def self.example_command(event=nil)
+  def self.example_command(_event=nil)
     case ['', 'command'].sample
     when ''
       []

+ 19 - 19
app/commands/image.rb

@@ -4,21 +4,21 @@ class ImageCommand < BaseCommand
   def self.opts
     {
       usage: {
-        name: "Searches for your character, by name",
+        name: 'Searches for your character, by name',
         keyword: "Searches for your character's image, by title or keyword," +
-        " or specifies the title if new image. If an image exists for the" +
-        " character with that name, the new flag and url will overwrite it",
-        flag: "Delete indicates you want to delete the specified image." +
-        " With a new image, SFW or NSFW should be used to specify image rating",
-        url: "The url to the new image. This must be a direct link, so check" +
-        " for a .jpg/.png or similar. Animated gifs are allowed",
+          ' or specifies the title if new image. If an image exists for the' +
+          ' character with that name, the new flag and url will overwrite it',
+        flag: 'Delete indicates you want to delete the specified image.' +
+          ' With a new image, SFW or NSFW should be used to specify image rating',
+        url: 'The url to the new image. This must be a direct link, so check' +
+          ' for a .jpg/.png or similar. Animated gifs are allowed'
       }
     }
   end
 
   def self.cmd
     desc = "View, add and edit your characters' images. " +
-      "Usable only in a direct message with R0ry!"
+           'Usable only in a direct message with R0ry!'
 
     @cmd ||= Command.new(:image, desc, opts) do |event, name, keyword, tag, url, id|
       # Save the character creator's User, and find the character
@@ -48,20 +48,20 @@ class ImageCommand < BaseCommand
             reactions: Emoji::REQUEST
           ),
           BotResponse.new(
-            embed: success_embed("Your image has been sumbitted for approval!")
+            embed: success_embed('Your image has been sumbitted for approval!')
           )
         ]
 
       elsif tag&.match(/delete/i)
         # Find character's image and destroy it
-        CharImage.where(char_id: character.id).
-          find_by('keyword ilike ?', keyword).destroy
+        CharImage.where(char_id: character.id)
+                 .find_by('keyword ilike ?', keyword).destroy
         success_embed("Removed image: #{keyword}")
 
       elsif keyword
         # Find image, and display
         image = CharImage.where(char_id: character.id).
-          find_by('keyword ilike ?', keyword)
+                find_by('keyword ilike ?', keyword)
         character_embed(
           character: character,
           event: event,
@@ -75,17 +75,17 @@ class ImageCommand < BaseCommand
       end
 
     rescue ActiveRecord::RecordNotFound => e
-      error_embed("Record not Found!", e.message)
+      error_embed('Record not Found!', e.message)
     rescue StandardError => e
       error_embed(e.message)
     end
   end
 
-  def self.example_command(event=nil)
+  def self.example_command(_event=nil)
     kws = ['Fluffy', 'Pupper', 'Midnight Drink', 'On the prowl', 'Bork']
-    image_url = "https://i.imgur.com/Xa9WgSn.jpg"
+    image_url = 'https://i.imgur.com/Xa9WgSn.jpg'
 
-    case ['name', 'keyword', 'delete', 'update', 'url'].sample
+    case %w[name keyword delete update url].sample
     when 'name'
       [Character.where.not(active: 'Deleted').order('RANDOM()').first.name]
     when 'keyword'
@@ -107,9 +107,9 @@ class ImageCommand < BaseCommand
     {
       usage: {
         name: "Character's name",
-        keyword: "Image Keyword",
-        tag: "SFW/NSFW or Delete",
-        url: "Image URL",
+        keyword: 'Image Keyword',
+        tag: 'SFW/NSFW or Delete',
+        url: 'Image URL',
         id: "Character's user id"
       }
     }

+ 6 - 5
app/commands/inv.rb

@@ -4,9 +4,9 @@ class InventoryCommand < BaseCommand
   def self.opts
     {
       usage: {
-        item: "Searches for an item by name",
-        amount: "Specifies the amount of the item to add or remove",
-        character: "Searches for your character by the specified name"
+        item: 'Searches for an item by name',
+        amount: 'Specifies the amount of the item to add or remove',
+        character: 'Searches for your character by the specified name'
       }
     }
   end
@@ -21,6 +21,7 @@ class InventoryCommand < BaseCommand
 
       # Return if amount is not a number
       raise 'Invalid Amount!' if amount.to_i == 0
+
       InventoryController.edit_inventory(item, amount.to_i, character, event)
 
     rescue ActiveRecord::RecordNotFound => e
@@ -30,10 +31,10 @@ class InventoryCommand < BaseCommand
     end
   end
 
-  def self.example_command(event=nil)
+  def self.example_command(_event=nil)
     [
       Item.order('RANDOM()').first.name,
-      ["-#{rand(1 .. 5)}", rand(1 .. 5)].sample,
+      ["-#{rand(1..5)}", rand(1..5)].sample,
       Character.where.not(active: 'Deleted').order('RANDOM()').first.name
     ]
   end

+ 8 - 8
app/commands/item.rb

@@ -4,14 +4,14 @@ class ItemCommand < BaseCommand
   def self.opts
     {
       usage: {
-        name: "Search for an item by its name. If none is specified, " +
-        "R0ry will display a list of all items"
+        name: 'Search for an item by its name. If none is specified, ' +
+          'R0ry will display a list of all items'
       }
     }
   end
 
   def self.cmd
-    desc = "Learn about Items"
+    desc = 'Learn about Items'
 
     @cmd ||= Command.new(:item, desc, opts) do |event, name|
       if name
@@ -21,14 +21,14 @@ class ItemCommand < BaseCommand
         # Item list embed
         item_list
       end
-    #rescue ActiveRecord::RecordNotFound
-      #error_embed("Item Not Found!")
-    #rescue StandardError => e
-      #error_embed(e.message)
+      # rescue ActiveRecord::RecordNotFound
+      # error_embed("Item Not Found!")
+      # rescue StandardError => e
+      # error_embed(e.message)
     end
   end
 
-  def self.example_command(event=nil)
+  def self.example_command(_event=nil)
     case ['', 'item'].sample
     when ''
       []

+ 14 - 15
app/commands/landmark.rb

@@ -5,29 +5,28 @@ class LandmarkCommand < BaseCommand
     {
       # Nav consists of reaction sections and descriptions
       nav: {
-        history: [ Emoji::BOOKS, "Learn about the history and folklore" ],
-        warning: [ Emoji::SKULL, "Learn about the areas dangers" ],
-        map: [ Emoji::MAP, "See the area on the map of Zaplana" ],
-        layout: [ Emoji::HOUSES, "View a local map of the area" ],
-        npc: [ Emoji::PEOPLE, "See the NPC residents you might meet" ]
+        history: [Emoji::BOOKS, 'Learn about the history and folklore'],
+        warning: [Emoji::SKULL, 'Learn about the areas dangers'],
+        map: [Emoji::MAP, 'See the area on the map of Zaplana'],
+        layout: [Emoji::HOUSES, 'View a local map of the area'],
+        npc: [Emoji::PEOPLE, 'See the NPC residents you might meet']
       },
       # Usage has each option, in order with instructions, and a real example
       usage: {
         name:
-        "Searches landmarks for the specified name. " +
-        "If no name is given, R0ry will show a list of all landmarks",
+        'Searches landmarks for the specified name. ' +
+          'If no name is given, R0ry will show a list of all landmarks',
         section:
-        "Skips to the specified section, can use any section listed in " +
-        "navigation. If no section is given, R0ry will default to history"
+        'Skips to the specified section, can use any section listed in ' +
+          'navigation. If no section is given, R0ry will default to history'
       }
     }
   end
 
   def self.cmd
-    desc = "Learn all about the various places in Zaplana!"
+    desc = 'Learn all about the various places in Zaplana!'
 
     @cmd ||= Command.new(:landmark, desc, opts) do |event, name, section|
-
       if name
         # Find landmark, case insensitive
         landmark = Landmark.find_by!('name ilike ?', name)
@@ -36,20 +35,20 @@ class LandmarkCommand < BaseCommand
         BotResponse.new(
           embed: landmark_embed(lm: landmark, section: section, event: event),
           carousel: landmark,
-          reactions: LandmarkCarousel.sections.map{ |k,v| k }.push(Emoji::CROSS)
+          reactions: LandmarkCarousel.sections.map { |k, _v| k }.push(Emoji::CROSS)
         )
       else
         # Reply with landmark list display
         landmark_list
       end
     rescue ActiveRecord::RecordNotFound => e
-      error_embed("Record Not Found!", e.message)
+      error_embed('Record Not Found!', e.message)
     rescue StandardError => e
       error_embed(e.message)
     end
   end
 
-  def self.example_command(event=nil)
+  def self.example_command(_event=nil)
     case ['', 'name', 'section'].sample
     when ''
       []
@@ -57,7 +56,7 @@ class LandmarkCommand < BaseCommand
       [Landmark.order('RANDOM()').first.name]
     when 'section'
       [Landmark.order('RANDOM()').first.name,
-       ['history', 'warning', 'map', 'layout', 'npc'].sample]
+       %w[history warning map layout npc].sample]
     end
   end
 end

+ 8 - 7
app/commands/matchup.rb

@@ -4,14 +4,14 @@ class MatchupCommand < BaseCommand
   def self.opts
     {
       usage: {
-        primary: "Searches for type by name, must be an official pokemon type",
-        secondary: "Concats the second type to the first, and displays both"
+        primary: 'Searches for type by name, must be an official pokemon type',
+        secondary: 'Concats the second type to the first, and displays both'
       }
     }
   end
 
   def self.cmd
-    desc = "Displays a chart of effectiveness for the given type"
+    desc = 'Displays a chart of effectiveness for the given type'
 
     @cmd ||= Command.new(:matchup, desc, opts) do |event, primary, secondary|
       # Find the appropriate type images
@@ -19,13 +19,14 @@ class MatchupCommand < BaseCommand
       secondary_file = "images/Type #{secondary.capitalize}.png"
 
       # Combine if there are two
-      if File.exists?(file) && File.exists?(secondary_file)
+      if File.exist?(file) && File.exist?(secondary_file)
         append_image(file, secondary_file, 'images/Type Double.png')
         file = 'images/Type Double.png'
       end
 
       # Raise an error if the File does not exist, or return
-      raise 'Unknown Type!' unless File.exists?(file)
+      raise 'Unknown Type!' unless File.exist?(file)
+
       BotResponse.new(destination: event.channel.id, file: file)
 
     rescue StandardError => e
@@ -33,8 +34,8 @@ class MatchupCommand < BaseCommand
     end
   end
 
-  def self.example_command(event=nil)
-    case ['primary', 'secondary'].sample
+  def self.example_command(_event=nil)
+    case %w[primary secondary].sample
     when 'primary'
       [Type.where.not(name: 'Unknown').order('RANDOM()').first.name]
     when 'secondary'

+ 39 - 41
app/commands/member.rb

@@ -5,29 +5,29 @@ class MemberCommand < BaseCommand
     {
       # Nav consists of reaction sections and descriptions
       nav: {
-        all: [ Emoji::EYES, "View all info about the character" ],
-        image: [ Emoji::PICTURE, "Scroll though the character's images" ],
-        bags: [ Emoji::BAGS, "View the character's inventory" ],
-        family: [ Emoji::FAMILY, "View related characters" ],
-        user: [ Emoji::BUST, "View the writer's other characters in a list" ]
+        all: [Emoji::EYES, 'View all info about the character'],
+        image: [Emoji::PICTURE, "Scroll though the character's images"],
+        bags: [Emoji::BAGS, "View the character's inventory"],
+        family: [Emoji::FAMILY, 'View related characters'],
+        user: [Emoji::BUST, "View the writer's other characters in a list"]
       },
       # Usage has each option, in order with instructions, and a real example
       usage: {
         name:
-        "Searches characters for the specified name, or discord user. " +
-        "If no name is given, R0ry will show a list of all characters",
+        'Searches characters for the specified name, or discord user. ' +
+          'If no name is given, R0ry will show a list of all characters',
         section:
-        "Skips to the specified section, some options include: bio, type, status, " +
-        "rumors, image, bags. If no section is given, R0ry will default to history",
+        'Skips to the specified section, some options include: bio, type, status, ' +
+          'rumors, image, bags. If no section is given, R0ry will default to history',
         keyword:
-        "Displays a specific image, searched by its title, or keyword. " +
-        "Can only be used if the section option is `image`",
+        'Displays a specific image, searched by its title, or keyword. ' +
+          'Can only be used if the section option is `image`'
       }
     }
   end
 
   def self.cmd
-    desc = "Display info about the guild members"
+    desc = 'Display info about the guild members'
 
     @cmd ||= Command.new(:member, desc, opts) do |event, name, section, keyword|
       # Determine display type: user, character, or list
@@ -37,11 +37,11 @@ class MemberCommand < BaseCommand
         # Find User to display, and a list of their characters
         member = event.server.member(UID.match(name)[1])
         characters = Character.where(user_id: UID.match(name)[1])
-        active_chars = characters.filter{ |c| c.active == 'Active' }
+        active_chars = characters.filter { |c| c.active == 'Active' }
 
         # Handle sfw channels and nsfw characters
         sfw = !event.channel.nsfw?
-        sfw_chars = active_chars.filter{ |c| c.rating != 'NSFW' }
+        sfw_chars = active_chars.filter { |c| c.rating != 'NSFW' }
         chars = sfw ? sfw_chars : active_chars
 
         # Generate embed and reply
@@ -74,10 +74,10 @@ class MemberCommand < BaseCommand
           character = Character.find(name)
         elsif section&.match(/deleted?/i)
           character = Character.where(active: 'Deleted')
-            .where('name ilike ?', name)
+                               .where('name ilike ?', name)
         else
           character = Character.where.not(active: 'Deleted')
-            .where('name ilike ?', name)
+                               .where('name ilike ?', name)
           raise 'Character not found!' if character.empty?
         end
 
@@ -85,9 +85,9 @@ class MemberCommand < BaseCommand
       end
 
     rescue ActiveRecord::RecordNotFound => e
-      error_embed("Record Not Found!", e.message)
-    #rescue StandardError => e
-      #error_embed(e.message)
+      error_embed('Record Not Found!', e.message)
+      # rescue StandardError => e
+      # error_embed(e.message)
     end
   end
 
@@ -97,33 +97,31 @@ class MemberCommand < BaseCommand
 
     # Determine if duplicate characters, then filter NSFW if SFW channel
     unless character.is_a? Character
-     chars = sfw ? character.filter{ |c| c.rating != 'NSFW' } : character
-
-     # If still more than 1 character, reply with duplicate embed
-     if chars.length > 1
-       embed = dup_char_embed(chars, chars.first.name)
-       return BotResponse.new(
-         embed: embed,
-         reactions: Emoji::NUMBERS.take(chars.count),
-         carousel: chars.map(&:id)
-       )
-     elsif chars.length == 0
-       nsfw_char_embed(chars.first, event)
-     else
-       character = character.first
-     end
+      chars = sfw ? character.filter { |c| c.rating != 'NSFW' } : character
+
+      # If still more than 1 character, reply with duplicate embed
+      if chars.length > 1
+        embed = dup_char_embed(chars, chars.first.name)
+        return BotResponse.new(
+          embed: embed,
+          reactions: Emoji::NUMBERS.take(chars.count),
+          carousel: chars.map(&:id)
+        )
+      elsif chars.length == 0
+        nsfw_char_embed(chars.first, event)
+      else
+        character = character.first
+      end
     end
 
     # Find image if specified
     image = CharImage.where(char_id: character.id).
-      find_by('keyword ilike ?', keyword || 'Default')
+            find_by('keyword ilike ?', keyword || 'Default')
 
     raise 'Image not found!' if keyword && !image
 
     # Ensure the content is appropriate for the current channel
-    if sfw && ( image&.category == 'NSFW' || character.rating == 'NSFW' )
-      return nsfw_char_embed(character, event)
-    end
+    return nsfw_char_embed(character, event) if sfw && (image&.category == 'NSFW' || character.rating == 'NSFW')
 
     # Generate Character Embed
     embed = character_embed(
@@ -138,19 +136,19 @@ class MemberCommand < BaseCommand
       BotResponse.new(
         embed: embed,
         carousel: image,
-        reactions: ImageCarousel.sections.map{ |k,v| k }.push(Emoji::CROSS)
+        reactions: ImageCarousel.sections.map { |k, _v| k }.push(Emoji::CROSS)
       )
     else
       BotResponse.new(
         embed: embed,
         carousel: character,
-        reactions: CharacterCarousel.sections.map{ |k,v| k }.push(Emoji::CROSS)
+        reactions: CharacterCarousel.sections.map { |k, _v| k }.push(Emoji::CROSS)
       )
     end
   end
 
   def self.example_command(event=nil)
-    sections = ['all', 'bio', 'type', 'status', 'rumors', 'image', 'bags']
+    sections = %w[all bio type status rumors image bags]
 
     case ['', 'user', 'name', 'section', 'keyword'].sample
     when ''

+ 11 - 10
app/commands/poll.rb

@@ -4,15 +4,15 @@ class PollCommand < BaseCommand
   def self.opts
     {
       usage: {
-        question: "The Question for people to vote on",
-        options: "The answers to choose from, separated by commas. Each answer " +
-        "will be assigned a cooresponding letter for users to vote with. Maxiumum 20 options"
+        question: 'The Question for people to vote on',
+        options: 'The answers to choose from, separated by commas. Each answer ' +
+          'will be assigned a cooresponding letter for users to vote with. Maxiumum 20 options'
       }
     }
   end
 
   def self.cmd
-    desc = "Creates a dynamic poll in any channel"
+    desc = 'Creates a dynamic poll in any channel'
 
     @cmd ||= Command.new(:poll, desc, opts) do |event, question, options|
       # Split choices into an array
@@ -20,6 +20,7 @@ class PollCommand < BaseCommand
 
       # Reply
       raise 'Need voting options!' if choices.empty?
+
       BotResponse.new(
         embed: new_poll(event, question, choices),
         reactions: Emoji::LETTERS.take(choices.count)
@@ -29,13 +30,13 @@ class PollCommand < BaseCommand
     end
   end
 
-  def self.example_command(event=nil)
+  def self.example_command(_event=nil)
     [
-      ["What's your favorite cake?", "Chocolate, Red Velvet, Ice Cream, Cookie, The Cake is a lie"],
-      ["Who would win in an Epic Rap Battle?", "Alina, Aster, Cecil, Jaki, Kipper, Someone Else (#poll-chat-sfw)"],
-      ["The best admin/moderator is..", "Neiro, Mizu, Lunick, Alina, Viewer, Vul, R0ry, He who must not be named"],
-      ["The best pokemon generation is", "Kanto, Johto, Hoenn, Sinnoh, Unova, Kalos, Alola, Galar"],
-      ["What is the answer to the ultimate question of life, the universe, and everything?", "What?, 42"]
+      ["What's your favorite cake?", 'Chocolate, Red Velvet, Ice Cream, Cookie, The Cake is a lie'],
+      ['Who would win in an Epic Rap Battle?', 'Alina, Aster, Cecil, Jaki, Kipper, Someone Else (#poll-chat-sfw)'],
+      ['The best admin/moderator is..', 'Neiro, Mizu, Lunick, Alina, Viewer, Vul, R0ry, He who must not be named'],
+      ['The best pokemon generation is', 'Kanto, Johto, Hoenn, Sinnoh, Unova, Kalos, Alola, Galar'],
+      ['What is the answer to the ultimate question of life, the universe, and everything?', 'What?, 42']
     ].sample
   end
 end

+ 5 - 5
app/commands/raffle.rb

@@ -4,14 +4,14 @@ class RaffleCommand < BaseCommand
   def self.opts
     {
       usage: {
-        participats: "Chooses a random winner from a list of names. " +
-        "Also accepts everyone and here to pull names from server members"
+        participats: 'Chooses a random winner from a list of names. ' +
+          'Also accepts everyone and here to pull names from server members'
       }
     }
   end
 
   def self.cmd
-    desc = "Creates a raffle and picks a winner"
+    desc = 'Creates a raffle and picks a winner'
 
     @cmd ||= Command.new(:raffle, desc, opts) do |event, participant|
       # Collect participants
@@ -40,7 +40,7 @@ class RaffleCommand < BaseCommand
     end
   end
 
-  def self.example_command(event=nil)
+  def self.example_command(_event=nil)
     list = [
       'Neiro, Mizu, Lunick, Alina, Viewer, Vul',
       'Cecil, Aster, Zel, Rezi, Vern, Sarah, Bernie',
@@ -49,6 +49,6 @@ class RaffleCommand < BaseCommand
       'Sword, Sheild, Gun, Bomb, Tank, Fighter Jet'
     ].sample
 
-    [ ['everyone'], ['here'], [list] ].sample
+    [['everyone'], ['here'], [list]].sample
   end
 end

+ 20 - 20
app/commands/roll.rb

@@ -4,13 +4,13 @@ class RollCommand < BaseCommand
   def self.opts
     {
       usage: {
-        die: "Rolls a specified die. Can be a list of options, a name of a saved die, " +
-        "or an indication of standard dice. Standard Die are designated as `xDy` " +
-        "where `x` designates the number of die to roll, and `y` designates the number of sides" +
-        " on the die. A modifier can be added with a + or - number: Added to total." +
-        " If no die is specified, displays a list of all saved dice",
+        die: 'Rolls a specified die. Can be a list of options, a name of a saved die, ' +
+          'or an indication of standard dice. Standard Die are designated as `xDy` ' +
+          'where `x` designates the number of die to roll, and `y` designates the number of sides' +
+          ' on the die. A modifier can be added with a + or - number: Added to total.' +
+          ' If no die is specified, displays a list of all saved dice',
         combined: "Indicates you don't want to see the individual rolls, only the total." +
-        " If left empty it will show each individual roll (unless more than 25 dice were rolled)"
+          ' If left empty it will show each individual roll (unless more than 25 dice were rolled)'
       }
     }
   end
@@ -27,13 +27,13 @@ class RollCommand < BaseCommand
       if die.nil?
         dice_list
 
-      elsif d = die.gsub(" ", "").match(/([0-9]*?)d([0-9]+)([\+|\-]?[0-9]+)?/i)
+      elsif d = die.gsub(' ', '').match(/([0-9]*?)d([0-9]+)([\+|\-]?[0-9]+)?/i)
         # Roll the dice, and save it in the hash
         hash = DiceController.roll({
-          number: d[1] == "" ? 1 : d[1].to_i ,
-          sides: d[2].to_i,
-          modifier: d[3]
-        })
+                                     number: d[1] == '' ? 1 : d[1].to_i,
+                                     sides: d[2].to_i,
+                                     modifier: d[3]
+                                   })
 
         # Determine if each result should be displayed
         # Format the results into an embed, and reply
@@ -59,13 +59,13 @@ class RollCommand < BaseCommand
         roll_results(author, hash)
       end
     rescue ActiveRecord::RecordNotFound => e
-      error_embed("Record Not Found!", e.message)
+      error_embed('Record Not Found!', e.message)
     rescue StandardError => e
       error_embed(e.message)
     end
   end
 
-  def self.example_command(event=nil)
+  def self.example_command(_event=nil)
     list = [
       'Hotdog, Hamburger, Chilli Cheese Fries, Nachos, Fried Onions',
       'A, B, C, D',
@@ -78,23 +78,23 @@ class RollCommand < BaseCommand
     when ''
       []
     when 'standard'
-      [ "#{rand(1 .. 70)}d#{rand(2 .. 420)}" ]
+      ["#{rand(1..70)}d#{rand(2..420)}"]
     when 'modifier'
-      [ "#{rand(1 .. 70)}d#{rand(2 .. 420)} #{['+', '-'].sample}#{rand(1 .. 10)}" ]
+      ["#{rand(1..70)}d#{rand(2..420)} #{['+', '-'].sample}#{rand(1..10)}"]
     when 'list'
-      [ list ]
+      [list]
     when 'named'
-      [ DiceArray.order('RANDOM()').first.name ]
+      [DiceArray.order('RANDOM()').first.name]
     when 'combined'
-      [ "#{rand(1 .. 70)}d#{rand(2 .. 420)}", 'combined' ]
+      ["#{rand(1..70)}d#{rand(2..420)}", 'combined']
     end
   end
 
   def self.admin_opts
     {
       usage: {
-        die: "New die name",
-        sides: "Sides of die, `delete` will delete the stored die"
+        die: 'New die name',
+        sides: 'Sides of die, `delete` will delete the stored die'
       }
     }
   end

+ 6 - 8
app/commands/stats.rb

@@ -4,9 +4,9 @@ class StatsCommand < BaseCommand
   def self.opts
     {
       usage: {
-        user: "Searches for a discord user (need to @ them)",
+        user: 'Searches for a discord user (need to @ them)',
         all: "Used to specify you'd like to view all stats, instead of level" +
-        " progress. If empty, will show level image"
+          ' progress. If empty, will show level image'
       }
     }
   end
@@ -15,9 +15,7 @@ class StatsCommand < BaseCommand
     desc = "Shows a user's stats, level, rank, and experience"
 
     @cmd ||= Command.new(:stats, desc, opts) do |event, name, all|
-      if name.match(/ghosts?/i) && Util::Roles.admin?(event.author)
-        return UserController.fetch_ghost_users(event)
-      end
+      return UserController.fetch_ghost_users(event) if name.match(/ghosts?/i) && Util::Roles.admin?(event.author)
 
       # Find appropriate User and Server Member
       user = User.find(UID.match(name)[1])
@@ -37,7 +35,7 @@ class StatsCommand < BaseCommand
           show_stats(user, member)
         else
           # Can only re-roll if admin
-          error_embed("Not Authorized!")
+          error_embed('Not Authorized!')
         end
       else
         # Generate stats image, and reply
@@ -61,14 +59,14 @@ class StatsCommand < BaseCommand
     when ''
       ["@#{member_name}"]
     when 'all'
-      ["@#{member_name}", "all"]
+      ["@#{member_name}", 'all']
     end
   end
 
   def self.admin_opts
     {
       usage: {
-        user: "@user",
+        user: '@user',
         reroll: "Reroll will reroll user's stats"
       }
     }

+ 7 - 7
app/commands/status.rb

@@ -2,14 +2,14 @@ class StatusCommand < BaseCommand
   def self.opts
     {
       usage: {
-        name: "Searches for a status by its name. If none is specified, " +
-        "R0ry displays a list of all statuses"
+        name: 'Searches for a status by its name. If none is specified, ' +
+          'R0ry displays a list of all statuses'
       }
     }
   end
 
   def self.cmd
-    desc = "Update or edit statuses"
+    desc = 'Update or edit statuses'
 
     @cmd ||= Command.new(:status, desc, opts) do |event, name, effect, flag|
       if effect
@@ -31,7 +31,7 @@ class StatusCommand < BaseCommand
     end
   end
 
-  def self.example_command(event=nil)
+  def self.example_command(_event=nil)
     case ['', 'name'].sample
     when ''
       []
@@ -43,9 +43,9 @@ class StatusCommand < BaseCommand
   def self.admin_opts
     {
       usage: {
-        name: "The name given to the status",
-        effect: "The effect to display on a user.",
-        flag: "Indicates if the effect stacks, default is true"
+        name: 'The name given to the status',
+        effect: 'The effect to display on a user.',
+        flag: 'Indicates if the effect stacks, default is true'
       }
     }
   end

+ 34 - 33
app/commands/team.rb

@@ -5,20 +5,20 @@ class TeamCommand < BaseCommand
     {
       usage: {
         team: "Searches for a team by it's name. If no team is specified, " +
-        "R0ry will display a list of all teams.",
-        action: "Accepts `create` to create a new team, " +
-        "`update` inside a team's private channel to update team information, " +
-        "`apply` to request for a character to join the team, and " +
-        "`leave` to have a character leave the team",
-        argument: "If creating or updating a team, this should be the description" +
-        " for the team. If applying for or leaving a team, this should be your " +
-        "character's name"
+          'R0ry will display a list of all teams.',
+        action: 'Accepts `create` to create a new team, ' +
+          "`update` inside a team's private channel to update team information, " +
+          '`apply` to request for a character to join the team, and ' +
+          '`leave` to have a character leave the team',
+        argument: 'If creating or updating a team, this should be the description' +
+          ' for the team. If applying for or leaving a team, this should be your ' +
+          "character's name"
       }
     }
   end
 
   def self.cmd
-    desc = "Rescue Teams: view, create, update, join or leave teams"
+    desc = 'Rescue Teams: view, create, update, join or leave teams'
 
     @cmd ||= Command.new(:team, desc, opts) do |event, team_name, action, desc|
       # Save author
@@ -29,19 +29,20 @@ class TeamCommand < BaseCommand
       # New Team Request
       when /create/i
         raise 'Team Already Exists' if Team.find_by(name: team_name)
+
         reply = []
 
         # Request Team to Admin
         reply.push(BotResponse.new(
-          destination: ENV['APP_CH'],
-          embed: create_request(team_name, desc),
-          reactions: Emoji::REQUEST
-        ))
+                     destination: ENV['APP_CH'],
+                     embed: create_request(team_name, desc),
+                     reactions: Emoji::REQUEST
+                   ))
 
         # Sucess message to submitter
         reply.push(BotResponse.new(
-          embed: success_embed("Your request for a new team has been submitted for approval!")
-        ))
+                     embed: success_embed('Your request for a new team has been submitted for approval!')
+                   ))
 
       # Existing Team Update
       when /update/i
@@ -66,7 +67,7 @@ class TeamCommand < BaseCommand
 
         # Ensure if user is eligable
         if User.find(event.author.id).level < 5
-          error_embed("You are not high enough level!")
+          error_embed('You are not high enough level!')
 
         # Ensure team has open slots
         elsif CharTeam.where(team_id: team.id, active: true).count >= 6
@@ -83,15 +84,15 @@ class TeamCommand < BaseCommand
 
           # Request message to team
           reply.push(BotResponse.new(
-            destination: team.channel.to_i,
-            embed: join_request(char, member),
-            reactions: Emoji::REQUEST
-          ))
+                       destination: team.channel.to_i,
+                       embed: join_request(char, member),
+                       reactions: Emoji::REQUEST
+                     ))
 
           # Success message to sumbitter
           reply.push(BotResponse.new(
-            embed: success_embed("Your request was sent to #{team.name}!")
-          ))
+                       embed: success_embed("Your request was sent to #{team.name}!")
+                     ))
 
           reply
         end
@@ -108,7 +109,7 @@ class TeamCommand < BaseCommand
         # Response indicates if user needs a role removed
         case team.leave(char)
         when Embed
-          error_embed("Character not in Team!")
+          error_embed('Character not in Team!')
         when true
           user = event.server.member(char.user_id.to_i)
           user.remove_role(team.role.to_i)
@@ -125,7 +126,7 @@ class TeamCommand < BaseCommand
             text: "#{char.name} has left the team"
           )
         else
-          error_embed("Something Went Wrong!")
+          error_embed('Something Went Wrong!')
         end
 
       # Disband Team
@@ -139,7 +140,7 @@ class TeamCommand < BaseCommand
 
         # Delete Role and archive channel
         event.server.role(team.role).delete('Archived Team')
-        event.channel.category=(ENV['TEAM_ARCHIVES'])
+        event.channel.category = (ENV['TEAM_ARCHIVES'])
 
         success_embed("Successfully Archived #{team.name}")
 
@@ -148,23 +149,23 @@ class TeamCommand < BaseCommand
         team = Team.find_by!('name ilike ?', team_name) if team_name
         team_name ? team_embed(team) : teams_embed
       else
-        command_error_embed("Could not process team request!", team)
+        command_error_embed('Could not process team request!', team)
       end
 
     rescue ActiveRecord::RecordNotFound => e
-      error_embed("Record Not Found!", e.message)
+      error_embed('Record Not Found!', e.message)
     rescue StandardError => e
       error_embed(e.message)
     end
   end
 
-  def self.example_command(event=nil)
+  def self.example_command(_event=nil)
     sample_team = [
-      [ 'Hotel California', "You can checkout any time you like, but you can never leave~" ],
-      [ 'The Jungle Team', "We've got fun and games. We've got everything you want!" ],
-      [ 'Team Sudden Stop', "We are a great team full of many young adventures just looking for a g-" ],
-      [ 'Little Nightmares', "Come play with us! *Forever, and ever and e v e r . . ." ],
-      [ 'Puppo Pals', "Bork bork! Woof?" ]
+      ['Hotel California', 'You can checkout any time you like, but you can never leave~'],
+      ['The Jungle Team', "We've got fun and games. We've got everything you want!"],
+      ['Team Sudden Stop', 'We are a great team full of many young adventures just looking for a g-'],
+      ['Little Nightmares', 'Come play with us! *Forever, and ever and e v e r . . .'],
+      ['Puppo Pals', 'Bork bork! Woof?']
     ].sample
 
     case ['', 'team', 'create', 'update', 'apply', 'leave'].sample

+ 3 - 3
app/controllers/bot_controller.rb

@@ -8,7 +8,7 @@ class BotController
     when BotResponse
       response.call(event, bot)
     when Embed
-      event.send_embed("", response)
+      event.send_embed('', response)
     when String
       event.respond(response)
     end
@@ -32,8 +32,8 @@ class BotController
     member = event.server.member(user_id)
 
     embed = Embed.new(
-      title: "You have too many characters!",
-      description: "Please deactivate and try again " +
+      title: 'You have too many characters!',
+      description: 'Please deactivate and try again ' +
       "[here](#{Url::CHARACTER}#{edit_url})"
     )
 

+ 5 - 9
app/controllers/character_controller.rb

@@ -2,7 +2,7 @@ class CharacterController
   def self.edit_character(params)
     char_hash = Character.from_form(params)
 
-    if character = Character.find_by(edit_url: char_hash["edit_url"])
+    if character = Character.find_by(edit_url: char_hash['edit_url'])
       character.update(char_hash)
       character.reload
     else
@@ -18,8 +18,8 @@ class CharacterController
 
     # Nothing to check if the character is public, already active, or not a PC
     return true if app.description.match(/(public|server)/i) ||
-      Character.find_by(edit_url: app.footer.text)&.active == 'Active' ||
-      !app.title.match('Personal Character')
+                   Character.find_by(edit_url: app.footer.text)&.active == 'Active' ||
+                   !app.title.match('Personal Character')
 
     # Save the user id, and find the db user, and discord member
     user_id = UID.match(app.description)
@@ -28,13 +28,9 @@ class CharacterController
 
     # Count the active characters, and subtract from their allowed max
     chars = Character.where(active: 'Active', user_id: user.id).count
-    if user.allowed_chars(member) - chars > 0
-      true
-    else
-      false
-    end
+    user.allowed_chars(member) - chars > 0
   rescue ActiveRecord::RecordNotFound => e
-    error_embed("Record not Found!", e.message)
+    error_embed('Record not Found!', e.message)
   rescue StandardError => e
     error_embed(e.message)
   end

+ 3 - 3
app/controllers/dice_controller.rb

@@ -8,7 +8,7 @@ class DiceController
       # Create array to save each roll
       results = []
       die[:number].times do
-        results.push(rand(1 .. die[:sides]))
+        results.push(rand(1..die[:sides]))
       end
 
       # Return results array
@@ -23,7 +23,7 @@ class DiceController
     if die_array.nil?
       # Create
       DieArray.create(name: die, sides: array)
-      success_embed("Created #{die}: #{array.join(", ")}")
+      success_embed("Created #{die}: #{array.join(', ')}")
     elsif array.include?(/delete/i)
       # Destroy
       die_array.destroy
@@ -32,7 +32,7 @@ class DiceController
       # Update
       die_array.update(sides: array)
       die_array.reload
-      success_embed("Updated #{die}: #{array.join(", ")}")
+      success_embed("Updated #{die}: #{array.join(', ')}")
     end
   end
 end

+ 1 - 1
app/controllers/fable_controller.rb

@@ -2,7 +2,7 @@ class FableController
   def self.edit_fable(params)
     f_hash = Fable.from_form(params)
 
-    fable = Fable.find_by(edit_url: f_hash["edit_url"])
+    fable = Fable.find_by(edit_url: f_hash['edit_url'])
     if fable
       fable.update(f_hash)
       fable.reload

+ 16 - 13
app/controllers/image_controller.rb

@@ -2,8 +2,8 @@ class ImageController
   def self.default_image(url, char_id, rating)
     image = CharImage.where(char_id: char_id).find_by(keyword: 'Default')
 
-    if url == nil
-      image.destroy if image
+    if url.nil?
+      image&.destroy
       return
     end
 
@@ -21,8 +21,8 @@ class ImageController
 
   def self.edit_image(params)
     img_hash = CharImage.from_form(params)
-    char_id = img_hash["char_id"]
-    keyword = img_hash["keyword"]
+    char_id = img_hash['char_id']
+    keyword = img_hash['keyword']
 
     img = CharImage.where(char_id: char_id).find_by(keyword: keyword)
 
@@ -36,18 +36,21 @@ class ImageController
     img
   end
 
-  def self.img_scroll(char_id: , nsfw: false, img: nil, dir: nil)
-    imgs = nsfw ? CharImage.where(char_id: char_id) :
-      CharImage.where(char_id: char_id, category: 'SFW' )
+  def self.img_scroll(char_id:, nsfw: false, img: nil, dir: nil)
+    imgs = if nsfw
+             CharImage.where(char_id: char_id)
+           else
+             CharImage.where(char_id: char_id, category: 'SFW')
+           end
 
     cur_i = img ? imgs.index { |i| i[:id] == img } : imgs.length - 1
 
-    case dir
-    when :left
-      nex_i = cur_i == 0 ? imgs.length - 1 : cur_i - 1
-    else
-      nex_i = cur_i == imgs.length - 1 ? 0 : cur_i + 1
-    end
+    nex_i = case dir
+            when :left
+              cur_i == 0 ? imgs.length - 1 : cur_i - 1
+            else
+              cur_i == imgs.length - 1 ? 0 : cur_i + 1
+            end
 
     imgs[nex_i]
   end

+ 1 - 1
app/controllers/inventory_controller.rb

@@ -20,7 +20,7 @@ class InventoryController
       character_embed(character: character, event: event, section: :bags)
     elsif new_amount < 0
       # Error
-      error_embed("Error!", "Negative total #{item.name} result")
+      error_embed('Error!', "Negative total #{item.name} result")
     end
   end
 end

+ 1 - 1
app/controllers/item_controller.rb

@@ -2,7 +2,7 @@ class ItemController
   def self.edit_item(app)
     item_hash = Item.from_form(app)
 
-    if item = Item.find_by(edit_url: item_hash["edit_url"])
+    if item = Item.find_by(edit_url: item_hash['edit_url'])
       item.update(item_hash)
       item.reload
     else

+ 1 - 1
app/controllers/landmark_controller.rb

@@ -2,7 +2,7 @@ class LandmarkController
   def self.edit_landmark(params)
     lm_hash = Landmark.from_form(params)
 
-    if lm = Landmark.find_by(edit_url: lm_hash["edit_url"])
+    if lm = Landmark.find_by(edit_url: lm_hash['edit_url'])
       lm.update(lm_hash)
       lm.reload
     else

+ 3 - 1
app/controllers/status_controller.rb

@@ -40,6 +40,7 @@ class StatusController
 
       if char_status && status.amount
         raise 'Amount must be a number' if amount == 0
+
         # Update row
         new_amount = char_status.amount + amount
 
@@ -55,6 +56,7 @@ class StatusController
         raise 'Character already has status'
       else
         raise 'Character did not have status' if amount.to_i < 0
+
         # Create new row
         CharStatus.create(
           char_id: character.id,
@@ -65,7 +67,7 @@ class StatusController
     end
   end
 
-  def update_or_create(status, name, desc, amount)
+  def update_or_create(status, name, _desc, _amount)
     # Create or Update
     if status
       status.update(effect: effect, amount: true)

+ 17 - 17
app/controllers/user_controller.rb

@@ -1,19 +1,19 @@
 class UsersController
   def self.stat_image(user, member, stats=nil)
-    size_width = 570;
-    size_height = 376;
-    stats_frame =  "images/LevelUp.png"
-    level_up = "images/LevelUpFont.png"
-    user_url_img = "images/Image_Builder/user_url_img.png"
-    output_file =  "images/Image_Builder/LevelUp"
+    size_width = 570
+    size_height = 376
+    stats_frame = 'images/LevelUp.png'
+    level_up = 'images/LevelUpFont.png'
+    user_url_img = 'images/Image_Builder/user_url_img.png'
+    output_file =  'images/Image_Builder/LevelUp'
 
     begin
       Down.download(member.avatar_url, destination: user_url_img)
     rescue Down::NotFound
-      user_url_img = "images/Image_Builder/unknown_img.png"
+      user_url_img = 'images/Image_Builder/unknown_img.png'
     end
 
-    #Gif Destroyer
+    # Gif Destroyer
     i = Magick::ImageList.new(user_url_img)
     i[0].write(user_url_img) if i.count > 1
 
@@ -41,14 +41,14 @@ class UsersController
       )
     end
 
-    last_level = user.level == 1 ? 0 : ((user.level + 4) **3) / 10.0
+    last_level = user.level == 1 ? 0 : ((user.level + 4)**3) / 10.0
     this_level = user.next_level - last_level
     ratio = 1 - ((user.next_level - user.boosted_xp).to_f / this_level)
 
     user_name = member.nickname || member.name
     short_name = user_name.length > 15 ? "#{user_name[0..14]}..." : user_name
     rank = User.order(unboosted_xp: :desc)
-    user_rank = rank.index{ |r| r.id == user.id } + 1
+    user_rank = rank.index { |r| r.id == user.id } + 1
 
     gc = Draw.new
 
@@ -59,16 +59,16 @@ class UsersController
 
     gc.stroke('none').fill('black')
     gc.pointsize('15')
-    gc.text(15,25, short_name)
+    gc.text(15, 25, short_name)
     gc.text(40, 45, "Lv.#{user.level}")
     gc.text(15, 290, "Rank: #{user_rank}")
     gc.text(40, 65, "Exp: #{user.boosted_xp}")
 
     gc.stroke('white').fill('white')
     gc.pointsize('30')
-    gc.text(40,330, user_name)
-    gc.text(40,360, "reached level #{user.level}!") if stats
-    gc.text(40,360, "is level #{user.level}!") if !stats
+    gc.text(40, 330, user_name)
+    gc.text(40, 360, "reached level #{user.level}!") if stats
+    gc.text(40, 360, "is level #{user.level}!") unless stats
 
     if stats
       gc.stroke('none').fill('black')
@@ -82,10 +82,10 @@ class UsersController
 
       gc.stroke('none').fill('maroon')
       gc.text(505, 97, "+ #{stats['hp'] - user.hp}")
-      gc.text(505, 127, "+ #{stats['attack']- user.attack}")
+      gc.text(505, 127, "+ #{stats['attack'] - user.attack}")
       gc.text(505, 159, "+ #{stats['defense'] - user.defense}")
       gc.text(505, 191, "+ #{stats['sp_attack'] - user.sp_attack}")
-      gc.text(505, 222, "+ #{stats['sp_defense']- user.sp_defense}")
+      gc.text(505, 222, "+ #{stats['sp_defense'] - user.sp_defense}")
       gc.text(505, 255, "+ #{stats['speed'] - user.speed}")
     else
       gc.stroke('none').fill('black')
@@ -113,6 +113,6 @@ class UsersController
       ghosts.push("<@#{u.id}>") if event.server.member(u.id).nil?
     end
 
-    Embed.new(title: "Ghost Members", description: ghosts.join(", "))
+    Embed.new(title: 'Ghost Members', description: ghosts.join(', '))
   end
 end

+ 5 - 5
app/embeds/app.rb

@@ -1,8 +1,8 @@
 def new_app_request(user, app_type)
   embed = Embed.new(
-    title: "New Appliction!",
+    title: 'New Appliction!',
     description: "Hi, #{user.nickname || user.name},\nI see you'd like to " +
-      "start a new #{app_type.to_s} application!\nI'll DM you instructions!"
+      "start a new #{app_type} application!\nI'll DM you instructions!"
   )
 
   embed.color = user.color.combined if user.color
@@ -19,13 +19,13 @@ def new_app_form(user, app_type)
 
   embed = Embed.new(
     title: "Hi, #{user.nickname || user.name}",
-    description: "If you have any questions, feel free to ask a Guildmaster!",
+    description: 'If you have any questions, feel free to ask a Guildmaster!',
     footer: {
       text: "If you cannot copy your key, press the #{Emoji::PHONE}"
     },
     fields: [
-      { name: "Please start your application here:", value: url },
-      { name: "Your key is:", value: user.id }
+      { name: 'Please start your application here:', value: url },
+      { name: 'Your key is:', value: user.id }
     ]
   )
 

+ 1 - 1
app/embeds/application_responses.rb

@@ -9,7 +9,7 @@ end
 
 def too_many(event, user, edit_url, model)
   message = "You have too many #{model}!" +
-    "\nPlease deactivate and try again #{Url::CHARACTER}#{edit_url}"
+            "\nPlease deactivate and try again #{Url::CHARACTER}#{edit_url}"
 
   event.server.member(user).dm(message)
   event.respond(message)

+ 167 - 120
app/embeds/character.rb

@@ -1,11 +1,14 @@
 def character_embed(character:, event:, section: nil, image: nil)
   # Find the author, if they're a member, or in DMs use the event's author
-  if event.server
-    member = character.user_id.match(/public/i) ? 'Public' :
-      event.server.member(character.user_id)
-  else
-    member = event.author
-  end
+  member = if event.server
+             if character.user_id.match(/public/i)
+               'Public'
+             else
+               event.server.member(character.user_id)
+             end
+           else
+             event.author
+           end
   fields = []
 
   embed = Embed.new(
@@ -39,17 +42,19 @@ def character_embed(character:, event:, section: nil, image: nil)
   when /rumors?/i
     fields = char_rumors(character, fields)
   when /images?/i
-    image = image ? image : default_img
+    image ||= default_img
     if image
-      embed.title =
-        "#{character.name} | #{image.keyword}" unless image.keyword == 'Default'
+      unless image.keyword == 'Default'
+        embed.title =
+          "#{character.name} | #{image.keyword}"
+      end
       embed.image = { url: image.url }
 
       # Replace the rating with the image's rating
       footer_info.pop
       footer_info.push(image.category)
     else
-      embed.description = "No character images found!"
+      embed.description = 'No character images found!'
     end
 
     # Remove default image
@@ -71,30 +76,46 @@ def char_bio(char, fields)
   char_teams = CharTeam.where(char_id: char.id, active: true).map(&:team_id)
   teams = Team.where(id: char_teams).map(&:name)
 
-  fields.push(
-    { name: 'Hometown', value: char.hometown, inline: true }
-  )if char.hometown
-  fields.push(
-    { name: 'Location', value: char.location, inline: true }
-  )if char.location
-  fields.push(
-    { name: 'Likes', value: char.likes }
-  )if char.likes
-  fields.push(
-    { name: 'Dislikes', value: char.dislikes }
-  )if char.dislikes
-  fields.push(
-    { name: 'Backstory', value: char.backstory }
-  )if char.backstory
-  fields.push(
-    { name: 'Recent Events', value: char.recent_events }
-  )if char.recent_events
-  fields.push(
-    { name: 'Other', value: char.other }
-  )if char.other
-  fields.push(
-    { name: 'Team', value: teams.join("\n") }
-  )if !teams.empty?
+  if char.hometown
+    fields.push(
+      { name: 'Hometown', value: char.hometown, inline: true }
+    )
+  end
+  if char.location
+    fields.push(
+      { name: 'Location', value: char.location, inline: true }
+    )
+  end
+  if char.likes
+    fields.push(
+      { name: 'Likes', value: char.likes }
+    )
+  end
+  if char.dislikes
+    fields.push(
+      { name: 'Dislikes', value: char.dislikes }
+    )
+  end
+  if char.backstory
+    fields.push(
+      { name: 'Backstory', value: char.backstory }
+    )
+  end
+  if char.recent_events
+    fields.push(
+      { name: 'Recent Events', value: char.recent_events }
+    )
+  end
+  if char.other
+    fields.push(
+      { name: 'Other', value: char.other }
+    )
+  end
+  unless teams.empty?
+    fields.push(
+      { name: 'Team', value: teams.join("\n") }
+    )
+  end
 
   fields
 end
@@ -102,12 +123,16 @@ end
 def char_type(char, fields)
   sp = char.shiny ? "#{char.species} #{Emoji::STAR}" : char.species
 
-  fields.push(
-    { name: 'Species', value: sp, inline: true }
-  )if char.species
-  fields.push(
-    { name: 'Type', value: char.types, inline: true }
-  )if char.types
+  if char.species
+    fields.push(
+      { name: 'Species', value: sp, inline: true }
+    )
+  end
+  if char.types
+    fields.push(
+      { name: 'Type', value: char.types, inline: true }
+    )
+  end
 
   if char.attacks
     attacks = char.attacks
@@ -120,9 +145,11 @@ def char_type(char, fields)
 end
 
 def char_rumors(char, fields)
-  fields.push(
-    { name: 'Warnings', value: char.warnings }
-  )if char.warnings
+  if char.warnings
+    fields.push(
+      { name: 'Warnings', value: char.warnings }
+    )
+  end
 
   if char.rumors
     rumors = char.rumors.split(/\s?\|\s?/)
@@ -139,24 +166,36 @@ def char_status(char, fields, status_effects=nil)
   # Find any status effects on the character
   status_effects = CharStatus.where(char_id: char.id)
 
-  fields.push(
-    { name: 'Age', value: char.age, inline: true }
-  )if char.age
-  fields.push(
-    { name: 'Gender', value: char.gender, inline: true }
-  )if char.gender
-  fields.push(
-    { name: 'Weight', value: char.weight, inline: true }
-  )if char.weight
-  fields.push(
-    { name: 'Height', value: char.height, inline: true }
-  )if char.height
-  fields.push(
-    { name: 'Sexual Orientation', value: char.orientation, inline: true }
-  )if char.orientation
-  fields.push(
-    { name: 'Relationship Status', value: char.relationship, inline: true }
-  )if char.relationship
+  if char.age
+    fields.push(
+      { name: 'Age', value: char.age, inline: true }
+    )
+  end
+  if char.gender
+    fields.push(
+      { name: 'Gender', value: char.gender, inline: true }
+    )
+  end
+  if char.weight
+    fields.push(
+      { name: 'Weight', value: char.weight, inline: true }
+    )
+  end
+  if char.height
+    fields.push(
+      { name: 'Height', value: char.height, inline: true }
+    )
+  end
+  if char.orientation
+    fields.push(
+      { name: 'Sexual Orientation', value: char.orientation, inline: true }
+    )
+  end
+  if char.relationship
+    fields.push(
+      { name: 'Relationship Status', value: char.relationship, inline: true }
+    )
+  end
 
   afs = []
   status_effects.each do |se|
@@ -168,9 +207,11 @@ def char_status(char, fields, status_effects=nil)
     end
   end
 
-  fields.push(
-    { name: "Current Afflictions", value: afs.join("\n") }
-  )unless afs.empty?
+  unless afs.empty?
+    fields.push(
+      { name: 'Current Afflictions', value: afs.join("\n") }
+    )
+  end
 
   fields
 end
@@ -182,7 +223,7 @@ def char_inv(char, fields)
 
   # Show formatted items
   value = bags.empty? ? "#{char.name} doesn't have any items" : bags.join("\n")
-  fields.push({ name: "Bags", value: value })
+  fields.push({ name: 'Bags', value: value })
 
   fields
 end
@@ -190,9 +231,11 @@ end
 def char_dm_notes(char, fields, event)
   return fields unless ENV['DM_CH'].include?(event.channel.id.to_s)
 
-  fields.push(
-    { name: 'DM Notes', value: char.dm_notes }
-  )if char.dm_notes
+  if char.dm_notes
+    fields.push(
+      { name: 'DM Notes', value: char.dm_notes }
+    )
+  end
 
   fields
 end
@@ -204,37 +247,39 @@ def char_list_embed(chars, group, sort = nil)
   case group
   when /active/i
     title = "Registered Guild Members -- [#{chars.count}]"
-    desc = "These are the pokemon registered to the guild, sorted by primary type"
+    desc = 'These are the pokemon registered to the guild, sorted by primary type'
   when /archived/i
     title = "Archived Guild Members -- [#{chars.count}]"
-    desc = "These are the pokemon in the guild archives, sorted by primary type"
+    desc = 'These are the pokemon in the guild archives, sorted by primary type'
   when /npc/i
     title = "Registered Guild NPCs -- [#{chars.length}]"
-    desc = "These are the NPCs from all around Zaplana, sorted by current location"
+    desc = 'These are the NPCs from all around Zaplana, sorted by current location'
   when /special/i
     title = "Special Characters -- [#{chars.count}]"
-    desc = "These are the special pokemon around Zaplana, sorted by category"
+    desc = 'These are the special pokemon around Zaplana, sorted by category'
   end
 
   case sort&.first
   when Type
     sort.each do |s|
       list[s.name] = chars.map do |c|
-        next unless c.types.split("/").first === s.name
+        next unless c.types.split('/').first === s.name
+
         name = c.name
         name = "|| #{name} ||" if c.rating&.match(/NSFW/i)
         name
       end.compact
     end
 
-    list = list.reject { |k,v| v == [] }
-    list.each do |k,v|
-      fields.push({ name: k, value: v.join(", ") })
+    list = list.reject { |_k, v| v == [] }
+    list.each do |k, v|
+      fields.push({ name: k, value: v.join(', ') })
     end
   when Region
     sort.each do |s|
       list[s.name] = chars.map do |c|
         next unless c.region == s.name
+
         name = c.name
         name = "*#{name}*" if c.user_id.match(/public/i)
         name = "|| #{name} ||" if c.rating&.match(/NSFW/i)
@@ -242,58 +287,56 @@ def char_list_embed(chars, group, sort = nil)
       end.compact
     end
 
-
-    list["Unknown"] = chars.map do |c|
+    list['Unknown'] = chars.map do |c|
       next unless c.region.nil?
+
       name = c.name
       name = "*#{name}*" if c.user_id.match(/public/i)
       name = "|| #{name} ||" if c.rating&.match(/NSFW/i)
       name
     end.compact
 
-    list = list.reject { |k,v| v == [] }
-    list.each do |k,v|
-      fields.push({ name: k, value: v.join(", ") })
+    list = list.reject { |_k, v| v == [] }
+    list.each do |k, v|
+      fields.push({ name: k, value: v.join(', ') })
     end
   when nil
-    list["guild"] = []
-    list["adoptable"] = []
-    list["legend"] = []
+    list['guild'] = []
+    list['adoptable'] = []
+    list['legend'] = []
 
     chars.each do |c|
       case c.special
       when /legend/i
-        list["legend"].push("#{c.name}, #{c.species} -- last seen: #{c.location || "???"}")
+        list['legend'].push("#{c.name}, #{c.species} -- last seen: #{c.location || '???'}")
       when /guild/i
-        list["guild"].push("#{c.name}, #{c.species}")
+        list['guild'].push("#{c.name}, #{c.species}")
       else
-        list["adoptable"].push("#{c.name}, #{c.species} -- #{c.location || "???"}")
+        list['adoptable'].push("#{c.name}, #{c.species} -- #{c.location || '???'}")
       end
     end
 
-    list = list.reject { |k,v| v == [] }
-    list.each do |k,v|
+    list = list.reject { |_k, v| v == [] }
+    list.each do |k, v|
       case k
       when /legend/i
-        fields.push({ name: "Mythic/Legend Pokemon", value: v.join("\n") })
+        fields.push({ name: 'Mythic/Legend Pokemon', value: v.join("\n") })
       when /guild/i
-        fields.push({ name: "Guild Employees", value: v.join("\n") })
+        fields.push({ name: 'Guild Employees', value: v.join("\n") })
       when /adoptable/i
-        fields.push({ name: "Adoptable NPCs", value: v.join("\n") })
+        fields.push({ name: 'Adoptable NPCs', value: v.join("\n") })
       end
     end
   end
 
-  if fields.empty?
-    fields.push({name: "No Resulst", value: "--"})
-  end
+  fields.push({ name: 'No Resulst', value: '--' }) if fields.empty?
 
   Embed.new(
     title: title,
     description: desc,
     fields: fields,
     footer: {
-      text: "React to Navigate | 1. Active | 2. Archived | 3. NPCs | 4. Special"
+      text: 'React to Navigate | 1. Active | 2. Archived | 3. NPCs | 4. Special'
     }
   )
 end
@@ -303,7 +346,7 @@ def user_char_embed(chars, member, nsfw=nil)
   active = []
   archived = []
   npcs = []
-  user_name = member&.nickname || member&.name || "Unknown User"
+  user_name = member&.nickname || member&.name || 'Unknown User'
 
   chars.each do |char|
     case char.active
@@ -317,31 +360,32 @@ def user_char_embed(chars, member, nsfw=nil)
   end
 
   active.each.with_index do |char, i|
-    name = nsfw && char.rating == 'NSFW' ?
-      "#{i+1} || #{char.name} ||" : "#{i+1} #{char.name}"
+    name = if nsfw && char.rating == 'NSFW'
+             "#{i + 1} || #{char.name} ||"
+           else
+             "#{i + 1} #{char.name}"
+           end
     fields.push({
-      name: name,
-      value: "#{char.species} -- #{char.types}"
-    })
+                  name: name,
+                  value: "#{char.species} -- #{char.types}"
+                })
   end
 
   unless archived.empty?
     fields.push({
-      name: "#{user_name}'s Archived Characters",
-      value: archived.join(", ")
-    })
+                  name: "#{user_name}'s Archived Characters",
+                  value: archived.join(', ')
+                })
   end
 
-  unless npcs.empty?
-    fields.push({ name: "#{user_name}'s NPCs", value: npcs.join(", ") })
-  end
+  fields.push({ name: "#{user_name}'s NPCs", value: npcs.join(', ') }) unless npcs.empty?
 
   # Find allowed active characters
   allowed = member ? User.find(member.id.to_s).allowed_chars(member) : '???'
 
   embed = Embed.new(
     title: "#{user_name}'s Characters [#{active.count}/#{allowed}]",
-    description: "Click on the corresponding reaction to view the character",
+    description: 'Click on the corresponding reaction to view the character',
     fields: fields
   )
 
@@ -354,29 +398,32 @@ def dup_char_embed(chars, name)
 
   chars.each.with_index do |char, i|
     fields.push({
-      name: "#{Emoji::NUMBERS[i]}: #{char.species}",
-      value: "Created by <@#{char.user_id}>"
-    })
+                  name: "#{Emoji::NUMBERS[i]}: #{char.species}",
+                  value: "Created by <@#{char.user_id}>"
+                })
   end
 
   Embed.new(
     title: "Which #{name}?",
-    description: "Click on the corresponding reaction to pick",
+    description: 'Click on the corresponding reaction to pick',
     fields: fields
   )
 end
 
 def image_list_embed(character, event)
   # Find the author, if they're a member, or in DMs use the event's author
-  if event.server
-    member = character.user_id.match(/public/i) ? 'Public' :
-      event.server.member(character.user_id)
-  else
-    member = event.author
-  end
+  member = if event.server
+             if character.user_id.match(/public/i)
+               'Public'
+             else
+               event.server.member(character.user_id)
+             end
+           else
+             event.author
+           end
   # Grab an array of the character's images
   images = CharImage.where(char_id: character.id).
-    map{ |i| "[#{i.keyword}](#{i.url})" }
+           map { |i| "[#{i.keyword}](#{i.url})" }
 
   # Create Embed
   embed = Embed.new(

+ 3 - 3
app/embeds/dice.rb

@@ -5,12 +5,12 @@ def dice_list
 
   # Insert each die into a field
   dice.each do |die|
-    fields.push({ name: die.name, value: die.sides.join(", ") })
+    fields.push({ name: die.name, value: die.sides.join(', ') })
   end
 
   # Create Embed
   embed = Embed.new(
-    title: "Available Dice",
+    title: 'Available Dice'
   )
 
   # Update with fields, or a message of no dice, and reply
@@ -51,7 +51,7 @@ def fill_result_fields(results, embed)
   fields = []
 
   results.each do |r|
-    fields.push({ name: 'Result', value: "#{r}", inline: true })
+    fields.push({ name: 'Result', value: r.to_s, inline: true })
   end
 
   embed.fields = fields

+ 1 - 1
app/embeds/fable.rb

@@ -4,7 +4,7 @@ def fable_embed(fable, event)
 
   embed = Embed.new(
     title: fable.title,
-    description: fable.story,
+    description: fable.story
   )
 
   embed.image = { url: fable.url } if fable.url

+ 12 - 12
app/embeds/global.rb

@@ -1,18 +1,18 @@
-UNKNOWN_USER_IMG = "https://i.imgur.com/oRJwgRa.png"
-ADOPT_IMG = "https://i.imgur.com/2u0fNd2.png"
+UNKNOWN_USER_IMG = 'https://i.imgur.com/oRJwgRa.png'.freeze
+ADOPT_IMG = 'https://i.imgur.com/2u0fNd2.png'.freeze
 
-SUCCESS_GREEN = "#6bc037"
-ERROR_RED = "#c42d2d"
+SUCCESS_GREEN = '#6bc037'.freeze
+ERROR_RED = '#c42d2d'.freeze
 
 def author_footer(embed, author, info=[])
   # Select the proper text and image for the author
   # .unshift places the argument at the beginning of an array
   img = case author
         when /Public/i
-          info.unshift("Adopt Me!")
+          info.unshift('Adopt Me!')
           ADOPT_IMG
         when nil
-          info.unshift("Unknown User")
+          info.unshift('Unknown User')
           UNKNOWN_USER_IMG
         else
           info.unshift("#{author.name}##{author.tag}")
@@ -21,7 +21,7 @@ def author_footer(embed, author, info=[])
 
   # Update the footer with the appropriate information
   embed.footer = {
-    text: info.compact.join(" | "),
+    text: info.compact.join(' | '),
     icon_url: img
   }
 
@@ -32,7 +32,7 @@ def message_embed(title, desc, img = nil)
   embed = Embed.new(
     title: title,
     description: desc,
-    color: SUCCESS_GREEN,
+    color: SUCCESS_GREEN
   )
 
   embed.thumbnail = { url: img } if img
@@ -41,11 +41,11 @@ end
 
 def success_embed(message)
   Embed.new(
-    title: "Hooray!",
+    title: 'Hooray!',
     description: message,
     color: SUCCESS_GREEN,
     footer: {
-      text: "High Five!"
+      text: 'High Five!'
     }
   )
 end
@@ -55,7 +55,7 @@ def error_embed(title, message = nil)
     title: title,
     color: ERROR_RED,
     footer: {
-      text: "For more help, feel free to ask a Moderator or Guildmaster"
+      text: 'For more help, feel free to ask a Moderator or Guildmaster'
     }
   )
 
@@ -65,7 +65,7 @@ end
 
 def generic_error(message)
   Embed.new(
-    title: "Error",
+    title: 'Error',
     description: message,
     color: ERROR_RED
   )

+ 27 - 26
app/embeds/help.rb

@@ -1,9 +1,9 @@
-HELP_BLUE = "#4976ca"
+HELP_BLUE = '#4976ca'.freeze
 
 def command_list_embed(commands, restriction = nil)
   fields = []
-  desc = "To learn more about any of the listed commands," +
-    " use `pkmn-help [command]`"
+  desc = 'To learn more about any of the listed commands,' +
+         ' use `pkmn-help [command]`'
 
   commands.each do |cmd|
     fields.push({name: "pkmn-#{cmd.name}", value: cmd.cmd.description})
@@ -11,15 +11,14 @@ def command_list_embed(commands, restriction = nil)
 
   case restriction
   when :pm
-    title = "PM Commands"
+    title = 'PM Commands'
     desc = "Can only be used in a PM with <@639191920786276378> \n" +
-      "To learn more about any of the listed commands, use `pkmn-help [command]`"
+           'To learn more about any of the listed commands, use `pkmn-help [command]`'
 
-  else
   end
 
   Embed.new(
-    title: title || "Commands",
+    title: title || 'Commands',
     description: desc,
     color: HELP_BLUE,
     fields: fields
@@ -31,7 +30,7 @@ def command_help(command, event)
     title: command.to_s.gsub('Command', ' Command'),
     description: command.cmd.description,
     color: HELP_BLUE,
-    footer: { text: "For more help, ask a Guild Master!" }
+    footer: { text: 'For more help, ask a Guild Master!' }
   )
 
   # Apply options, if there are any
@@ -51,26 +50,28 @@ def command_usage(command, event)
   fields = []
 
   # Add navigation information, if there is any
-  fields.push({
-    name: "Reaction Navigation",
-    value: opts[:nav].map{ |k,v| "#{v[0]} - `#{k}` - #{v[1]}" }.join("\n")
-  }) if opts[:nav]
+  if opts[:nav]
+    fields.push({
+                  name: 'Reaction Navigation',
+                  value: opts[:nav].map { |k, v| "#{v[0]} - `#{k}` - #{v[1]}" }.join("\n")
+                })
+  end
 
   # Save the command with its options, and the option instructions
-  structure = "```pkmn-#{command.name} #{opts[:usage].map{ |k,v| k }.join(' | ')}```"
-  instructions = opts[:usage].map{ |k,v| "- `#{k}` -- #{v}" }.join("\n")
+  structure = "```pkmn-#{command.name} #{opts[:usage].map { |k, _v| k }.join(' | ')}```"
+  instructions = opts[:usage].map { |k, v| "- `#{k}` -- #{v}" }.join("\n")
 
   # Add usage information
   fields.push({
-    name: "Command Usage",
-    value: "#{structure}\n#{instructions}"
-  })
+                name: 'Command Usage',
+                value: "#{structure}\n#{instructions}"
+              })
 
   # Add an example command
   fields.push({
-    name: "Example",
-    value: "```pkmn-#{command.name} #{example.join(' | ')}```"
-  })
+                name: 'Example',
+                value: "```pkmn-#{command.name} #{example.join(' | ')}```"
+              })
 end
 
 def admin_options(command, fields)
@@ -79,14 +80,14 @@ def admin_options(command, fields)
   return fields unless r_opts
 
   # Save the command with its options, and the option instructions
-  structure = "```pkmn-#{command.name} #{r_opts[:usage].map{ |k,v| k }.join(' | ')}```"
-  instructions = r_opts[:usage].map{ |k,v| "- `#{k}` -- #{v}" }.join("\n")
+  structure = "```pkmn-#{command.name} #{r_opts[:usage].map { |k, _v| k }.join(' | ')}```"
+  instructions = r_opts[:usage].map { |k, v| "- `#{k}` -- #{v}" }.join("\n")
 
   # Add usage information
   fields.push({
-    name: "Administrator Options",
-    value: "#{structure}\n#{instructions}"
-  })
+                name: 'Administrator Options',
+                value: "#{structure}\n#{instructions}"
+              })
 
   fields
 end
@@ -96,7 +97,7 @@ def command_error(title, command, event=nil)
     title: title,
     description: command.cmd.description,
     color: ERROR_RED,
-    footer: { text: "For more help, ask a Guild Master!" }
+    footer: { text: 'For more help, ask a Guild Master!' }
   )
 
   # Apply options, if there are any

+ 8 - 5
app/embeds/item.rb

@@ -1,19 +1,22 @@
 def item_embed(item, event)
   # Find the author, if they're a member, or in DMs use the event's author
-  member = item.user_id.match(/public/i) ? 'Public' :
-    event.server.member(item.user_id)
+  member = if item.user_id.match(/public/i)
+             'Public'
+           else
+             event.server.member(item.user_id)
+           end
   fields = []
 
   embed = Embed.new(
     title: item.name,
-    description: item.description,
+    description: item.description
   )
 
   embed.thumbnail = { url: item.url } if item.url
   author_footer(
     embed,
     member,
-    [item.category.join(", "), item.reusable ? 'Reusable' : 'Not Resuable']
+    [item.category.join(', '), item.reusable ? 'Reusable' : 'Not Resuable']
   )
 
   fields.push({ name: 'Effect', value: item.effect }) if item.effect
@@ -24,6 +27,6 @@ end
 def item_list
   Embed.new(
     title: 'Items',
-    description: Item.all.map(&:name).join(", ")
+    description: Item.all.map(&:name).join(', ')
   )
 end

+ 30 - 20
app/embeds/landmark.rb

@@ -1,4 +1,4 @@
-NO_GOLD = 'https://cdn.discordapp.com/attachments/645493256821669888/683732758199140387/fcece3957f27d25f9c7aee13a89b7e7c.png'
+NO_GOLD = 'https://cdn.discordapp.com/attachments/645493256821669888/683732758199140387/fcece3957f27d25f9c7aee13a89b7e7c.png'.freeze
 
 def landmark_embed(lm:, section: nil, event: nil)
   # Find the author, if they're a member
@@ -18,9 +18,11 @@ def landmark_embed(lm:, section: nil, event: nil)
   case section
   when /history/i, nil
     # Parent Landmark
-    fields.push(
-      { name: 'Location', value: Landmark.find(lm.location).name, inline: true }
-    ) if lm.location
+    if lm.location
+      fields.push(
+        { name: 'Location', value: Landmark.find(lm.location).name, inline: true }
+      )
+    end
 
     # Region
     fields.push(
@@ -36,36 +38,44 @@ def landmark_embed(lm:, section: nil, event: nil)
 
     # List Kinks, Show warning, or hide if needed
     fields.push({name: 'Kinks', value: lm.kink.join("\n")}) if lm.kink
-    fields.push(
-      {name: 'Warning', value: hide ? 'This warning is NSFW!' : lm.warning}
-    ) if lm.warning
+    if lm.warning
+      fields.push(
+        {name: 'Warning', value: hide ? 'This warning is NSFW!' : lm.warning}
+      )
+    end
 
     # Display appropriate image
     embed.thumbnail = { url: hide ? NO_GOLD : lm.w_url }
   when /map/i
     # Display map, if it exists
-    lm.map_url ?
-      embed.image = { url: lm.map_url } : embed.description = 'No Map Data'
+    if lm.map_url
+      embed.image = { url: lm.map_url }
+    else
+      embed.description = 'No Map Data'
+    end
 
     # Remove default image
     embed.thumbnail = nil
   when /layout/i
     # Display layout map, if it exists
-    lm.layout_url ?
-      embed.image = { url: lm.layout_url } : embed.description = 'No Layout Data'
+    if lm.layout_url
+      embed.image = { url: lm.layout_url }
+    else
+      embed.description = 'No Layout Data'
+    end
 
     # Remove default image
     embed.thumbnail = nil
   when /npcs?/i
     # Find NPCs in the landmark, case insensitive
     npcs = Character.where('location ilike ?', lm.name)
-      .map{ |npc| "#{npc.name} - #{npc.species}" }
+                    .map { |npc| "#{npc.name} - #{npc.species}" }
 
     # List NPCs that currently reside in this landmark
     fields.push({
-      name: 'NPC Residents',
-      value: npcs.empty? ? 'No known inhabitants' : npcs.join("\n")
-    })
+                  name: 'NPC Residents',
+                  value: npcs.empty? ? 'No known inhabitants' : npcs.join("\n")
+                })
   end
 
   # Update fields and return embed
@@ -80,7 +90,7 @@ def landmark_list
   Region.all.each do |r|
     # Fetch the all the Landmarks inside the region, then iterate
     landmarks = Landmark.where(region: r.id)
-    children, parents = landmarks.partition{ |lm| lm.location }
+    children, parents = landmarks.partition { |lm| lm.location }
     list = []
 
     parents.each do |p|
@@ -99,11 +109,11 @@ def landmark_list
 end
 
 def input_children(children, parent, list, level)
-  indent = "---"
+  indent = '---'
 
-  children.filter{ |c| c.location == parent.id }.each do |landmark|
-    list.push("#{indent*level}#{landmark.name}")
+  children.filter { |c| c.location == parent.id }.each do |landmark|
+    list.push("#{indent * level}#{landmark.name}")
 
-    input_children(children, landmark, list, level+1)
+    input_children(children, landmark, list, level + 1)
   end
 end

+ 23 - 23
app/embeds/poll.rb

@@ -1,23 +1,23 @@
-def new_poll(event, question, choices)
-  fields = []
-
-  choices.each.with_index do |c, i|
-    fields.push({
-      name: "#{Emoji::LETTERS[i]} #{c}",
-      value: CharApp::INLINE_SPACE,
-      inline: true
-    })
-  end
-
-  embed = Embed.new(
-    title:  question,
-    author: {
-      name: event.author.nickname || event.author.name,
-      icon_url: event.author.avatar_url
-    },
-    fields: fields
-  )
-
-  embed.color = event.author.color.combined if event.author.color
-  embed
-end
+def new_poll(event, question, choices)
+  fields = []
+
+  choices.each.with_index do |c, i|
+    fields.push({
+                  name: "#{Emoji::LETTERS[i]} #{c}",
+                  value: CharApp::INLINE_SPACE,
+                  inline: true
+                })
+  end
+
+  embed = Embed.new(
+    title: question,
+    author: {
+      name: event.author.nickname || event.author.name,
+      icon_url: event.author.avatar_url
+    },
+    fields: fields
+  )
+
+  embed.color = event.author.color.combined if event.author.color
+  embed
+end

+ 19 - 19
app/embeds/reject.rb

@@ -1,5 +1,5 @@
-MSG = "Please resubmit when you've addressed the issues!\n"
-FTR = "If you have any questions, feel free to ask a Guildmaster"
+MSG = "Please resubmit when you've addressed the issues!\n".freeze
+FTR = 'If you have any questions, feel free to ask a Guildmaster'.freeze
 
 def reject_app(app, opts)
   embed = Embed.new(
@@ -37,13 +37,13 @@ def reject_app(app, opts)
            end
 
   # Add one last field and update embed
-  fields.push({ name: Emoji::CHECK, value: "Indicates you are finished" })
+  fields.push({ name: Emoji::CHECK, value: 'Indicates you are finished' })
   embed.fields = fields
   embed
 end
 
 def reject_fields(message_hash)
-  message_hash.map{ |e,m| { name: e, value: m, inline: true } }
+  message_hash.map { |e, m| { name: e, value: m, inline: true } }
 end
 
 def rejected_app(event, opts)
@@ -56,45 +56,45 @@ def rejected_app(event, opts)
     case opts
     when :character
       [{
-        name: "Messages from the admin:",
+        name: 'Messages from the admin:',
         value: selected_messages(reactions, CharApp::REJECT_MESSAGES).
-        join("\n") || 'No messages given'
-      },{
+          join("\n") || 'No messages given'
+      }, {
         name: MSG,
         value: "[Edit Your Application](#{Url::CHARACTER}" +
-        "#{app.footer.text})"
+          "#{app.footer.text})"
       }]
     when :image
       [{
-        name: "Messages from the admin:",
+        name: 'Messages from the admin:',
         value: selected_messages(reactions, ImgApp::REJECT_MESSAGES).
-        join("\n") || 'No messages given'
+          join("\n") || 'No messages given'
       }]
     when :landmark
       [{
-        name: "Messages from the admin:",
+        name: 'Messages from the admin:',
         value: selected_messages(reactions, LmApp::REJECT_MESSAGES).
-        join("\n") || 'No messages given'
-      },{
+          join("\n") || 'No messages given'
+      }, {
         name: MSG,
         value: "[Edit Your Application](#{Url::LANDMARK}" +
-        "#{app.footer.text})"
+          "#{app.footer.text})"
       }]
     when :fable
       [{
-        name: "Messages from the admin:",
+        name: 'Messages from the admin:',
         value: selected_messages(reactions, FableApp::REJECT_MESSAGES).
-        join("\n") || 'No messages given'
-      },{
+          join("\n") || 'No messages given'
+      }, {
         name: MSG,
         value: "[Edit Your Application](#{Url::FABLE}" +
-        "#{app.footer.text})"
+          "#{app.footer.text})"
       }]
     end
 
   # Populate embed and return
   Embed.new(
-    title: "Your application has been rejected!",
+    title: 'Your application has been rejected!',
     description: app.title,
     color: ERROR,
     footer: { text: FTR },

+ 1 - 2
app/embeds/requests.rb

@@ -2,7 +2,7 @@ def create_request(name, desc)
   Embed.new(
     title: name,
     description: desc,
-    author:{
+    author: {
       name: 'Team Application'
     }
   )
@@ -25,5 +25,4 @@ def join_request(char, user)
 
   # Return
   embed
-
 end

+ 11 - 7
app/embeds/status.rb

@@ -1,17 +1,21 @@
 def status_list
   # Create Status lists
   # Split Statuses by stackable, and non-stackable, saving only their names
-  stackable, non_stackable = Status.all.partition{ |s| s.amount }
+  stackable, non_stackable = Status.all.partition { |s| s.amount }
 
   # Push the categorized Statuses into embed fields
   fields = []
-  fields.push(
-    { name: 'Stackable Effects', value: stackable.map(&:name).join(", ")}
-  ) unless stackable.empty?
+  unless stackable.empty?
+    fields.push(
+      { name: 'Stackable Effects', value: stackable.map(&:name).join(', ')}
+    )
+  end
 
-  fields.push(
-    { name: 'Non-Stackable Effects', value: non_stackable.map(&:name).join(", ")}
-  ) unless non_stackable.empty?
+  unless non_stackable.empty?
+    fields.push(
+      { name: 'Non-Stackable Effects', value: non_stackable.map(&:name).join(', ')}
+    )
+  end
 
   # Create Embed
   Embed.new(

+ 21 - 17
app/embeds/team.rb

@@ -1,4 +1,4 @@
-TEAM_BLUE = "#3498db"
+TEAM_BLUE = '#3498db'.freeze
 
 def team_embed(team)
   fields = []
@@ -6,15 +6,15 @@ def team_embed(team)
   members = CharTeam.where(team_id: team.id)
 
   members.each do |member|
-    if member.active
-      active.push(Character.find(member.char_id).name)
-    end
+    active.push(Character.find(member.char_id).name) if member.active
   end
 
-  fields.push({
-    name: 'Active Members',
-    value: active.join(", ")
-  })unless active.empty?
+  unless active.empty?
+    fields.push({
+                  name: 'Active Members',
+                  value: active.join(', ')
+                })
+  end
 
   embed = Embed.new(
     title: team.name,
@@ -40,15 +40,19 @@ def teams_embed
     end
   end
 
-  fields.push({
-    name: 'Active Teams',
-    value: active.join(", ")
-  })unless active.empty?
+  unless active.empty?
+    fields.push({
+                  name: 'Active Teams',
+                  value: active.join(', ')
+                })
+  end
 
-  fields.push({
-    name: 'Inactive Teams',
-    value: inactive.join(", ")
-  })unless inactive.empty?
+  unless inactive.empty?
+    fields.push({
+                  name: 'Inactive Teams',
+                  value: inactive.join(', ')
+                })
+  end
 
   Embed.new(
     title: 'Rescue Teams',
@@ -62,7 +66,7 @@ def team_alert(char, teams)
   Embed.new(
     author: { name: 'Team Alert' },
     description: "By archiving #{char.name}, you will be removed from " +
-      "#{teams.join(" & ")}\n**Are you sure?**",
+      "#{teams.join(' & ')}\n**Are you sure?**",
     footer: { text: char.id },
     color: TEAM_BLUE
   )

+ 1 - 1
app/embeds/users.rb

@@ -13,7 +13,7 @@ def show_stats(user, member)
 
   embed = Embed.new(
     title: member.nickname || member.name,
-    description: "```#{stats.to_s}```",
+    description: "```#{stats}```"
   )
 
   embed.color = member.color.combined if member.color

+ 1 - 1
app/models/bot_response.rb

@@ -1,5 +1,5 @@
 class BotResponse
-  def initialize(destination: nil, text: "", embed: nil, timer: nil, file: nil, carousel: nil, reactions: [])
+  def initialize(destination: nil, text: '', embed: nil, timer: nil, file: nil, carousel: nil, reactions: [])
     @destination = destination
     @text = text
     @timer = timer

+ 1 - 1
app/models/carousels.rb

@@ -27,7 +27,7 @@ class Carousel < ActiveRecord::Base
   end
 
   def close(event)
-    self.destroy
+    destroy
     event.message.delete
   end
 end

+ 7 - 7
app/models/char_images.rb

@@ -4,8 +4,8 @@ class CharImage < ActiveRecord::Base
 
   def self.from_form(app)
     key_mapping = {
-      "Keyword" => "keyword",
-      "Category" => "category",
+      'Keyword' => 'keyword',
+      'Category' => 'category'
     }
 
     hash = {}
@@ -17,10 +17,10 @@ class CharImage < ActiveRecord::Base
         db_column == 'category' ? field.value.upcase : field.value
     end
 
-    hash["char_id"] = app.footer.text
-    hash["url"] = app.image.url
+    hash['char_id'] = app.footer.text
+    hash['url'] = app.image.url
 
-    hash = hash.reject { |k,v| k == nil }
+    hash = hash.reject { |k, _v| k.nil? }
     hash
   end
 
@@ -29,8 +29,8 @@ class CharImage < ActiveRecord::Base
       title: "#{char.name} | #{char.species}",
       description: "<@#{user_id}>",
       author: {
-        name: "Image Application",
-        icon_url: "https://i.imgur.com/fiLLQED.jpg"
+        name: 'Image Application',
+        icon_url: 'https://i.imgur.com/fiLLQED.jpg'
       },
       image: {
         url: url

+ 60 - 60
app/models/characters.rb

@@ -20,7 +20,7 @@ class Character < ActiveRecord::Base
   end
 
   def type_color
-    Type.find_by(name: types.split("/").first || 'Unknown').color
+    Type.find_by(name: types.split('/').first || 'Unknown').color
   end
 
   def fetch_inventory
@@ -32,59 +32,59 @@ class Character < ActiveRecord::Base
 
   def self.from_form(app)
     key_mapping = {
-      "Characters Name" => "name",
-      "Species" => "species",
-      "Shiny" => "shiny",
-      "Type" => "types",
-      "Age" => "age",
-      "Weight" => "weight",
-      "Height" => "height",
-      "Gender" => "gender",
-      "Sexual Orientation" => "orientation",
-      "Relationship Status" => "relationship",
-      "Attacks" => "attacks",
-      "Likes" => "likes",
-      "Dislikes" => "dislikes",
-      "Personality" => "personality",
-      "Hometown" => "hometown",
-      "Warnings" => "warnings",
-      "Rumors" => "rumors",
-      "Backstory" => "backstory",
-      "Recent Events" => "recent_events",
-      "Other" => "other",
-      "Rating" => "rating",
-      "Current Location" => "location",
-      "DM Notes" => "dm_notes",
-      "Edit Key (ignore)" => "edit_url",
+      'Characters Name' => 'name',
+      'Species' => 'species',
+      'Shiny' => 'shiny',
+      'Type' => 'types',
+      'Age' => 'age',
+      'Weight' => 'weight',
+      'Height' => 'height',
+      'Gender' => 'gender',
+      'Sexual Orientation' => 'orientation',
+      'Relationship Status' => 'relationship',
+      'Attacks' => 'attacks',
+      'Likes' => 'likes',
+      'Dislikes' => 'dislikes',
+      'Personality' => 'personality',
+      'Hometown' => 'hometown',
+      'Warnings' => 'warnings',
+      'Rumors' => 'rumors',
+      'Backstory' => 'backstory',
+      'Recent Events' => 'recent_events',
+      'Other' => 'other',
+      'Rating' => 'rating',
+      'Current Location' => 'location',
+      'DM Notes' => 'dm_notes',
+      'Edit Key (ignore)' => 'edit_url'
     }
 
     hash = {
-      "user_id" => nil,
-      "name" => nil,
-      "species" => nil,
-      "shiny" => nil,
-      "types" => nil,
-      "age" => nil,
-      "weight" => nil,
-      "height" => nil,
-      "gender" => nil,
-      "orientation" => nil,
-      "relationship" => nil,
-      "attacks" => nil,
-      "likes" => nil,
-      "dislikes" => nil,
-      "personality" => nil,
-      "backstory" => nil,
-      "recent_events" => nil,
-      "other" => nil,
-      "edit_url" => nil,
-      "active" => nil,
-      "dm_notes" => nil,
-      "location" => nil,
-      "rumors" => nil,
-      "hometown" => nil,
-      "warnings" => nil,
-      "rating" => nil
+      'user_id' => nil,
+      'name' => nil,
+      'species' => nil,
+      'shiny' => nil,
+      'types' => nil,
+      'age' => nil,
+      'weight' => nil,
+      'height' => nil,
+      'gender' => nil,
+      'orientation' => nil,
+      'relationship' => nil,
+      'attacks' => nil,
+      'likes' => nil,
+      'dislikes' => nil,
+      'personality' => nil,
+      'backstory' => nil,
+      'recent_events' => nil,
+      'other' => nil,
+      'edit_url' => nil,
+      'active' => nil,
+      'dm_notes' => nil,
+      'location' => nil,
+      'rumors' => nil,
+      'hometown' => nil,
+      'warnings' => nil,
+      'rating' => nil
     }
 
     user_id = UID.match(app.description)
@@ -97,7 +97,7 @@ class Character < ActiveRecord::Base
                'Archived'
              end
 
-    hash["user_id"] = case app.description
+    hash['user_id'] = case app.description
                       when /public/i
                         'Public'
                       when /server/i
@@ -106,22 +106,22 @@ class Character < ActiveRecord::Base
                         user_id[1]
                       end
 
-    hash["active"] = active
-    hash["edit_url"] = app.footer.text
+    hash['active'] = active
+    hash['edit_url'] = app.footer.text
 
     app.fields.each do |field|
       next if field.nil?
 
       db_column = key_mapping[field.name]
 
-      if db_column == 'shiny'
-        hash[db_column] = field.value.match(/yes/i) ? true : false
-      else
-        hash[db_column] = field.value
-      end
+      hash[db_column] = if db_column == 'shiny'
+                          field.value.match(/yes/i) ? true : false
+                        else
+                          field.value
+                        end
     end
 
-    hash = hash.reject { |k,v| k == nil }
+    hash = hash.reject { |k, _v| k.nil? }
     hash
   end
 end

+ 3 - 7
app/models/commands.rb

@@ -3,20 +3,16 @@ require 'optparse'
 class Command
   attr_reader :name, :operation
 
-  def initialize(name, description, options ={}, &block)
+  def initialize(name, description, options = {}, &block)
     @name = name
     @description = description
     @options = options
     @operation = block
   end
 
-  def description
-    @description
-  end
+  attr_reader :description
 
-  def options
-    @options
-  end
+  attr_reader :options
 
   def call(message_str, event=nil)
     match = /pkmn-\w+\s?(.*)/.match(message_str)

+ 13 - 9
app/models/embed.rb

@@ -103,17 +103,21 @@ class Embed
       timestamp: discord_embed.timestamp
     )
 
-    embed.footer = {
-      icon_url: discord_embed.footer.icon_url,
-      text: discord_embed.footer.text
-    } if discord_embed.footer
+    if discord_embed.footer
+      embed.footer = {
+        icon_url: discord_embed.footer.icon_url,
+        text: discord_embed.footer.text
+      }
+    end
     embed.thumbnail = { url: discord_embed.thumbnail.url } if discord_embed.thumbnail
     embed.image = { url: discord_embed.image.url } if discord_embed.image
-    embed.author = {
-      icon_url: discord_embed.author.icon_url,
-      name: discord_embed.author.name,
-      url: discord_embed.author.url,
-    } if discord_embed.author
+    if discord_embed.author
+      embed.author = {
+        icon_url: discord_embed.author.icon_url,
+        name: discord_embed.author.name,
+        url: discord_embed.author.url
+      }
+    end
     embed.fields = fields if fields
 
     embed

+ 20 - 21
app/models/fables.rb

@@ -4,39 +4,38 @@ class Fable < ActiveRecord::Base
 
   def self.from_form(app)
     key_mapping = {
-      "Author" => "user_id",
-      "Keywords" => "keywords"
+      'Author' => 'user_id',
+      'Keywords' => 'keywords'
     }
 
     hash = {
-      "title" => nil,
-      "story" => nil,
-      "url" => nil,
-      "keywords" => nil,
-      "user_id" => nil,
-      "edit_url" => nil
+      'title' => nil,
+      'story' => nil,
+      'url' => nil,
+      'keywords' => nil,
+      'user_id' => nil,
+      'edit_url' => nil
     }
 
-    hash["title"] = app.title
-    hash["story"] = app.description
-    hash["edit_url"] = app.footer.text
-    hash["url"] = app.image&.url
+    hash['title'] = app.title
+    hash['story'] = app.description
+    hash['edit_url'] = app.footer.text
+    hash['url'] = app.image&.url
 
     app.fields.each do |field|
       next if field.nil?
 
       db_column = key_mapping[field.name]
-      if db_column == "user_id"
-        hash[db_column] = UID.match(field.value)[1]
-      elsif db_column == "keywords"
-        hash[db_column] = field.value.split(/\s?(,|\|)\s?/)
-      else
-        hash[db_column] = field.value
-      end
+      hash[db_column] = if db_column == 'user_id'
+                          UID.match(field.value)[1]
+                        elsif db_column == 'keywords'
+                          field.value.split(/\s?(,|\|)\s?/)
+                        else
+                          field.value
+                        end
     end
 
-
-    hash = hash.reject { |k,v| k == nil }
+    hash = hash.reject { |k, _v| k.nil? }
     hash
   end
 end

+ 33 - 37
app/models/image_merger.rb

@@ -1,37 +1,33 @@
-require 'rmagick'
-include Magick
-
-def append_image(image1_in, images_in, image_out)
-  i = Magick::ImageList.new(image1_in,images_in)
-
-  if i.append(true)
-    u.write(image_out)
-  end
-end
-
-def merge_image(image_array, image_out, output_width, output_height, xaxis, yaxis, image_width, image_height)
-  i = Magick::ImageList.new(*image_array)
-
-  v = Magick::ImageList.new
-  arr = []
-
-  i.each.with_index do |item, index|
-    if image_width[index] && image_height[index]
-      i[index] = item.resize(image_width[index], image_height[index])
-    end
-
-    if xaxis[index] && yaxis[index]
-      v.new_image(output_width, output_height) { self.background_color = "transparent" }
-
-      i[index] = v.composite(i[index], xaxis[index], yaxis[index], OverCompositeOp).write(image_out + index.to_s + ".png")
-    else
-      i[index].write(image_out + index.to_s + ".png");
-    end
-
-    arr << image_out + index.to_s + ".png"
-  end
-
-  i = Magick::ImageList.new(*arr)
-  i = i.flatten_images();
-  i.write(image_out + ".png")
-end
+require 'rmagick'
+include Magick
+
+def append_image(image1_in, images_in, image_out)
+  i = Magick::ImageList.new(image1_in, images_in)
+
+  u.write(image_out) if i.append(true)
+end
+
+def merge_image(image_array, image_out, output_width, output_height, xaxis, yaxis, image_width, image_height)
+  i = Magick::ImageList.new(*image_array)
+
+  v = Magick::ImageList.new
+  arr = []
+
+  i.each.with_index do |item, index|
+    i[index] = item.resize(image_width[index], image_height[index]) if image_width[index] && image_height[index]
+
+    if xaxis[index] && yaxis[index]
+      v.new_image(output_width, output_height) { self.background_color = 'transparent' }
+
+      i[index] = v.composite(i[index], xaxis[index], yaxis[index], OverCompositeOp).write(image_out + index.to_s + '.png')
+    else
+      i[index].write(image_out + index.to_s + '.png')
+    end
+
+    arr << image_out + index.to_s + '.png'
+  end
+
+  i = Magick::ImageList.new(*arr)
+  i = i.flatten_images
+  i.write(image_out + '.png')
+end

+ 20 - 20
app/models/item.rb

@@ -3,13 +3,13 @@ class Item < ActiveRecord::Base
 
   def self.from_form(app)
     key_mapping = {
-      "Item Name" => "name",
-      "Description" => "description",
-      "Effect" => "effect",
-      "Side Effect" => "side_effect",
-      "RP Reply" => "rp_reply",
-      "Category" => "category",
-      "Reusable" => "reusable"
+      'Item Name' => 'name',
+      'Description' => 'description',
+      'Effect' => 'effect',
+      'Side Effect' => 'side_effect',
+      'RP Reply' => 'rp_reply',
+      'Category' => 'category',
+      'Reusable' => 'reusable'
     }
 
     hash = {}
@@ -18,22 +18,22 @@ class Item < ActiveRecord::Base
 
       db_column = key_mapping[field.name]
       hash[db_column] =
-        case db_column
-        when "category"
-          hash[db_column] = field.value.split(",")
-        when "reusable"
-          hash[db_column] = field.value == "True" ? true : false
-        else
-          hash[db_column] = field.value
-        end
+        hash[db_column] = case db_column
+                          when 'category'
+                            field.value.split(',')
+                          when 'reusable'
+                            field.value == 'True'
+                          else
+                            field.value
+                          end
     end
 
-    hash["name"] = app.title
-    hash["description"] = app.description
-    hash["url"] = app.thumbnail.url if app.thumbnail
-    hash["edit_url"] = app.footer.text
+    hash['name'] = app.title
+    hash['description'] = app.description
+    hash['url'] = app.thumbnail.url if app.thumbnail
+    hash['edit_url'] = app.footer.text
 
-    hash = hash.reject { |k,v| k == nil }
+    hash = hash.reject { |k, _v| k.nil? }
     hash
   end
 end

+ 38 - 38
app/models/landmarks.rb

@@ -16,76 +16,76 @@ class Landmark < ActiveRecord::Base
   end
 
   def set_default_warning
-    if self.warning.nil?
-      self.warning = "This is a verified safe location!"
-      self.w_url = "https://cdn.dribbble.com/users/250235/screenshots/2850450/pokemon_center_1x.png"
-      self.w_rating = "SFW"
+    if warning.nil?
+      self.warning = 'This is a verified safe location!'
+      self.w_url = 'https://cdn.dribbble.com/users/250235/screenshots/2850450/pokemon_center_1x.png'
+      self.w_rating = 'SFW'
     end
   end
 
   def self.from_form(app)
     key_mapping = {
-      "Description" => "description",
-      "Type" => "category",
-      "Main Region" => "region",
-      "Parent Landmark" => "location",
-      "Kinks" => "kink",
-      "Warning Description" => "warning",
-      "Warning URL" => "w_url",
-      "Warning Rating" => "w_rating",
-      "History" => "history",
-      "Folklore" => "folk_lore",
-      "Layout URL" => "layout_url"
+      'Description' => 'description',
+      'Type' => 'category',
+      'Main Region' => 'region',
+      'Parent Landmark' => 'location',
+      'Kinks' => 'kink',
+      'Warning Description' => 'warning',
+      'Warning URL' => 'w_url',
+      'Warning Rating' => 'w_rating',
+      'History' => 'history',
+      'Folklore' => 'folk_lore',
+      'Layout URL' => 'layout_url'
     }
 
     hash = {
-      "name" => nil,
-      "description" => nil,
-      "category" => nil,
-      "url" => nil,
-      "location" => nil,
-      "region" => nil,
-      "warning" => nil,
-      "w_url" => nil,
-      "kink" => nil,
-      "layout_url" => nil,
-      "user_id" => nil,
-      "w_rating" => nil,
-      "history" => nil,
-      "folk_lore" => nil,
-      "edit_url" => nil
+      'name' => nil,
+      'description' => nil,
+      'category' => nil,
+      'url' => nil,
+      'location' => nil,
+      'region' => nil,
+      'warning' => nil,
+      'w_url' => nil,
+      'kink' => nil,
+      'layout_url' => nil,
+      'user_id' => nil,
+      'w_rating' => nil,
+      'history' => nil,
+      'folk_lore' => nil,
+      'edit_url' => nil
     }
 
     user_id = UID.match(app.description)
-    hash["user_id"] = case app.description
+    hash['user_id'] = case app.description
                       when /server/i
                         'Server'
                       else
                         user_id[1]
                       end
 
-    hash["name"] = app.title
-    hash["edit_url"] = app.footer.text
-    hash["url"] = app.image&.url
+    hash['name'] = app.title
+    hash['edit_url'] = app.footer.text
+    hash['url'] = app.image&.url
 
     app.fields.each do |field|
       next if field.nil?
 
       db_column = key_mapping[field.name]
-      if db_column == "region"
+      if db_column == 'region'
         r = Region.find_by(name: field.value)
         hash[db_column] = r.id
-      elsif db_column == "location"
+      elsif db_column == 'location'
         lm = Landmark.find_by(name: field.value)
         hash[db_column] = lm.id
-      elsif db_column == "kink"
+      elsif db_column == 'kink'
         hash[db_column] = field.value.split(/,\s?/)
       else
         hash[db_column] = field.value
       end
     end
 
-    hash = hash.reject { |k,v| k == nil }
+    hash = hash.reject { |k, _v| k.nil? }
     hash
   end
 end

+ 8 - 8
app/models/teams.rb

@@ -2,7 +2,7 @@ class Team < ActiveRecord::Base
   validates :name, presence: true
   validates :description, presence: true
 
-  def join(character, event)
+  def join(character, _event)
     existing_row = CharTeam.where(char_id: character.id, team_id: id)
 
     if existing_row.empty?
@@ -19,12 +19,12 @@ class Team < ActiveRecord::Base
 
     # Check if they have any members left in the team
     # Special Query
-    sql = "SELECT * " +
-      "FROM char_teams JOIN characters " +
-      "ON char_teams.char_id = characters.id " +
-      "WHERE characters.user_id = ? " +
-      "AND char_teams.team_id = ? " +
-      "and char_teams.active = true;"
+    sql = 'SELECT * ' +
+          'FROM char_teams JOIN characters ' +
+          'ON char_teams.char_id = characters.id ' +
+          'WHERE characters.user_id = ? ' +
+          'AND char_teams.team_id = ? ' +
+          'and char_teams.active = true;'
     # Execute
     sql = ActiveRecord::Base.send(:sanitize_sql_array, [sql, char.user_id, id])
     remaining_chars = ActiveRecord::Base.connection.exec_query(sql)
@@ -42,6 +42,6 @@ class Team < ActiveRecord::Base
 
     # Delete Server Role, and move channel
     event.server.role(role_id).delete('Archived Team')
-    event.channel.category=(ENV['TEAM_ARCHIVES'])
+    event.channel.category = (ENV['TEAM_ARCHIVES'])
   end
 end

+ 15 - 15
app/models/users.rb

@@ -17,8 +17,8 @@ class User < ActiveRecord::Base
     stats['d_base'] = rand(1..184)
     stats['sd_base'] = 185 - stats['d_base']
 
-    self.update(stats)
-    self.update(
+    update(stats)
+    update(
       hp_iv: rand(0..31),
       a_iv: rand(0..31),
       d_iv: rand(0..31),
@@ -28,13 +28,13 @@ class User < ActiveRecord::Base
       nature: rand(1..25)
     )
 
-    self.reload
+    reload
 
     n = Nature.find(nature)
     stats = stat_calc(n.up_stat, n.down_stat)
-    self.update(stats)
+    update(stats)
 
-    self.reload
+    reload
     self
   end
 
@@ -56,9 +56,9 @@ class User < ActiveRecord::Base
       else 0.5
       end
 
-    xp = (msg_length/50 * multiplier).to_i
+    xp = (msg_length / 50 * multiplier).to_i
 
-    self.update(
+    update(
       boosted_xp: boosted_xp + xp,
       unboosted_xp: unboosted_xp + xp,
       additional_xp: additional_xp + (xp - old_xp),
@@ -66,7 +66,7 @@ class User < ActiveRecord::Base
       post_count: post_count + 1
     )
 
-    self.reload
+    reload
     reply = level_up(member) if next_level && boosted_xp > next_level
 
     reply
@@ -74,12 +74,12 @@ class User < ActiveRecord::Base
 
   def level_up(member=nil)
     if level < 100
-      next_level = (level + 6) ** 3 / 10.0
-      self.update(level: level + 1, next_level: next_level.round)
-      self.reload
+      next_level = (level + 6)**3 / 10.0
+      update(level: level + 1, next_level: next_level.round)
+      reload
     else
-      self.update(level: level + 1, next_level: nil)
-      self.reload
+      update(level: level + 1, next_level: nil)
+      reload
     end
 
     n = Nature.find(nature)
@@ -87,8 +87,8 @@ class User < ActiveRecord::Base
     stats = stat_calc(n.up_stat, n.down_stat)
     img = UsersController.stat_image(self, member, stats) if member
 
-    self.update(stats)
-    self.reload
+    update(stats)
+    reload
 
     img
   end

+ 57 - 47
bot.rb

@@ -13,11 +13,11 @@ require 'active_record'
 
 # Constants: such as roles and colors and regexes
 
-DISCORD = "#36393f"
-ERROR = "#a41e1f"
+DISCORD = '#36393f'.freeze
+ERROR = '#a41e1f'.freeze
 
-UID = /<@\!?(\w+)>/
-URL = /https?:\/\/[\S]+/
+UID = /<@\!?(\w+)>/.freeze
+URL = %r{https?://[\S]+}.freeze
 
 # ---
 
@@ -39,7 +39,7 @@ ActiveRecord::Base.establish_connection(
 )
 
 Dir['app/**/*.rb'].each { |f| require File.join(File.expand_path(__dir__), f) }
-Dir['./lib/*.rb'].each { |f| require f }
+Dir['./lib/*.rb'].sort.each { |f| require f }
 
 token = ENV['DISCORD_BOT_TOKEN']
 bot = Discordrb::Bot.new(token: token)
@@ -59,8 +59,8 @@ bot.message do |event|
   # Check for a standard command
   if cmd
     # Search for the corresponding command
-    commands = BaseCommand.descendants.filter{ |bc| bc.restricted_to == nil }
-    command = commands.detect{ |c| c.name == cmd[1].downcase.to_sym }
+    commands = BaseCommand.descendants.filter { |bc| bc.restricted_to.nil? }
+    command = commands.detect { |c| c.name == cmd[1].downcase.to_sym }
 
     # Call the command, and reply with its results
     reply = command&.call(content, event)
@@ -86,28 +86,31 @@ bot.message do |event|
 
   # Check for a clear command
   elsif ENV['CLEAR_CH'].include?(event.channel.id.to_s) && content.match(/^clear\schat$/i)
-    msgs = event.channel.history(50).reject{ |m| m.author.webhook? }
+    msgs = event.channel.history(50).reject { |m| m.author.webhook? }
     event.channel.delete_messages(msgs)
 
   # Check for no exp channels
   elsif ENV['NO_EXP_CH'].include?(event.channel.id.to_s)
-    # Do nothing
+  # Do nothing
 
   # Apply experience to non-bot users
   elsif !author.bot_account? && !author.webhook?
     # Replace any urls with 150 'x' chars
-    message = URL.match(content) ? content.gsub(URL, "x" * 100) : content
+    message = URL.match(content) ? content.gsub(URL, 'x' * 100) : content
 
     # Add 40 to the message length if there's a file
-    msg_length = event.message.attachments.map(&:filename).count > 0 ?
-      50 + message.length : message.length
+    msg_length = if event.message.attachments.map(&:filename).positive?
+                   50 + message.length
+                 else
+                   message.length
+                 end
 
     # Record post lengths and count
     user = User.find(author.id)
 
     if msg_length >= 40
       # Update User and reply with image, if there is one
-      reply =  user.update_xp(msg_length, author)
+      reply = user.update_xp(msg_length, author)
       bot.send_file(event.channel.id, File.open(reply, 'r')) if reply
     else
       user.update(
@@ -116,7 +119,6 @@ bot.message do |event|
       )
     end
   end
-
 end
 
 # This will trigger when a dm is sent to the bot from a user
@@ -129,8 +131,8 @@ bot.pm do |event|
   # Check for a standard command
   if cmd
     # Search for the corresponding command
-    commands = BaseCommand.descendants.filter{ |bc| bc.restricted_to == :pm }
-    command = commands.detect{ |c| c.name == cmd[1].downcase.to_sym }
+    commands = BaseCommand.descendants.filter { |bc| bc.restricted_to == :pm }
+    command = commands.detect { |c| c.name == cmd[1].downcase.to_sym }
 
     # Call the command, and reply with its results
     reply = command&.call(content, event)
@@ -151,7 +153,7 @@ bot.reaction_add do |event|
   break unless app_form
 
   # Find the appropriate app type, and process
-  app = ApplicationForm.descendants.detect{ |af| af.name == app_form.author&.name }
+  app = ApplicationForm.descendants.detect { |af| af.name == app_form.author&.name }
   carousel = Carousel.find_by(message_id: event.message.id)
 
   reply = if app then app&.call(event)
@@ -160,12 +162,12 @@ bot.reaction_add do |event|
 
   if reply
     BotController.reply(bot, event, reply)
-  #elsif event.message&.reactions[Emoji::CROSS]&.count
-    #crosses = event.message.reacted_with(Emoji::CROSS)
-    #crosses.each do |cross|
-      #member = event.server.member(cross.id)
-      #event.message.delete unless member.current_bot?
-    #end
+    # elsif event.message&.reactions[Emoji::CROSS]&.count
+    # crosses = event.message.reacted_with(Emoji::CROSS)
+    # crosses.each do |cross|
+    # member = event.server.member(cross.id)
+    # event.message.delete unless member.current_bot?
+    # end
   end
 end
 
@@ -192,7 +194,7 @@ bot.member_leave do |event|
 
   chars = Character.where(user_id: event.user.id)
   roles = event.roles
-  roles = roles.map{ |r| "<@#{r}>" } if roles
+  roles = roles.map { |r| "<@#{r}>" } if roles
 
   chars.each do |char|
     unless char.active == 'NPC'
@@ -200,7 +202,7 @@ bot.member_leave do |event|
       char.reload
     end
     ct = CharTeam.find_by(char_id: char.id)
-    ct.update(active: false) if ct
+    ct&.update(active: false)
     t = Team.find(ct.team_id) if ct
 
     bot.send_message(t.channel, "#{char.name} has left the server", false, nil) if t
@@ -209,15 +211,19 @@ bot.member_leave do |event|
     updated.push("#{char.name}, no team data -- #{char.active}") if t.nil?
   end
 
-  fields.push({
-    name: "```Flagging Guild Members......```",
-    value: updated.join("\n")
-  }) unless updated.empty?
+  unless updated.empty?
+    fields.push({
+                  name: '```Flagging Guild Members......```',
+                  value: updated.join("\n")
+                })
+  end
 
-  fields.push({
-    name: "User's Roles",
-    value: roles.join(", ")
-  }) unless roles.empty?
+  unless roles.empty?
+    fields.push({
+                  name: "User's Roles",
+                  value: roles.join(', ')
+                })
+  end
 
   embed = Embed.new(
     title: "I've lost track of a user!",
@@ -226,10 +232,10 @@ bot.member_leave do |event|
   )
 
   # production channel
-  bot.send_message(588464466048581632, "", false, embed)
+  bot.send_message(588_464_466_048_581_632, '', false, embed)
 
   # development channel
-  #bot.send_message(594244240020865035, "", false, embed)
+  # bot.send_message(594244240020865035, "", false, embed)
 end
 
 # This will trigger when anyone is banned from the server
@@ -239,7 +245,7 @@ bot.user_ban do |event|
 
   chars = Character.where(user_id: event.user.id)
   roles = event.roles
-  roles = roles.map{ |r| "<@#{r}>" } if roles
+  roles = roles.map { |r| "<@#{r}>" } if roles
 
   chars.each do |char|
     unless char.active == 'NPC'
@@ -247,31 +253,35 @@ bot.user_ban do |event|
       char.reload
     end
     ct = CharTeam.find_by(char_id: char.id)
-    ct.update(active: false) if ct
+    ct&.update(active: false)
     t = Team.find(ct.team_id) if ct
 
     updated.push("#{char.name}, #{t.name} -- #{char.active}") if t
     updated.push("#{char.name}, no team data -- #{char.active}") if t.nil?
   end
 
-  fields.push({
-    name: "```Flagging Guild Members......```",
-    value: updated.join("\n")
-  }) unless updated.empty?
+  unless updated.empty?
+    fields.push({
+                  name: '```Flagging Guild Members......```',
+                  value: updated.join("\n")
+                })
+  end
 
-  fields.push({
-    name: "User's Roles",
-    value: roles.join(", ")
-  }) unless roles.empty?
+  unless roles.empty?
+    fields.push({
+                  name: "User's Roles",
+                  value: roles.join(', ')
+                })
+  end
 
   embed = Embed.new(
-    title: "A User was forced to leave!",
+    title: 'A User was forced to leave!',
     description: "It seems #{event.member.mention}, (#{event.user.username}) has been banned from the server!",
     fields: fields
   )
 
   # production channel
-  bot.send_message(588464466048581632, "", false, embed)
+  bot.send_message(588_464_466_048_581_632, '', false, embed)
 end
 
 # This will trigger when anyone is un-banned from the server