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) -> Async::Task<void>
(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)
Note:
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 1170
|
#channel_id -> Discorb::Snowflake (readonly)
Returns The channel ID.
1164 1165 1166 |
# File 'lib/discorb/guild.rb', line 1164 def channel_id @channel_id end |
#enabled -> Boolean (readonly) Also known as: enabled?, enable?
Returns Whether the widget is enabled.
1166 1167 1168 |
# File 'lib/discorb/guild.rb', line 1166 def enabled @enabled end |
#guild -> nil, Discorb::Guild (readonly)
Note:
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 1170
|
#guild_id -> Discorb::Snowflake (readonly)
Returns The guild ID.
1162 1163 1164 |
# File 'lib/discorb/guild.rb', line 1162 def guild_id @guild_id end |
#json_url -> String (readonly)
Returns The JSON URL.
|
# File 'lib/discorb/guild.rb', line 1170
|
Instance Method Details
#edit(enabled: nil, channel: nil, reason: nil) -> Async::Task<void> Also known as: modify
Note:
The arguments of this method are defaultly set to Discorb::Unset
. Specify value to set the value, if not don't specify or specify Discorb::Unset
.
Edit the widget.
1209 1210 1211 1212 1213 1214 1215 1216 1217 |
# File 'lib/discorb/guild.rb', line 1209 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.request(Route.new("/guilds/#{@guild_id}/widget", "//guilds/:guild_id/widget", :patch), payload, audit_log_reason: reason).wait end end |
#iframe(theme: "dark", width: 350, height: 500) -> String
Return iframe HTML of the widget.
1234 1235 1236 1237 1238 1239 1240 1241 |
# File 'lib/discorb/guild.rb', line 1234 def iframe(theme: "dark", width: 350, height: 500) # rubocop:disable Layout/LineLength [ %(<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 # rubocop:enable Layout/LineLength end |