Sha256: 93c004a82fe12742a8a7ad2f46578ec24497b26c722ada9c367dab51b60b76c2
Contents?: true
Size: 916 Bytes
Versions: 2
Compression:
Stored size: 916 Bytes
Contents
class EventWrapper include QwtfDiscordBot DEFAULT_MAXPLAYERS = 8 def initialize(event) @event = event end def user_id @event.user.id end def username @event.user.username end def maxplayers_key [pug_key, "maxplayers"].join(":") end def maxplayers redis.setnx(maxplayers_key, DEFAULT_MAXPLAYERS) redis.get(maxplayers_key).to_i end def joined_player_count redis.scard(players_key).to_i end def slots_left maxplayers - joined_player_count end def pug_key ["pug", "channel", @event.channel.id].join(":") end def players_key [pug_key, "players"].join(":") end def player_slots "#{joined_player_count}/#{maxplayers}" end def users @event.server.users end def role_key [pug_key, "role"].join(":") end def role redis.get(role_key) || "@here" end def pug_active? redis.get(pug_key) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
qwtf_discord_bot-5.0.4 | lib/event_wrapper.rb |
qwtf_discord_bot-5.0.3 | lib/event_wrapper.rb |