Class: DiscordRDA::ChannelBuilder
- Inherits:
-
Object
- Object
- DiscordRDA::ChannelBuilder
- Defined in:
- lib/discord_rda/entity/channel_builder.rb
Overview
DSL for building channel modifications. Provides a fluent interface for modifying channel properties.
Instance Attribute Summary collapse
-
#data ⇒ Hash
readonly
Channel data being built.
Instance Method Summary collapse
-
#add_overwrite(id:, type:, allow: 0, deny: 0) ⇒ self
Add a single permission overwrite.
-
#available_tags(tags) ⇒ self
Set available tags (for forum channels).
-
#bitrate(bitrate) ⇒ self
Set channel bitrate (for voice channels).
-
#build ⇒ Hash
Build and return the channel data.
-
#default_auto_archive_duration(minutes) ⇒ self
Set default auto archive duration (for threads).
-
#default_forum_layout(layout) ⇒ self
Set default forum layout (for forum channels).
-
#default_reaction_emoji(emoji) ⇒ self
Set default reaction emoji (for forum channels).
-
#default_sort_order(order) ⇒ self
Set default sort order (for forum channels).
-
#default_thread_slowmode(seconds) ⇒ self
Set default thread rate limit per user.
-
#flags(flags) ⇒ self
Set channel flags.
-
#initialize(name = nil) ⇒ ChannelBuilder
constructor
Initialize a new channel builder.
-
#name(name) ⇒ self
Set channel name.
-
#nsfw(nsfw = true) ⇒ self
Set NSFW flag.
-
#parent(category_id) ⇒ self
Set parent category ID.
-
#permission_overwrites(overwrites) ⇒ self
Set permission overwrites.
-
#position(position) ⇒ self
Set channel position.
-
#slowmode(seconds) ⇒ self
Set rate limit per user (slowmode).
-
#to_h ⇒ Hash
Convert builder to hash.
-
#topic(topic) ⇒ self
Set channel topic.
-
#type(type) ⇒ self
Set channel type.
-
#user_limit(limit) ⇒ self
Set user limit (for voice channels).
-
#video_quality_mode(mode) ⇒ self
Set video quality mode (for voice channels).
Constructor Details
#initialize(name = nil) ⇒ ChannelBuilder
Initialize a new channel builder
13 14 15 16 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 13 def initialize(name = nil) @data = {} @data[:name] = name if name end |
Instance Attribute Details
#data ⇒ Hash (readonly)
Returns Channel data being built.
9 10 11 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 9 def data @data end |
Instance Method Details
#add_overwrite(id:, type:, allow: 0, deny: 0) ⇒ self
Add a single permission overwrite
120 121 122 123 124 125 126 127 128 129 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 120 def add_overwrite(id:, type:, allow: 0, deny: 0) @data[:permission_overwrites] ||= [] @data[:permission_overwrites] << { id: id.to_s, type: type, allow: allow.is_a?(Integer) ? allow.to_s : allow, deny: deny.is_a?(Integer) ? deny.to_s : deny } self end |
#available_tags(tags) ⇒ self
Set available tags (for forum channels)
142 143 144 145 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 142 def () @data[:available_tags] = self end |
#bitrate(bitrate) ⇒ self
Set channel bitrate (for voice channels)
45 46 47 48 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 45 def bitrate(bitrate) @data[:bitrate] = bitrate self end |
#build ⇒ Hash
Build and return the channel data
187 188 189 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 187 def build to_h end |
#default_auto_archive_duration(minutes) ⇒ self
Set default auto archive duration (for threads)
93 94 95 96 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 93 def default_auto_archive_duration(minutes) @data[:default_auto_archive_duration] = minutes self end |
#default_forum_layout(layout) ⇒ self
Set default forum layout (for forum channels)
158 159 160 161 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 158 def default_forum_layout(layout) @data[:default_forum_layout] = layout self end |
#default_reaction_emoji(emoji) ⇒ self
Set default reaction emoji (for forum channels)
166 167 168 169 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 166 def default_reaction_emoji(emoji) @data[:default_reaction_emoji] = emoji self end |
#default_sort_order(order) ⇒ self
Set default sort order (for forum channels)
150 151 152 153 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 150 def default_sort_order(order) @data[:default_sort_order] = order self end |
#default_thread_slowmode(seconds) ⇒ self
Set default thread rate limit per user
101 102 103 104 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 101 def default_thread_slowmode(seconds) @data[:default_thread_rate_limit_per_user] = seconds self end |
#flags(flags) ⇒ self
Set channel flags
134 135 136 137 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 134 def flags(flags) @data[:flags] = flags self end |
#name(name) ⇒ self
Set channel name
21 22 23 24 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 21 def name(name) @data[:name] = name self end |
#nsfw(nsfw = true) ⇒ self
Set NSFW flag
85 86 87 88 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 85 def nsfw(nsfw = true) @data[:nsfw] = nsfw self end |
#parent(category_id) ⇒ self
Set parent category ID
77 78 79 80 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 77 def parent(category_id) @data[:parent_id] = category_id.to_s self end |
#permission_overwrites(overwrites) ⇒ self
Set permission overwrites
109 110 111 112 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 109 def (overwrites) @data[:permission_overwrites] = overwrites.map { |o| normalize_overwrite(o) } self end |
#position(position) ⇒ self
Set channel position
69 70 71 72 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 69 def position(position) @data[:position] = position self end |
#slowmode(seconds) ⇒ self
Set rate limit per user (slowmode)
61 62 63 64 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 61 def slowmode(seconds) @data[:rate_limit_per_user] = seconds self end |
#to_h ⇒ Hash
Convert builder to hash
181 182 183 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 181 def to_h @data.dup end |
#topic(topic) ⇒ self
Set channel topic
37 38 39 40 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 37 def topic(topic) @data[:topic] = topic self end |
#type(type) ⇒ self
Set channel type
29 30 31 32 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 29 def type(type) @data[:type] = type.is_a?(Symbol) ? Channel::TYPES[type] : type self end |
#user_limit(limit) ⇒ self
Set user limit (for voice channels)
53 54 55 56 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 53 def user_limit(limit) @data[:user_limit] = limit self end |
#video_quality_mode(mode) ⇒ self
Set video quality mode (for voice channels)
174 175 176 177 |
# File 'lib/discord_rda/entity/channel_builder.rb', line 174 def video_quality_mode(mode) @data[:video_quality_mode] = mode self end |