Exception: MijDiscord::Errors::MessageTooLong

Inherits:
DiscordError
  • Object
show all
Defined in:
lib/mij-discord/errors.rb

Constant Summary collapse

MATCH_PATTERNS =
[['2000'], ['long', 'length', 'size'], ['fewer', 'maximum']]

Instance Attribute Summary

Attributes inherited from DiscordError

#code, #response

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, response) ⇒ MessageTooLong

Returns a new instance of MessageTooLong.



25
26
27
# File 'lib/mij-discord/errors.rb', line 25

def initialize(message, response)
  super(nil, message, response)
end

Class Method Details

.match_pattern?(error) ⇒ Boolean

This is shitcode

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/mij-discord/errors.rb', line 20

def self.match_pattern?(error)
  return false if error.nil?
  MATCH_PATTERNS.reduce(true) {|a,x| a && x.reduce(false) {|b,y| b || error.include?(y) } }
end