Sha256: c9b9d4b56552c6fcd4110d07d8b446686dd3459fb1edbe78635a5555e4e7ffca

Contents?: true

Size: 876 Bytes

Versions: 64

Compression:

Stored size: 876 Bytes

Contents

class EventDecorator
  def initialize(event)
    @event = event
  end

  def channel
    @event.channel
  end

  def channel_id
    @event.channel.id
  end

  def display_name
    user.display_name
  end

  def user_id
    user.id
  end

  def mention
    user.mention
  end

  def users
    server.users
  end

  def mention_for(user_id)
    find_user(user_id)&.mention
  end

  def mentions_for(user_ids)
    find_users(user_ids).map(&:mention)
  end

  def display_name_for(user_id)
    find_user(user_id)&.display_name
  end

  def display_names_for(user_ids)
    find_users(user_ids).map(&:display_name)
  end

  private

  def find_users(user_ids)
    user_ids.map do |user_id|
      find_user(user_id)
    end
  end

  def find_user(user_id)
    users.find { |user| user.id == user_id }
  end

  def server
    @event.server
  end

  def user
    @event.user
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
qwtf_discord_bot-6.3.1 lib/event_decorator.rb
qwtf_discord_bot-6.3.0 lib/event_decorator.rb
qwtf_discord_bot-6.2.2 lib/event_decorator.rb
qwtf_discord_bot-6.2.1 lib/event_decorator.rb
qwtf_discord_bot-6.2.0 lib/event_decorator.rb
qwtf_discord_bot-6.1.5 lib/event_decorator.rb
qwtf_discord_bot-6.1.4 lib/event_decorator.rb
qwtf_discord_bot-6.1.3 lib/event_decorator.rb
qwtf_discord_bot-6.1.2 lib/event_decorator.rb
qwtf_discord_bot-6.1.1 lib/event_decorator.rb
qwtf_discord_bot-6.1.0 lib/event_decorator.rb
qwtf_discord_bot-6.0.4 lib/event_decorator.rb
qwtf_discord_bot-6.0.3 lib/event_decorator.rb
qwtf_discord_bot-6.0.2 lib/event_decorator.rb
qwtf_discord_bot-6.0.1 lib/event_decorator.rb
qwtf_discord_bot-5.5.26 lib/event_decorator.rb
qwtf_discord_bot-5.5.25 lib/event_decorator.rb
qwtf_discord_bot-5.5.24 lib/event_decorator.rb
qwtf_discord_bot-5.5.23 lib/event_decorator.rb
qwtf_discord_bot-5.5.22 lib/event_decorator.rb