Class: Discorb::Guild::Widget
- Inherits:
 - 
      DiscordModel
      
        
- Object
 - DiscordModel
 - Discorb::Guild::Widget
 
 
- Defined in:
 - lib/discorb/guild.rb
 
Overview
Represents a guild widget.
Instance Attribute Summary collapse
- #channel -> nil, Discorb::Channel readonly
 - 
  
    
      #channel_id -> Discorb::Snowflake 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The channel ID.
 - 
  
    
      #enabled -> Boolean 
    
    
      (also: #enabled?, #enable?)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Whether the widget is enabled.
 - #guild -> nil, Discorb::Guild readonly
 - 
  
    
      #guild_id -> Discorb::Snowflake 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The guild ID.
 - 
  
    
      #json_url -> String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The JSON URL.
 
Instance Method Summary collapse
- 
  
    
      #edit(enabled: nil, channel: nil, reason: nil) -> Object 
    
    
      (also: #modify)
    
  
  
  
  
  
  
  
  
  
    
Edit the widget.
 - 
  
    
      #iframe(theme: "dark", width: 350, height: 500) -> String 
    
    
  
  
  
  
  
  
  
  
  
    
Return iframe HTML of the widget.
 
Methods inherited from DiscordModel
Instance Attribute Details
#channel -> nil, Discorb::Channel (readonly)
This method returns an object from client cache. it will return nil if the object is not in cache.
| 
       | 
    
      # File 'lib/discorb/guild.rb', line 949
     | 
  
#channel_id -> Discorb::Snowflake (readonly)
Returns The channel ID.
      943 944 945  | 
    
      # File 'lib/discorb/guild.rb', line 943 def channel_id @channel_id end  | 
  
#enabled -> Boolean (readonly) Also known as: enabled?, enable?
Returns Whether the widget is enabled.
      945 946 947  | 
    
      # File 'lib/discorb/guild.rb', line 945 def enabled @enabled end  | 
  
#guild -> nil, Discorb::Guild (readonly)
This method returns an object from client cache. it will return nil if the object is not in cache.
| 
       | 
    
      # File 'lib/discorb/guild.rb', line 949
     | 
  
#guild_id -> Discorb::Snowflake (readonly)
Returns The guild ID.
      941 942 943  | 
    
      # File 'lib/discorb/guild.rb', line 941 def guild_id @guild_id end  | 
  
#json_url -> String (readonly)
Returns The JSON URL.
| 
       | 
    
      # File 'lib/discorb/guild.rb', line 949
     | 
  
Instance Method Details
#edit(enabled: nil, channel: nil, reason: nil) -> Object Also known as: modify
This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.
This method calls HTTP request.
The arguments of this method are defaultly set to :unset. Specify value to set the value, if not don't specify or specify :unset.
Edit the widget.
      980 981 982 983 984 985 986 987  | 
    
      # File 'lib/discorb/guild.rb', line 980 def edit(enabled: nil, channel: nil, reason: nil) Async do payload = {} payload[:enabled] = enabled unless enabled.nil? payload[:channel_id] = channel.id if channel_id @client.http.patch("/guilds/#{@guild_id}/widget", payload, audit_log_reason: reason).wait end end  | 
  
#iframe(theme: "dark", width: 350, height: 500) -> String
Return iframe HTML of the widget.
      1004 1005 1006 1007 1008 1009  | 
    
      # File 'lib/discorb/guild.rb', line 1004 def iframe(theme: "dark", width: 350, height: 500) [ %(<iframe src="https://canary.discord.com/widget?id=#{@guild_id}&theme=#{theme}" width="#{width}" height="#{height}"), %(allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>), ].join end  |