Class: RubyCord::Guild::WelcomeScreen::Channel
- Inherits:
-
DiscordModel
- Object
- DiscordModel
- RubyCord::Guild::WelcomeScreen::Channel
- Defined in:
- lib/rubycord/guild/welcome_screen.rb
Overview
Represents a channel to display the welcome screen.
Instance Attribute Summary collapse
- #channel ⇒ nil, RubyCord::Channel readonly
-
#description ⇒ String
readonly
The channel's name.
-
#emoji ⇒ RubyCord::Emoji
readonly
The emoji to display.
Instance Method Summary collapse
-
#edit(enabled: RubyCord::Unset, channels: RubyCord::Unset, description: RubyCord::Unset, reason: nil) ⇒ Async::Task<void>
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.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/rubycord/guild/welcome_screen.rb', line 68 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, RubyCord::Channel (readonly)
Note:
This method returns an object from client cache. it will return nil
if the object is not in cache.
|
# File 'lib/rubycord/guild/welcome_screen.rb', line 55
|
#description ⇒ String (readonly)
Returns The channel's name.
53 54 55 |
# File 'lib/rubycord/guild/welcome_screen.rb', line 53 def description @description end |
#emoji ⇒ RubyCord::Emoji (readonly)
Returns The emoji to display.
|
# File 'lib/rubycord/guild/welcome_screen.rb', line 55
|
Instance Method Details
#edit(enabled: RubyCord::Unset, channels: RubyCord::Unset, description: RubyCord::Unset, reason: nil) ⇒ Async::Task<void>
Note:
The arguments of this method are defaultly set to RubyCord::Unset
.
Specify value to set the value, if not don't specify or specify RubyCord::Unset
.
Edits the welcome screen.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/rubycord/guild/welcome_screen.rb', line 128 def edit( enabled: RubyCord::Unset, channels: RubyCord::Unset, description: RubyCord::Unset, reason: nil ) Async do payload = {} payload[:enabled] = enabled unless enabled == RubyCord::Unset payload[:welcome_channels] = channels.map( &:to_hash ) unless channels == RubyCord::Unset payload[:description] = description unless description == RubyCord::Unset @client .http .request( RubyCord::Internal::Route.new( "/guilds/#{@guild.id}/welcome-screen", "//guilds/:guild_id/welcome-screen", :patch ), payload, audit_log_reason: reason ) .wait end end |
#to_hash ⇒ Hash
Converts the channel to a hash.
95 96 97 98 99 100 101 102 |
# File 'lib/rubycord/guild/welcome_screen.rb', line 95 def to_hash { channel_id: @channel_id, description: @description, emoji_id: @emoji_id, emoji_name: @emoji_name } end |