Class: Discorb::WelcomeScreen::Channel
- Inherits:
-
DiscordModel
- Object
- DiscordModel
- Discorb::WelcomeScreen::Channel
- Defined in:
- lib/discorb/guild.rb
Overview
Represents a channel to display the welcome screen.
Instance Attribute Summary collapse
- #channel -> nil, Discorb::Channel readonly
-
#description -> String
readonly
The channel's name.
-
#emoji -> Discorb::Emoji
readonly
The emoji to display.
Instance Method Summary collapse
-
#edit(enabled: :unset, channels: :unset, description: :unset, reason: nil) -> Object
Edits the welcome screen.
-
#initialize(channel, description, emoji) -> Channel
constructor
Initialize a new welcome screen channel.
-
#to_hash -> Hash
Converts the channel to a hash.
Methods inherited from DiscordModel
Constructor Details
#initialize(channel, description, emoji) -> Channel
Initialize a new welcome screen channel.
1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 |
# File 'lib/discorb/guild.rb', line 1206 def initialize(channel, description, emoji) if description.is_a?(Hash) @screen = channel data = description @channel_id = Snowflake.new(data[:channel_id]) @description = data[:description] @emoji_id = Snowflake.new(data[:emoji_id]) @emoji_name = data[:emoji_name] else @channel_id = channel.id @description = description if emoji.is_a?(UnicodeEmoji) @emoji_id = nil @emoji_name = emoji.value else @emoji_id = emoji.id @emoji_name = emoji.name end end end |
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 1193
|
#description -> String (readonly)
Returns The channel's name.
1191 1192 1193 |
# File 'lib/discorb/guild.rb', line 1191 def description @description end |
#emoji -> Discorb::Emoji (readonly)
Returns The emoji to display.
|
# File 'lib/discorb/guild.rb', line 1193
|
Instance Method Details
#edit(enabled: :unset, channels: :unset, description: :unset, reason: nil) -> Object
Note:
This is an asynchronous method, it will return a Async::Task
object. Use Async::Task#wait
to get the result.
Note:
This method calls HTTP request.
Note:
The arguments of this method are defaultly set to :unset
. Specify value to set the value, if not don't specify or specify :unset
.
Edits the welcome screen.
1265 1266 1267 1268 1269 1270 1271 1272 1273 |
# File 'lib/discorb/guild.rb', line 1265 def edit(enabled: :unset, channels: :unset, description: :unset, reason: nil) Async do payload = {} payload[:enabled] = enabled unless enabled == :unset payload[:welcome_channels] = channels.map(&:to_hash) unless channels == :unset payload[:description] = description unless description == :unset @client.http.patch("/guilds/#{@guild.id}/welcome-screen", payload, audit_log_reason: reason).wait end end |
#to_hash -> Hash
Converts the channel to a hash.
1233 1234 1235 1236 1237 1238 1239 1240 |
# File 'lib/discorb/guild.rb', line 1233 def to_hash { channel_id: @channel_id, description: @description, emoji_id: @emoji_id, emoji_name: @emoji_name, } end |