Class: RubyCord::Guild::ForumChannel::Post

Inherits:
ThreadChannel show all
Defined in:
lib/rubycord/guild/channel/forum.rb

Overview

Represents a thread in the forum channel.

Instance Attribute Summary collapse

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

#permission_overwrites, #position

Attributes inherited from Channel

#id, #name

Instance Method Summary collapse

Methods inherited from ThreadChannel

#add_member, #archive, #fetch_members, #guild, #inspect, #joined?, #lock, #me, #owner, #parent, #remove_member, #unarchive, #unlock

Methods included from Internal::Messageable

#delete_message, #edit_message, #fetch_message, #fetch_messages, #fetch_pins, #pin_message, #post, #typing, #unpin_message

Methods inherited from Channel

#<=>, #==, #create_invite, #delete, #delete_permissions, #fetch_invites, #guild, #inspect, #mention, #move, #parent, #set_permissions, #to_s

Methods inherited from Channel

#==, #inspect, #type

Methods inherited from DiscordModel

#==, #eql?, #inspect

Instance Attribute Details

#pinnedBoolean (readonly) Also known as: pinned?

Returns Whether the post is pinned.

Returns:

  • (Boolean)

    Whether the post is pinned.



116
117
118
# File 'lib/rubycord/guild/channel/forum.rb', line 116

def pinned
  @pinned
end

#tagsArray<RubyCord::Guild::ForumChannel::Tag> (readonly)

Returns The tags of the post.

Returns:



114
115
116
# File 'lib/rubycord/guild/channel/forum.rb', line 114

def tags
  @tags
end

Instance Method Details

#add_tags(*tags, reason: nil) ⇒ Async::Task<self>

Adds tags to the thread.

Parameters:

Returns:

  • (Async::Task<self>)

    The thread with added tags.

See Also:



218
219
220
# File 'lib/rubycord/guild/channel/forum.rb', line 218

def add_tags(*tags, reason: nil)
  edit(tags: self.tags + tags, reason:)
end

#edit(name: RubyCord::Unset, archived: RubyCord::Unset, auto_archive_duration: RubyCord::Unset, archive_in: RubyCord::Unset, locked: RubyCord::Unset, pinned: RubyCord::Unset, tags: RubyCord::Unset, reason: nil) ⇒ Async::Task<self>

Note:

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.

Edit the thread.

Parameters:

  • name (String) (defaults to: RubyCord::Unset)

    The name of the thread.

  • archived (Boolean) (defaults to: RubyCord::Unset)

    Whether the thread is archived or not.

  • auto_archive_duration (Integer) (defaults to: RubyCord::Unset)

    The auto archive duration in seconds.

  • archive_in (Integer) (defaults to: RubyCord::Unset)

    Alias of auto_archive_duration.

  • locked (Boolean) (defaults to: RubyCord::Unset)

    Whether the thread is locked or not.

  • reason (String) (defaults to: nil)

    The reason of editing the thread.

  • pinned (Boolean) (defaults to: RubyCord::Unset)

    Whether the thread is pinned or not.

  • tags (Array<RubyCord::Guild::ForumChannel::Tag>) (defaults to: RubyCord::Unset)

    The tags of the thread.

Returns:

  • (Async::Task<self>)

    The edited thread.

See Also:



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
174
175
# File 'lib/rubycord/guild/channel/forum.rb', line 144

def edit(
  name: RubyCord::Unset,
  archived: RubyCord::Unset,
  auto_archive_duration: RubyCord::Unset,
  archive_in: RubyCord::Unset,
  locked: RubyCord::Unset,
  pinned: RubyCord::Unset,
  tags: RubyCord::Unset,
  reason: nil
)
  Async do
    payload = {}
    payload[:name] = name if name != RubyCord::Unset
    payload[:archived] = archived if archived != RubyCord::Unset
    auto_archive_duration ||= archive_in
    payload[
      :auto_archive_duration
    ] = auto_archive_duration if auto_archive_duration != RubyCord::Unset
    payload[:locked] = locked if locked != RubyCord::Unset
    payload[:flags] = pinned ? 1 : 0 if pinned != RubyCord::Unset
    payload[:applied_tags] = tags.map(&:id) if tags != RubyCord::Unset
    @client
      .http
      .request(
        RubyCord::Internal::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.

Parameters:

  • reason (String) (defaults to: nil)

    The reason of pinning the thread.

Returns:

  • (Async::Task<self>)

    The pinned thread.

See Also:



188
189
190
# File 'lib/rubycord/guild/channel/forum.rb', line 188

def pin(reason: nil)
  edit(pinned: true, reason:)
end

#remove_tags(*tags, reason: nil) ⇒ Async::Task<self>

Removes tags from the thread.

Parameters:

Returns:

  • (Async::Task<self>)

    The thread with removed tags.

See Also:



233
234
235
# File 'lib/rubycord/guild/channel/forum.rb', line 233

def remove_tags(*tags, reason: nil)
  edit(tags: self.tags - tags, reason:)
end

#unpin(reason: nil) ⇒ Async::Task<self>

Unpins the thread.

Parameters:

  • reason (String) (defaults to: nil)

    The reason of unpinning the thread.

Returns:

  • (Async::Task<self>)

    The unpinned thread.

See Also:



203
204
205
# File 'lib/rubycord/guild/channel/forum.rb', line 203

def unpin(reason: nil)
  edit(pinned: false, reason:)
end