module Discorb # # Represents a channel of Discord. # @abstract class Channel < Discorb::DiscordModel # # Initializes a new instance of the Channel class. # @private def initialize: (untyped client, untyped data, ?no_cache: untyped) -> void # # Checks if the channel is other channel. # # @param [Discorb::Channel] other The channel to check. # # @return [Boolean] True if the channel is other channel. def ==: (Discorb::Channel other) -> bool %a{pure} def inspect: -> String # # Returns the descendants of the Channel class. # @private def self.descendants: -> untyped # # Creates a new instance of the Channel class or instance of its descendants. # @private # # @param [Discorb::Client] client The client that instantiated the object. # @param [Hash] data The data of the object. # @param [Boolean] no_cache Whether to disable cache the object. def self.make_channel: ( Discorb::Client client, Discorb::json data, ?no_cache: bool ) -> untyped %a{pure} def `type`: -> String # # Returns the channel id to request. # @private # # @return [Async::Task] A task that resolves to the channel id. def channel_id: -> Async::Task[Discorb::Snowflake] # @return [Discorb::Snowflake] The ID of the channel. attr_reader id: Discorb::Snowflake # @return [String] The name of the channel. attr_reader name: String end # # Represents a channel in guild. # @abstract class GuildChannel < Discorb::Channel include Comparable # # Compares position of two channels. # # @param [Discorb::GuildChannel] other The channel to compare. # # @return [-1, 0, 1] -1 if the channel is at lower than the other, 1 if the channel is at highter than the other. def <=>: (Discorb::GuildChannel other) -> Integer? # # Checks if the channel is same as another. # # @param [Discorb::GuildChannel] other The channel to check. # # @return [Boolean] `true` if the channel is same as another. def ==: (Discorb::GuildChannel other) -> bool # # Stringifies the channel. # # @return [String] The name of the channel with `#`. %a{pure} def to_s: -> String %a{pure} def mention: -> String %a{pure} def parent: -> Discorb::CategoryChannel? %a{pure} def guild: -> Discorb::Guild %a{pure} def inspect: -> String # # Deletes the channel. # @async # # @param [String] reason The reason of deleting the channel. # # @return [Async::Task] The deleted channel. def delete: (?reason: String?) -> Async::Task[self] # # Moves the channel to another position. # @async # # @param [Integer] position The position to move the channel. # @param [Boolean] lock_permissions Whether to lock the permissions of the channel. # @param [Discorb::CategoryChannel] parent The parent of channel. # @param [String] reason The reason of moving the channel. # # @return [Async::Task] The moved channel. def move: ( Integer position, ?lock_permissions: bool, ?parent: Discorb::CategoryChannel, ?reason: String? ) -> Async::Task[self] # # Set the channel's permission overwrite. # @async # # @param [Discorb::Role, Discorb::Member] target The target of the overwrite. # @param [String] reason The reason of setting the overwrite. # @param [{Symbol => Boolean}] perms The permission overwrites to replace. # # @return [Async::Task] The task. def set_permissions: ( Discorb::Role | Discorb::Member target, ?reason: String?, **bool perms ) -> Async::Task[void] # # Delete the channel's permission overwrite. # @async # # @param [Discorb::Role, Discorb::Member] target The target of the overwrite. # @param [String] reason The reason of deleting the overwrite. # # @return [Async::Task] The task. def delete_permissions: ( Discorb::Role | Discorb::Member target, ?reason: String? ) -> Async::Task[void] # # Fetch the channel's invites. # @async # # @return [Async::Task>] The invites in the channel. def fetch_invites: -> Async::Task[::Array[Discorb::Invite]] # # Create an invite in the channel. # @async # # @param [Integer] max_age The max age of the invite. # @param [Integer] max_uses The max uses of the invite. # @param [Boolean] temporary Whether the invite is temporary. # @param [Boolean] unique Whether the invite is unique. # @note if it's `false` it may return existing invite. # @param [String] reason The reason of creating the invite. # # @return [Async::Task] The created invite. def create_invite: ( ?max_age: Integer?, ?max_uses: Integer?, ?temporary: bool, ?unique: bool, ?reason: String? ) -> Async::Task[Invite] # @return [Integer] The position of the channel as integer. attr_reader position: Integer # @return [Hash{Discorb::Role, Discorb::Member => PermissionOverwrite}] The permission overwrites of the channel. attr_reader permission_overwrites: Hash[Discorb::Role | Discorb::Member, Discorb::PermissionOverwrite] end end