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: Discorb::Unset, channels: Discorb::Unset, description: Discorb::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.
1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 |
# File 'lib/discorb/guild.rb', line 1552 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 1539
|
#description -> String (readonly)
Returns The channel's name.
1537 1538 1539 |
# File 'lib/discorb/guild.rb', line 1537 def description @description end |
#emoji -> Discorb::Emoji (readonly)
Returns The emoji to display.
|
# File 'lib/discorb/guild.rb', line 1539
|
Instance Method Details
#edit(enabled: Discorb::Unset, channels: Discorb::Unset, description: Discorb::Unset, reason: nil) -> Async::Task<void>
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
.
Edits the welcome screen.
1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 |
# File 'lib/discorb/guild.rb', line 1612 def edit(enabled: Discorb::Unset, channels: Discorb::Unset, description: Discorb::Unset, reason: nil) Async do payload = {} payload[:enabled] = enabled unless enabled == Discorb::Unset payload[:welcome_channels] = channels.map(&:to_hash) unless channels == Discorb::Unset payload[:description] = description unless description == Discorb::Unset @client.http.request( 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.
1579 1580 1581 1582 1583 1584 1585 1586 |
# File 'lib/discorb/guild.rb', line 1579 def to_hash { channel_id: @channel_id, description: @description, emoji_id: @emoji_id, emoji_name: @emoji_name, } end |