Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Commit

Permalink
Updates for Crystal 0.28.0+
Browse files Browse the repository at this point in the history
- Use Time.utc
- Update spec against Packet#inspect format
- Use Kind#null?

Closes #186
  • Loading branch information
z64 committed Jan 17, 2020
1 parent 405d9a3 commit 15d78ab
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/multicommand.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ client.on_message_create do |payload|
suffix = command.split(' ')[1..-1].join(" ")
client.create_message(payload.channel_id, suffix)
when PREFIX + "date"
client.create_message(payload.channel_id, Time.now.to_s("%D"))
client.create_message(payload.channel_id, Time.utc.to_s("%D"))
end
end

Expand Down
2 changes: 1 addition & 1 deletion examples/ping_with_response_time.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ client.on_message_create do |payload|
if payload.content.starts_with? "!ping"
# We first create a new Message, and then we check how long it took to send the message by comparing it to the current time
m = client.create_message(payload.channel_id, "Pong!")
time = Time.utc_now - payload.timestamp
time = Time.utc - payload.timestamp
client.edit_message(m.channel_id, m.id, "Pong! Time taken: #{time.total_milliseconds} ms.")
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/discordcr_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe Discord do
describe Discord::WebSocket::Packet do
it "inspects" do
packet = Discord::WebSocket::Packet.new(0_i64, 1_i64, IO::Memory.new("foo"), "test")
packet.inspect.should eq %(Discord::WebSocket::Packet(@opcode=0_i64 @sequence=1_i64 @data="foo" @event_type="test"))
packet.inspect.should eq %(Discord::WebSocket::Packet(@opcode=0 @sequence=1 @data="foo" @event_type="test"))
end

it "serializes" do
Expand Down
4 changes: 2 additions & 2 deletions spec/snowflake_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require "./spec_helper"
describe Discord::Snowflake do
describe Discord::DISCORD_EPOCH do
it "is 2015-01-01" do
expected = Time.new(2015, 1, 1, location: Time::Location::UTC)
expected = Time.utc(2015, 1, 1)
Discord::DISCORD_EPOCH.should eq expected.to_unix_ms
end
end
Expand Down Expand Up @@ -35,7 +35,7 @@ describe Discord::Snowflake do

describe "#creation_time" do
it "returns the time the snowflake was created" do
time = Time.new(2018, 4, 18)
time = Time.utc(2018, 4, 18)
snowflake = Discord::Snowflake.new(time)
snowflake.creation_time.should eq time
end
Expand Down
2 changes: 1 addition & 1 deletion src/discordcr/mappings/converters.cr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module Discord
# :nodoc:
module MaybeTimestampConverter
def self.from_json(parser : JSON::PullParser)
if parser.kind == :null
if parser.kind.null?
parser.read_null
return nil
end
Expand Down

0 comments on commit 15d78ab

Please sign in to comment.