Class: ESM::Community
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ESM::Community
- Defined in:
- lib/esm/model/community.rb
Constant Summary collapse
- ESM_ID =
"452568470765305866"
Class Method Summary collapse
Instance Method Summary collapse
- #discord_server ⇒ Object
- #log_event(event, message) ⇒ Object
- #logging_channel ⇒ Object
- #modifiable_by?(guild_member) ⇒ Boolean
Class Method Details
Instance Method Details
#discord_server ⇒ Object
19 20 21 22 23 |
# File 'lib/esm/model/community.rb', line 19 def discord_server ESM.bot.server(guild_id) rescue nil end |
#log_event(event, message) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/esm/model/community.rb', line 25 def log_event(event, ) return if logging_channel_id.blank? # Only allow logging events to logging channel if permission has been given case event when :xm8 return if !log_xm8_event when :discord_log return if !log_discord_log_event when :reconnect return if !log_reconnect_event when :error return if !log_error_event else raise ESM::Exception::Error, "Attempted to log :#{event} to #{guild_id} without explicit permission.\nMessage:\n#{}" end # Check this first to avoid an infinite loop if the bot cannot send a message to this channel # since this method is called from the #deliver method for this exact reason. channel = logging_channel return if channel.nil? ESM.bot.deliver(, to: channel) end |
#logging_channel ⇒ Object
13 14 15 16 17 |
# File 'lib/esm/model/community.rb', line 13 def logging_channel ESM.bot.channel(logging_channel_id) rescue nil end |
#modifiable_by?(guild_member) ⇒ Boolean
50 51 52 53 54 55 |
# File 'lib/esm/model/community.rb', line 50 def modifiable_by?(guild_member) return true if guild_member.(:administrator) || guild_member.owner? # Check for roles dashboard_access_role_ids.any? { |role_id| guild_member.role?(role_id) } end |