Class: Discorb::ThreadChannel Abstract
- Inherits:
-
Channel
- Object
- DiscordModel
- Channel
- Discorb::ThreadChannel
- Includes:
- Messageable
- Defined in:
- lib/discorb/channel.rb
Overview
Represents a thread.
Defined Under Namespace
Classes: Member, News, Private, Public
Class Attribute Summary collapse
-
.channel_type -> Object
readonly
Returns the value of attribute channel_type.
Instance Attribute Summary collapse
-
#archived -> Boolean
(also: #archived?)
readonly
Whether the thread is archived or not.
- #archived_timestamp -> Time? (also: #archived_at) readonly
-
#auto_archive_duration -> Integer
(also: #archive_in)
readonly
Auto archive duration in seconds.
- #guild -> nil, Discorb::Guild readonly
-
#id -> Discorb::Snowflake
readonly
The ID of the channel.
-
#joined? -> Boolean
readonly
Whether the bot is in the thread or not.
- #me -> Discorb::ThreadChannel::Member? readonly
-
#member_count -> Integer
(also: #recipient_count)
readonly
The number of recipients in the thread.
-
#members -> Array<Discorb::ThreadChannel::Member>
readonly
The members of the thread.
-
#message_count -> Integer
readonly
The number of messages in the thread.
-
#name -> String
readonly
The name of the thread.
- #owner -> nil, Discorb::Member readonly
- #parent -> nil, Discorb::GuildChannel (also: #channel) readonly
-
#rate_limit_per_user -> Integer
(also: #slowmode)
readonly
The rate limit per user (slowmode) in the thread.
Instance Method Summary collapse
-
#add_member(member = :me) -> Async::Task<void>
(also: #join)
Add a member to the thread.
-
#archive(reason: nil) -> self
Helper method to archive the thread.
-
#edit(name: Discorb::Unset, archived: Discorb::Unset, auto_archive_duration: Discorb::Unset, archive_in: Discorb::Unset, locked: Discorb::Unset, reason: nil) -> Async::Task<self>
Edit the thread.
-
#fetch_members -> Array<Discorb::ThreadChannel::Member>
Fetch members in the thread.
- #inspect -> Object
-
#lock(reason: nil) -> self
Helper method to lock the thread.
-
#remove_member(member = :me) -> Async::Task<void>
(also: #leave)
Remove a member from the thread.
-
#unarchive(reason: nil) -> self
Helper method to unarchive the thread.
-
#unlock(reason: nil) -> self
Helper method to unlock the thread.
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
Class Attribute Details
.channel_type -> Object (readonly)
Returns the value of attribute channel_type.
980 981 982 |
# File 'lib/discorb/channel.rb', line 980 def channel_type @channel_type end |
Instance Attribute Details
#archived -> Boolean (readonly) Also known as: archived?
Returns Whether the thread is archived or not.
779 780 781 |
# File 'lib/discorb/channel.rb', line 779 def archived @archived end |
#archived_timestamp -> Time? (readonly) Also known as: archived_at
773 774 775 |
# File 'lib/discorb/channel.rb', line 773 def @archived_timestamp end |
#auto_archive_duration -> Integer (readonly) Also known as: archive_in
Returns Auto archive duration in seconds.
776 777 778 |
# File 'lib/discorb/channel.rb', line 776 def auto_archive_duration @auto_archive_duration end |
#guild -> nil, Discorb::Guild (readonly)
This method returns an object from client cache. it will return nil
if the object is not in cache.
|
# File 'lib/discorb/channel.rb', line 782
|
#id -> Discorb::Snowflake (readonly)
This ID is same as the starter message's ID
Returns The ID of the channel.
756 757 758 |
# File 'lib/discorb/channel.rb', line 756 def id @id end |
#joined? -> Boolean (readonly)
Returns Whether the bot is in the thread or not.
|
# File 'lib/discorb/channel.rb', line 782
|
#member_count -> Integer (readonly) Also known as: recipient_count
This will stop counting at 50.
Returns The number of recipients in the thread.
764 765 766 |
# File 'lib/discorb/channel.rb', line 764 def member_count @member_count end |
#members -> Array<Discorb::ThreadChannel::Member> (readonly)
Returns The members of the thread.
770 771 772 |
# File 'lib/discorb/channel.rb', line 770 def members @members end |
#message_count -> Integer (readonly)
This will stop counting at 50.
Returns The number of messages in the thread.
761 762 763 |
# File 'lib/discorb/channel.rb', line 761 def @message_count end |
#name -> String (readonly)
Returns The name of the thread.
758 759 760 |
# File 'lib/discorb/channel.rb', line 758 def name @name end |
#owner -> nil, Discorb::Member (readonly)
This method returns an object from client cache. it will return nil
if the object is not in cache.
You must enable GUILD_MEMBERS
intent to use this method.
|
# File 'lib/discorb/channel.rb', line 782
|
#parent -> nil, Discorb::GuildChannel (readonly) Also known as: channel
This method returns an object from client cache. it will return nil
if the object is not in cache.
|
# File 'lib/discorb/channel.rb', line 782
|
#rate_limit_per_user -> Integer (readonly) Also known as: slowmode
Returns The rate limit per user (slowmode) in the thread.
767 768 769 |
# File 'lib/discorb/channel.rb', line 767 def rate_limit_per_user @rate_limit_per_user end |
Instance Method Details
#add_member(member = :me) -> Async::Task<void> Also known as: join
Add a member to the thread.
924 925 926 927 928 929 930 931 932 |
# File 'lib/discorb/channel.rb', line 924 def add_member(member = :me) Async do if member == :me @client.http.post("/channels/#{@id}/thread-members/@me").wait else @client.http.post("/channels/#{@id}/thread-members/#{Utils.try(member, :id)}").wait end end end |
#archive(reason: nil) -> self
Helper method to archive the thread.
850 851 852 |
# File 'lib/discorb/channel.rb', line 850 def archive(reason: nil) edit(archived: true, reason: reason) end |
#edit(name: Discorb::Unset, archived: Discorb::Unset, auto_archive_duration: Discorb::Unset, archive_in: Discorb::Unset, locked: 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.
830 831 832 833 834 835 836 837 838 839 840 841 |
# File 'lib/discorb/channel.rb', line 830 def edit(name: Discorb::Unset, archived: Discorb::Unset, auto_archive_duration: Discorb::Unset, archive_in: Discorb::Unset, locked: 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 @client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait self end end |
#fetch_members -> Array<Discorb::ThreadChannel::Member>
Fetch members in the thread.
960 961 962 963 964 965 |
# File 'lib/discorb/channel.rb', line 960 def fetch_members Async do _resp, data = @client.http.get("/channels/#{@id}/thread-members").wait data.map { |d| @members[d[:id]] = Member.new(@client, d) } end end |
#inspect -> Object
913 914 915 |
# File 'lib/discorb/channel.rb', line 913 def inspect "#<#{self.class} \"##{@name}\" id=#{@id}>" end |
#lock(reason: nil) -> self
Helper method to lock the thread.
861 862 863 |
# File 'lib/discorb/channel.rb', line 861 def lock(reason: nil) edit(archived: true, locked: true, reason: reason) end |
#remove_member(member = :me) -> Async::Task<void> Also known as: leave
Remove a member from the thread.
943 944 945 946 947 948 949 950 951 |
# File 'lib/discorb/channel.rb', line 943 def remove_member(member = :me) Async do if member == :me @client.http.delete("/channels/#{@id}/thread-members/@me").wait else @client.http.delete("/channels/#{@id}/thread-members/#{Utils.try(member, :id)}").wait end end end |
#unarchive(reason: nil) -> self
Helper method to unarchive the thread.
872 873 874 |
# File 'lib/discorb/channel.rb', line 872 def unarchive(reason: nil) edit(archived: false, reason: reason) end |
#unlock(reason: nil) -> self
This method won't unarchive the thread. Use #unarchive instead.
Helper method to unlock the thread.
885 886 887 |
# File 'lib/discorb/channel.rb', line 885 def unlock(reason: nil) edit(archived: !unarchive, locked: false, reason: reason) end |