Class: Discorb::ForumChannel::Post
- Inherits:
-
ThreadChannel
- Object
- DiscordModel
- Channel
- ThreadChannel
- Discorb::ForumChannel::Post
- Defined in:
- lib/discorb/channel/forum.rb
Overview
Represents a thread in the forum channel.
Instance Attribute Summary collapse
-
#pinned -> Boolean
(also: #pinned?)
readonly
Whether the post is pinned.
-
#tags -> Array<Discorb::ForumChannel::Tag>
readonly
The tags of the post.
Attributes inherited from ThreadChannel
#archived, #archived_timestamp, #auto_archive_duration, #id, #member_count, #members, #message_count, #name, #rate_limit_per_user
Attributes inherited from Channel
Instance Method Summary collapse
-
#add_tags(*tags, reason: nil) -> Async::Task<self>
Adds tags to the thread.
-
#edit(name: Discorb::Unset, archived: Discorb::Unset, auto_archive_duration: Discorb::Unset, archive_in: Discorb::Unset, locked: Discorb::Unset, pinned: Discorb::Unset, tags: Discorb::Unset, reason: nil) -> Async::Task<self>
Edit the thread.
-
#pin(reason: nil) -> Async::Task<self>
Pins the thread.
-
#remove_tags(*tags, reason: nil) -> Async::Task<self>
Removes tags from the thread.
-
#unpin(reason: nil) -> Async::Task<self>
Unpins the thread.
Methods inherited from ThreadChannel
#add_member, #archive, #fetch_members, #guild, #inspect, #joined?, #lock, #me, #owner, #parent, #remove_member, #unarchive, #unlock
Methods included from Messageable
#delete_message, #edit_message, #fetch_message, #fetch_messages, #fetch_pins, #pin_message, #post, #typing, #unpin_message
Methods inherited from Channel
Methods inherited from DiscordModel
Instance Attribute Details
#pinned -> Boolean (readonly) Also known as: pinned?
Returns Whether the post is pinned.
114 115 116 |
# File 'lib/discorb/channel/forum.rb', line 114 def pinned @pinned end |
#tags -> Array<Discorb::ForumChannel::Tag> (readonly)
Returns The tags of the post.
112 113 114 |
# File 'lib/discorb/channel/forum.rb', line 112 def @tags end |
Instance Method Details
#add_tags(*tags, reason: nil) -> Async::Task<self>
Adds tags to the thread.
216 217 218 |
# File 'lib/discorb/channel/forum.rb', line 216 def (*, reason: nil) edit(tags: self. + , reason: reason) end |
#edit(name: Discorb::Unset, archived: Discorb::Unset, auto_archive_duration: Discorb::Unset, archive_in: Discorb::Unset, locked: Discorb::Unset, pinned: Discorb::Unset, tags: Discorb::Unset, reason: nil) -> Async::Task<self>
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
.
Edit the thread.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/discorb/channel/forum.rb', line 142 def edit( name: Discorb::Unset, archived: Discorb::Unset, auto_archive_duration: Discorb::Unset, archive_in: Discorb::Unset, locked: Discorb::Unset, pinned: Discorb::Unset, tags: Discorb::Unset, reason: nil ) Async do payload = {} payload[:name] = name if name != Discorb::Unset payload[:archived] = archived if archived != Discorb::Unset auto_archive_duration ||= archive_in payload[ :auto_archive_duration ] = auto_archive_duration if auto_archive_duration != Discorb::Unset payload[:locked] = locked if locked != Discorb::Unset payload[:flags] = pinned ? 1 : 0 if pinned != Discorb::Unset payload[:applied_tags] = .map(&:id) if != Discorb::Unset @client .http .request( Route.new("/channels/#{@id}", "//channels/:channel_id", :patch), payload, audit_log_reason: reason ) .wait self end end |
#pin(reason: nil) -> Async::Task<self>
Pins the thread.
186 187 188 |
# File 'lib/discorb/channel/forum.rb', line 186 def pin(reason: nil) edit(pinned: true, reason: reason) end |
#remove_tags(*tags, reason: nil) -> Async::Task<self>
Removes tags from the thread.
231 232 233 |
# File 'lib/discorb/channel/forum.rb', line 231 def (*, reason: nil) edit(tags: self. - , reason: reason) end |
#unpin(reason: nil) -> Async::Task<self>
Unpins the thread.
201 202 203 |
# File 'lib/discorb/channel/forum.rb', line 201 def unpin(reason: nil) edit(pinned: false, reason: reason) end |