Skip to content

Commit

Permalink
Add: Add ForumChannel#default_forum_view
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Jul 27, 2024
1 parent a5a7125 commit 0f4179c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/discorb/channel/forum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class ForumChannel < GuildChannel
attr_reader :default_auto_archive_duration
# @return [:latest_activity, :creation_date] The default sort order of the channel.
attr_reader :default_sort_order
# @return [nil, :list_view, :gallery_view] The default view of the channel.
attr_reader :default_forum_view
# @return [Array<Discorb::ForumChannel::Tag>] The tags in the channel.
attr_reader :tags
# @return [Boolean] Whether at least one tag is required.
Expand All @@ -36,6 +38,7 @@ def threads
end

DEFAULT_SORT_ORDER = { 1 => :latest_activity, 2 => :creation_date }.freeze
DEFAULT_FORUM_VIEW = { 0 => nil, 1 => :list_view, 2 => :gallery_view }.freeze

#
# Represents a tag in the forum channel.
Expand Down Expand Up @@ -271,6 +274,7 @@ def inspect
# @param [Boolean] require_tag Whether the channel requires tag to create thread.
# @param [Discorb::Emoji] default_reaction_emoji The default reaction emoji of the channel.
# @param [:latest_activity, :creation_date] default_sort_order The default sort order of the channel.
# @param [nil, :list_view, :gallery_view] default_forum_view The default view of the channel.
# @param [Array<Discorb::ForumChannel::Tag>] tags The tags of the channel.
# @param [String] reason The reason of editing the channel.
#
Expand All @@ -296,6 +300,7 @@ def edit(
require_tag: Discorb::Unset,
default_reaction_emoji: Discorb::Unset,
default_sort_order: Discorb::Unset,
default_forum_view: Discorb::Unset,
tags: Discorb::Unset,
reason: nil
)
Expand Down Expand Up @@ -337,6 +342,9 @@ def edit(
payload[:default_sort_order] = DEFAULT_SORT_ORDER.key(
default_sort_order
) unless default_sort_order == Discorb::Unset
payload[:default_forum_view] = DEFAULT_FORUM_VIEW.key(
default_forum_view
) unless default_forum_view == Discorb::Unset
payload[:available_tags] = tags.map(&:to_hash) unless tags ==
Discorb::Unset
ret =
Expand Down
5 changes: 5 additions & 0 deletions sig/discorb/channel/forum.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ module Discorb
# @return [:latest_activity, :creation_date] The default sort order of the channel.
attr_reader default_sort_order: :latest_activity | :creation_date

# @return [nil, :list_view, :gallery_view] The default view of the channel.
attr_reader default_forum_view: nil | :list_view | :gallery_view

# @return [Array<Discorb::ForumChannel::Tag>] The tags in the channel.
attr_reader tags: Array[Discorb::ForumChannel::Tag]

Expand Down Expand Up @@ -192,6 +195,7 @@ module Discorb
# @param [Integer] thread_slowmode Alias of `thread_rate_limit_per_user`.
# @param [Integer] default_auto_archive_duration The default auto archive duration of the channel.
# @param [Integer] archive_in Alias of `default_auto_archive_duration`.
# @param [nil, :list_view, :gallery_view] default_forum_view The default view of the channel.
# @param [Boolean] require_tag Whether the channel requires tag to create thread.
# @param [Discorb::Emoji] default_reaction_emoji The default reaction emoji of the channel.
# @param [:latest_activity, :creation_date] default_sort_order The default sort order of the channel.
Expand All @@ -216,6 +220,7 @@ module Discorb
?thread_slowmode: Integer,
?default_auto_archive_duration: Integer,
?archive_in: Integer,
?default_forum_view: nil | :list_view | :gallery_view,
?require_tag: bool,
?default_reaction_emoji: Discorb::emoji,
?default_sort_order: :latest_activity | :creation_date,
Expand Down

0 comments on commit 0f4179c

Please # to comment.