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. 
- 
  
    
      #id -> Discorb::Snowflake 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The ID of the channel. 
- 
  
    
      #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. 
- 
  
    
      #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. 
- #guild -> Object
- #inspect -> Object
- #joined? -> Boolean
- 
  
    
      #lock(reason: nil) -> self 
    
    
  
  
  
  
  
  
  
  
  
    Helper method to lock the thread. 
- #me -> Object
- #owner -> Object
- #parent -> Object (also: #channel)
- 
  
    
      #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.
| 1008 1009 1010 | # File 'lib/discorb/channel.rb', line 1008 def channel_type @channel_type end | 
Instance Attribute Details
#archived -> Boolean (readonly) Also known as: archived?
Returns Whether the thread is archived or not.
| 808 809 810 | # File 'lib/discorb/channel.rb', line 808 def archived @archived end | 
#archived_timestamp -> Time? (readonly) Also known as: archived_at
| 802 803 804 | # File 'lib/discorb/channel.rb', line 802 def @archived_timestamp end | 
#auto_archive_duration -> Integer (readonly) Also known as: archive_in
Returns Auto archive duration in seconds.
| 805 806 807 | # File 'lib/discorb/channel.rb', line 805 def auto_archive_duration @auto_archive_duration end | 
#id -> Discorb::Snowflake (readonly)
This ID is same as the starter message's ID
Returns The ID of the channel.
| 785 786 787 | # File 'lib/discorb/channel.rb', line 785 def id @id end | 
#member_count -> Integer (readonly) Also known as: recipient_count
This will stop counting at 50.
Returns The number of recipients in the thread.
| 793 794 795 | # File 'lib/discorb/channel.rb', line 793 def member_count @member_count end | 
#members -> Array<Discorb::ThreadChannel::Member> (readonly)
Returns The members of the thread.
| 799 800 801 | # File 'lib/discorb/channel.rb', line 799 def members @members end | 
#message_count -> Integer (readonly)
This will stop counting at 50.
Returns The number of messages in the thread.
| 790 791 792 | # File 'lib/discorb/channel.rb', line 790 def @message_count end | 
#name -> String (readonly)
Returns The name of the thread.
| 787 788 789 | # File 'lib/discorb/channel.rb', line 787 def name @name end | 
#rate_limit_per_user -> Integer (readonly) Also known as: slowmode
Returns The rate limit per user (slowmode) in the thread.
| 796 797 798 | # File 'lib/discorb/channel.rb', line 796 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.
| 952 953 954 955 956 957 958 959 960 | # File 'lib/discorb/channel.rb', line 952 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.
| 878 879 880 | # File 'lib/discorb/channel.rb', line 878 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.
| 858 859 860 861 862 863 864 865 866 867 868 869 | # File 'lib/discorb/channel.rb', line 858 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.
| 988 989 990 991 992 993 | # File 'lib/discorb/channel.rb', line 988 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 | 
#guild -> Object
| 933 934 935 | # File 'lib/discorb/channel.rb', line 933 def guild @client.guilds[@guild] end | 
#inspect -> Object
| 941 942 943 | # File 'lib/discorb/channel.rb', line 941 def inspect "#<#{self.class} \"##{@name}\" id=#{@id}>" end | 
#joined? -> Boolean
| 929 930 931 | # File 'lib/discorb/channel.rb', line 929 def joined? !!me end | 
#lock(reason: nil) -> self
Helper method to lock the thread.
| 889 890 891 | # File 'lib/discorb/channel.rb', line 889 def lock(reason: nil) edit(archived: true, locked: true, reason: reason) end | 
#me -> Object
| 925 926 927 | # File 'lib/discorb/channel.rb', line 925 def me @members[@client.user.id] end | 
#owner -> Object
| 937 938 939 | # File 'lib/discorb/channel.rb', line 937 def owner guild.members[@owner_id] end | 
#parent -> Object Also known as: channel
| 917 918 919 920 921 | # File 'lib/discorb/channel.rb', line 917 def parent return nil unless @parent_id @client.channels[@parent_id] end | 
#remove_member(member = :me) -> Async::Task<void> Also known as: leave
Remove a member from the thread.
| 971 972 973 974 975 976 977 978 979 | # File 'lib/discorb/channel.rb', line 971 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.
| 900 901 902 | # File 'lib/discorb/channel.rb', line 900 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.
| 913 914 915 | # File 'lib/discorb/channel.rb', line 913 def unlock(reason: nil) edit(archived: !unarchive, locked: false, reason: reason) end |