Nakilon/reddit_bot

NoMethodError: undefined method `fdiv' when fetching subreddits

ishields opened this issue · 3 comments

I will dig into this more but wanted to post this issue in case others are experiencing it. It looks like the gem is all of a sudden throwing this error when fetching subreddits.

bot.json(:get, '/subreddits/mine/moderator')

throws this error:

#<NoMethodError: undefined method `fdiv' for 1969-12-31 19:04:47.147372 -0500:Time>

This was working for quite a while so guessing maybe there's an API change on the Reddit side.

Update: The error occurs on this line in nethttputils.rb

                t = (reset_time - current_timestamp + 1).fdiv([remaining - 5, 1].max)

I believe maybe it's because reset_time is a timestamp not an interger

(reset_time - current_timestamp + 1) => 1969-12-31 19:02:51.517775 -0500

@Nakilon This was a simple fix in nethttputils gem and I opened a PR here Nakilon/nethttputils#1

Should be fixed now in v1.11.0