prevent it from trying to downcase a nil element and failing.
This commit is contained in:
parent
dbdd9a6495
commit
1d33f6d468
@ -24,12 +24,13 @@ module QuoteSystem
|
|||||||
end
|
end
|
||||||
|
|
||||||
command :quote do |event, *message|
|
command :quote do |event, *message|
|
||||||
category = message[0].downcase
|
category = message[0]
|
||||||
if category == nil
|
if category == nil
|
||||||
quotes = db.execute("SELECT * FROM quotes")
|
quotes = db.execute("SELECT * FROM quotes")
|
||||||
quote = quotes.sample
|
quote = quotes.sample
|
||||||
event.channel.send_message("##{quote[0]} <#{quote[2]}>: #{quote[3]}")
|
event.channel.send_message("##{quote[0]} <#{quote[2]}>: #{quote[3]}")
|
||||||
else
|
else
|
||||||
|
category = category.downcase
|
||||||
quotes = db.execute("SELECT * FROM quotes WHERE category = ?", [category])
|
quotes = db.execute("SELECT * FROM quotes WHERE category = ?", [category])
|
||||||
if quotes == []
|
if quotes == []
|
||||||
event.channel.send_message("Uh, this is awkward. The category you're trying to get a quote from doesn't exist.")
|
event.channel.send_message("Uh, this is awkward. The category you're trying to get a quote from doesn't exist.")
|
||||||
|
Loading…
Reference in New Issue
Block a user