Class: RubyCord::Guild::ForumChannel
- Inherits:
-
Channel
- Object
- DiscordModel
- Channel
- Channel
- RubyCord::Guild::ForumChannel
- Defined in:
- lib/rubycord/guild/channel/forum.rb
Defined Under Namespace
Constant Summary collapse
- DEFAULT_SORT_ORDER =
{ 1 => :latest_activity, 2 => :creation_date }.freeze
Instance Attribute Summary collapse
-
#default_auto_archive_duration ⇒ Integer
readonly
The default value of duration of auto archive.
-
#default_sort_order ⇒ :latest_activity, :creation_date
readonly
The default sort order of the channel.
-
#guideline ⇒ String
(also: #topic)
readonly
The guideline of the channel.
-
#message_rate_limit_per_user ⇒ Integer
(also: #message_slowmode)
readonly
The rate limit to send message per user (Slowmode) in the channel.
-
#nsfw ⇒ Boolean
readonly
Whether the channel is nsfw.
-
#rate_limit_per_user ⇒ Integer
(also: #slowmode, #thread_slowmode)
readonly
The rate limit to create thread per user (Slowmode) in the channel.
-
#require_tag ⇒ Boolean
(also: #require_tag?)
readonly
Whether at least one tag is required.
-
#tags ⇒ Array<RubyCord::Guild::ForumChannel::Tag>
readonly
The tags in the channel.
- #threads ⇒ Object readonly
Attributes inherited from Channel
#permission_overwrites, #position
Attributes inherited from Channel
Instance Method Summary collapse
-
#create_post(title, content = nil, embed: nil, embeds: nil, allowed_mentions: nil, components: nil, attachment: nil, attachments: nil, tags: nil, auto_archive_duration: nil, rate_limit_per_user: nil, slowmode: nil, reason: nil) ⇒ Async::Task<RubyCord::Guild::ForumChannel::Post>
(also: #start_thread)
Create post in the channel.
-
#create_tags(*tags, reason: nil) ⇒ Async::Task<self>
Creates tags in the channel.
-
#create_webhook(name, avatar: nil) ⇒ Async::Task<RubyCord::Guild::Webhook::IncomingWebhook>
Create webhook in the channel.
-
#delete_tags(*tags, reason: nil) ⇒ Async::Task<self>
Deletes tags from the channel.
-
#edit(name: RubyCord::Unset, position: RubyCord::Unset, category: RubyCord::Unset, parent: RubyCord::Unset, topic: RubyCord::Unset, guideline: RubyCord::Unset, nsfw: RubyCord::Unset, rate_limit_per_user: RubyCord::Unset, slowmode: RubyCord::Unset, thread_rate_limit_per_user: RubyCord::Unset, thread_slowmode: RubyCord::Unset, default_auto_archive_duration: RubyCord::Unset, archive_in: RubyCord::Unset, require_tag: RubyCord::Unset, default_reaction_emoji: RubyCord::Unset, default_sort_order: RubyCord::Unset, tags: RubyCord::Unset, reason: nil) ⇒ Async::Task<self>
(also: #modify)
Edits the channel.
-
#fetch_archived_threads ⇒ Async::Task<Array<RubyCord::Guild::ThreadChannel>>
Fetch archived threads in the channel.
-
#fetch_webhooks ⇒ Async::Task<Array<RubyCord::Guild::Webhook>>
Fetch webhooks in the channel.
-
#initialize(client, data, no_cache: false) ⇒ ForumChannel
constructor
A new instance of ForumChannel.
-
#inspect ⇒ String
Object class and attributes.
Methods inherited from Channel
#<=>, #==, #create_invite, #delete, #delete_permissions, #fetch_invites, #guild, #mention, #move, #parent, #set_permissions, #to_s
Methods inherited from Channel
Methods inherited from DiscordModel
Constructor Details
#initialize(client, data, no_cache: false) ⇒ ForumChannel
Returns a new instance of ForumChannel.
246 247 248 249 |
# File 'lib/rubycord/guild/channel/forum.rb', line 246 def initialize(client, data, no_cache: false) super _set_data(data) end |
Instance Attribute Details
#default_auto_archive_duration ⇒ Integer (readonly)
Returns The default value of duration of auto archive.
22 23 24 |
# File 'lib/rubycord/guild/channel/forum.rb', line 22 def default_auto_archive_duration @default_auto_archive_duration end |
#default_sort_order ⇒ :latest_activity, :creation_date (readonly)
Returns The default sort order of the channel.
24 25 26 |
# File 'lib/rubycord/guild/channel/forum.rb', line 24 def default_sort_order @default_sort_order end |
#guideline ⇒ String (readonly) Also known as: topic
Returns The guideline of the channel.
10 11 12 |
# File 'lib/rubycord/guild/channel/forum.rb', line 10 def guideline @guideline end |
#message_rate_limit_per_user ⇒ Integer (readonly) Also known as: message_slowmode
Returns The rate limit to send message per user (Slowmode) in the channel.
19 20 21 |
# File 'lib/rubycord/guild/channel/forum.rb', line 19 def end |
#nsfw ⇒ Boolean (readonly)
Returns Whether the channel is nsfw.
13 14 15 |
# File 'lib/rubycord/guild/channel/forum.rb', line 13 def nsfw @nsfw end |
#rate_limit_per_user ⇒ Integer (readonly) Also known as: slowmode, thread_slowmode
Returns The rate limit to create thread per user (Slowmode) in the channel.
15 16 17 |
# File 'lib/rubycord/guild/channel/forum.rb', line 15 def rate_limit_per_user @rate_limit_per_user end |
#require_tag ⇒ Boolean (readonly) Also known as: require_tag?
Returns Whether at least one tag is required.
28 29 30 |
# File 'lib/rubycord/guild/channel/forum.rb', line 28 def require_tag @require_tag end |
#tags ⇒ Array<RubyCord::Guild::ForumChannel::Tag> (readonly)
Returns The tags in the channel.
26 27 28 |
# File 'lib/rubycord/guild/channel/forum.rb', line 26 def end |
#threads ⇒ Object (readonly)
35 36 37 |
# File 'lib/rubycord/guild/channel/forum.rb', line 35 def threads guild.threads.select { |thread| thread.parent == self } end |
Instance Method Details
#create_post(title, content = nil, embed: nil, embeds: nil, allowed_mentions: nil, components: nil, attachment: nil, attachments: nil, tags: nil, auto_archive_duration: nil, rate_limit_per_user: nil, slowmode: nil, reason: nil) ⇒ Async::Task<RubyCord::Guild::ForumChannel::Post> Also known as: start_thread
Create post in the channel.
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
# File 'lib/rubycord/guild/channel/forum.rb', line 472 def create_post( title, content = nil, embed: nil, embeds: nil, allowed_mentions: nil, components: nil, attachment: nil, attachments: nil, tags: nil, auto_archive_duration: nil, rate_limit_per_user: nil, slowmode: nil, reason: nil ) Async do = {} [:content] = content if content = if [] elsif end [:embeds] = .map(&:to_hash) if [:allowed_mentions] = ( if allowed_mentions allowed_mentions.to_hash(@client.allowed_mentions) else @client.allowed_mentions.to_hash end ) [:components] = Component.to_payload( components ) if components ||= ? [] : [] [:attachments] = .map.with_index do |a, i| { id: i, filename: a.filename, description: a.description } end payload = {} payload[:name] = title payload[ :auto_archive_duration ] = auto_archive_duration if auto_archive_duration payload[:rate_limit_per_user] = rate_limit_per_user || slowmode if rate_limit_per_user || slowmode payload[:message] = payload[:applied_tags] = .map(&:id) if _resp, data = @client .http .multipart_request( RubyCord::Internal::Route.new( "/channels/#{channel_id.wait}/threads", "//channels/:channel_id/threads", :post ), payload, , audit_log_reason: reason ) .wait Channel.make_channel(@client, data) end end |
#create_tags(*tags, reason: nil) ⇒ Async::Task<self>
Creates tags in the channel.
381 382 383 |
# File 'lib/rubycord/guild/channel/forum.rb', line 381 def (*, reason: nil) edit(tags: self. + , reason:) end |
#create_webhook(name, avatar: nil) ⇒ Async::Task<RubyCord::Guild::Webhook::IncomingWebhook>
Create webhook in the channel.
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
# File 'lib/rubycord/guild/channel/forum.rb', line 409 def create_webhook(name, avatar: nil) Async do payload = {} payload[:name] = name payload[:avatar] = avatar.to_s if avatar _resp, data = @client .http .request( RubyCord::Internal::Route.new( "/channels/#{@id}/webhooks", "//channels/:channel_id/webhooks", :post ), payload ) .wait Guild::Webhook.from_data(@client, data) end end |
#delete_tags(*tags, reason: nil) ⇒ Async::Task<self>
Deletes tags from the channel.
396 397 398 |
# File 'lib/rubycord/guild/channel/forum.rb', line 396 def (*, reason: nil) edit(tags: self. - , reason:) end |
#edit(name: RubyCord::Unset, position: RubyCord::Unset, category: RubyCord::Unset, parent: RubyCord::Unset, topic: RubyCord::Unset, guideline: RubyCord::Unset, nsfw: RubyCord::Unset, rate_limit_per_user: RubyCord::Unset, slowmode: RubyCord::Unset, thread_rate_limit_per_user: RubyCord::Unset, thread_slowmode: RubyCord::Unset, default_auto_archive_duration: RubyCord::Unset, archive_in: RubyCord::Unset, require_tag: RubyCord::Unset, default_reaction_emoji: RubyCord::Unset, default_sort_order: RubyCord::Unset, tags: RubyCord::Unset, reason: nil) ⇒ Async::Task<self> Also known as: modify
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 channel.
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/rubycord/guild/channel/forum.rb', line 285 def edit( name: RubyCord::Unset, position: RubyCord::Unset, category: RubyCord::Unset, parent: RubyCord::Unset, topic: RubyCord::Unset, guideline: RubyCord::Unset, nsfw: RubyCord::Unset, rate_limit_per_user: RubyCord::Unset, slowmode: RubyCord::Unset, thread_rate_limit_per_user: RubyCord::Unset, thread_slowmode: RubyCord::Unset, default_auto_archive_duration: RubyCord::Unset, archive_in: RubyCord::Unset, require_tag: RubyCord::Unset, default_reaction_emoji: RubyCord::Unset, default_sort_order: RubyCord::Unset, tags: RubyCord::Unset, reason: nil ) Async do payload = {} payload[:name] = name unless name == RubyCord::Unset payload[:position] = position unless position == RubyCord::Unset payload[:parent_id] = category.id unless category == RubyCord::Unset payload[:parent_id] = parent.id unless parent == RubyCord::Unset payload[:topic] = topic unless topic == RubyCord::Unset payload[:topic] = guideline unless guideline == RubyCord::Unset payload[:nsfw] = nsfw unless nsfw == RubyCord::Unset payload[ :rate_limit_per_user ] = rate_limit_per_user unless rate_limit_per_user == RubyCord::Unset payload[:rate_limit_per_user] = slowmode unless slowmode == RubyCord::Unset payload[ :thread_rate_limit_per_user ] = thread_rate_limit_per_user unless thread_rate_limit_per_user == RubyCord::Unset payload[ :thread_rate_limit_per_user ] = thread_slowmode unless thread_slowmode == RubyCord::Unset payload[ :default_auto_archive_duration ] = default_auto_archive_duration unless default_auto_archive_duration == RubyCord::Unset payload[ :default_auto_archive_duration ] = archive_in unless archive_in == RubyCord::Unset payload[:flags] = (require_tag ? 1 << 4 : 0) unless require_tag == RubyCord::Unset payload[:default_reaction_emoji] = default_reaction_emoji .to_hash .then do |e| { emoji_name: e[:name], emoji_id: e[:id] } end unless default_reaction_emoji == RubyCord::Unset payload[:default_sort_order] = DEFAULT_SORT_ORDER.key( default_sort_order ) unless default_sort_order == RubyCord::Unset payload[:available_tags] = .map(&:to_hash) unless == RubyCord::Unset ret = @client .http .request( RubyCord::Internal::Route.new("/channels/#{id}", "//channels/:channel_id", :patch), reason: ) .wait _set_data(ret) if != RubyCord::Unset .reject(&:id) .each do |tag| tag.instance_variable_set( :@id, ret[:available_tags].find { |t| t.to_hash == tag.to_hash }[:id] ) end end self end end |
#fetch_archived_threads ⇒ Async::Task<Array<RubyCord::Guild::ThreadChannel>>
Fetch archived threads in the channel.
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/rubycord/guild/channel/forum.rb', line 550 def fetch_archived_threads Async do _resp, data = @client .http .request( RubyCord::Internal::Route.new( "/channels/#{@id}/threads/archived/public", "//channels/:channel_id/threads/archived/public", :get ) ) .wait data.map { |thread| Channel.make_channel(@client, thread) } end end |
#fetch_webhooks ⇒ Async::Task<Array<RubyCord::Guild::Webhook>>
Fetch webhooks in the channel.
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
# File 'lib/rubycord/guild/channel/forum.rb', line 436 def fetch_webhooks Async do _resp, data = @client .http .request( RubyCord::Internal::Route.new( "/channels/#{@id}/webhooks", "//channels/:channel_id/webhooks", :get ) ) .wait data.map { |webhook| Webhook.from_data(@client, webhook) } end end |
#inspect ⇒ String
Returns Object class and attributes.
252 253 254 |
# File 'lib/rubycord/guild/channel/forum.rb', line 252 def inspect "#<#{self.class}: #{name} id=#{id}>" end |