Преглед изворни кода

fix logic on dealing with arrays and characters

Kylie Jo Swistak пре 5 година
родитељ
комит
a0f33d2a06
1 измењених фајлова са 4 додато и 4 уклоњено
  1. 4 4
      app/commands/member.rb

+ 4 - 4
app/commands/member.rb

@@ -92,7 +92,7 @@ class MemberCommand < BaseCommand
     sfw = !event.channel.nsfw?
 
     # Determine if duplicate characters, then filter NSFW if SFW channel
-    if character.is_a? Array
+    unless character.is_a? Character
      chars = sfw ? character.filter{ |c| c.rating != 'NSFW' } : character
 
      # If still more than 1 character, reply with duplicate embed
@@ -103,13 +103,13 @@ class MemberCommand < BaseCommand
          reactions: Emoji::NUMBERS.take(chars.count),
          carousel: chars.map(&:id)
        )
-     elsif chars.legth == 0
+     elsif chars.length == 0
        nsfw_char_embed(chars.first, event)
+     else
+       character = character.first
      end
     end
 
-    character = character.first unless character.is_a? Character
-
     # Find image if specified
     image = CharImage.where(char_id: character.id).
       find_by('keyword ilike ?', keyword || 'Default')