discorb 0.17.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +1 -3
  3. data/.github/workflows/validate.yml +21 -0
  4. data/Changelog.md +25 -0
  5. data/Gemfile +6 -0
  6. data/README.md +2 -1
  7. data/Rakefile +205 -98
  8. data/Steepfile +30 -0
  9. data/docs/application_command.md +1 -0
  10. data/docs/events.md +44 -8
  11. data/docs/tutorial.md +7 -7
  12. data/docs/voice_events.md +8 -8
  13. data/examples/commands/message.rb +12 -7
  14. data/examples/commands/permission.rb +2 -1
  15. data/examples/commands/slash.rb +23 -19
  16. data/examples/commands/user.rb +15 -12
  17. data/examples/components/authorization_button.rb +2 -1
  18. data/examples/components/select_menu.rb +4 -1
  19. data/examples/extension/main.rb +1 -0
  20. data/examples/extension/message_expander.rb +1 -0
  21. data/examples/sig/commands/message.rbs +5 -0
  22. data/examples/simple/eval.rb +1 -0
  23. data/examples/simple/ping_pong.rb +1 -0
  24. data/examples/simple/rolepanel.rb +16 -5
  25. data/examples/simple/shard.rb +2 -1
  26. data/examples/simple/wait_for_message.rb +3 -0
  27. data/exe/discorb +3 -3
  28. data/lib/discorb/allowed_mentions.rb +1 -1
  29. data/lib/discorb/app_command/command.rb +16 -13
  30. data/lib/discorb/app_command/handler.rb +21 -6
  31. data/lib/discorb/audit_logs.rb +6 -2
  32. data/lib/discorb/automod.rb +269 -0
  33. data/lib/discorb/channel/guild.rb +5 -4
  34. data/lib/discorb/channel/stage.rb +1 -1
  35. data/lib/discorb/channel/text.rb +14 -23
  36. data/lib/discorb/channel/thread.rb +15 -11
  37. data/lib/discorb/client.rb +15 -15
  38. data/lib/discorb/color.rb +37 -60
  39. data/lib/discorb/common.rb +1 -1
  40. data/lib/discorb/dictionary.rb +1 -1
  41. data/lib/discorb/embed.rb +5 -4
  42. data/lib/discorb/emoji.rb +4 -4
  43. data/lib/discorb/event.rb +2 -2
  44. data/lib/discorb/exe/about.rb +1 -1
  45. data/lib/discorb/exe/new.rb +1 -5
  46. data/lib/discorb/extension.rb +0 -4
  47. data/lib/discorb/flag.rb +2 -2
  48. data/lib/discorb/gateway.rb +38 -589
  49. data/lib/discorb/gateway_events.rb +638 -0
  50. data/lib/discorb/guild.rb +138 -19
  51. data/lib/discorb/guild_template.rb +3 -3
  52. data/lib/discorb/http.rb +47 -25
  53. data/lib/discorb/integration.rb +2 -2
  54. data/lib/discorb/intents.rb +27 -18
  55. data/lib/discorb/interaction/command.rb +14 -10
  56. data/lib/discorb/interaction/response.rb +150 -84
  57. data/lib/discorb/interaction/root.rb +139 -0
  58. data/lib/discorb/invite.rb +1 -1
  59. data/lib/discorb/member.rb +3 -3
  60. data/lib/discorb/message.rb +17 -15
  61. data/lib/discorb/message_meta.rb +2 -3
  62. data/lib/discorb/modules.rb +5 -4
  63. data/lib/discorb/permission.rb +3 -1
  64. data/lib/discorb/presence.rb +4 -2
  65. data/lib/discorb/reaction.rb +2 -2
  66. data/lib/discorb/role.rb +3 -3
  67. data/lib/discorb/shard.rb +1 -1
  68. data/lib/discorb/sticker.rb +5 -5
  69. data/lib/discorb/user.rb +2 -2
  70. data/lib/discorb/voice_state.rb +8 -8
  71. data/lib/discorb/webhook.rb +20 -11
  72. data/lib/discorb.rb +2 -2
  73. data/rbs_collection.lock.yaml +88 -96
  74. data/rbs_collection.yaml +21 -17
  75. data/sig/async.rbs +11 -5
  76. data/sig/discorb/activity.rbs +24 -0
  77. data/sig/discorb/allowed_mentions.rbs +45 -0
  78. data/sig/discorb/app_command/base.rbs +288 -0
  79. data/sig/discorb/app_command/handler.rbs +171 -0
  80. data/sig/discorb/application.rbs +146 -0
  81. data/sig/discorb/asset.rbs +34 -0
  82. data/sig/discorb/attachment.rbs +99 -0
  83. data/sig/discorb/audit_log.rbs +238 -0
  84. data/sig/discorb/automod.rbs +145 -0
  85. data/sig/discorb/avatar.rbs +27 -0
  86. data/sig/discorb/channel/base.rbs +186 -0
  87. data/sig/discorb/channel/category.rbs +57 -0
  88. data/sig/discorb/channel/container.rbs +33 -0
  89. data/sig/discorb/channel/dm.rbs +14 -0
  90. data/sig/discorb/channel/news.rbs +20 -0
  91. data/sig/discorb/channel/stage.rbs +81 -0
  92. data/sig/discorb/channel/text.rbs +158 -0
  93. data/sig/discorb/channel/thread.rbs +196 -0
  94. data/sig/discorb/channel/voice.rbs +43 -0
  95. data/sig/discorb/client.rbs +2496 -0
  96. data/sig/discorb/color.rbs +148 -0
  97. data/sig/discorb/component/base.rbs +29 -0
  98. data/sig/discorb/component/button.rbs +67 -0
  99. data/sig/discorb/component/select_menu.rbs +111 -0
  100. data/sig/discorb/component/text_input.rbs +70 -0
  101. data/sig/discorb/connectable.rbs +8 -0
  102. data/sig/discorb/custom_emoji.rbs +94 -0
  103. data/sig/discorb/dictionary.rbs +87 -0
  104. data/sig/discorb/discord_model.rbs +17 -0
  105. data/sig/discorb/embed.rbs +286 -0
  106. data/sig/discorb/emoji.rbs +14 -0
  107. data/sig/discorb/error.rbs +73 -0
  108. data/sig/discorb/event_handler.rbs +28 -0
  109. data/sig/discorb/extension.rbs +1735 -0
  110. data/sig/discorb/flag.rbs +74 -0
  111. data/sig/discorb/gateway.rbs +486 -0
  112. data/sig/discorb/guild.rbs +872 -0
  113. data/sig/discorb/guild_template.rbs +174 -0
  114. data/sig/discorb/http.rbs +150 -0
  115. data/sig/discorb/image.rbs +22 -0
  116. data/sig/discorb/integration.rbs +118 -0
  117. data/sig/discorb/intents.rbs +98 -0
  118. data/sig/discorb/interaction/autocomplete.rbs +9 -0
  119. data/sig/discorb/interaction/base.rbs +102 -0
  120. data/sig/discorb/interaction/command.rbs +66 -0
  121. data/sig/discorb/interaction/message_component.rbs +139 -0
  122. data/sig/discorb/interaction/modal.rbs +49 -0
  123. data/sig/discorb/interaction/responder.rbs +157 -0
  124. data/sig/discorb/invite.rbs +86 -0
  125. data/sig/discorb/member.rbs +189 -0
  126. data/sig/discorb/message.rbs +474 -0
  127. data/sig/discorb/messageable.rbs +150 -0
  128. data/sig/discorb/partial_emoji.rbs +38 -0
  129. data/sig/discorb/permissions.rbs +156 -0
  130. data/sig/discorb/presence.rbs +239 -0
  131. data/sig/discorb/reaction.rbs +37 -0
  132. data/sig/discorb/role.rbs +151 -0
  133. data/sig/discorb/scheduled_event.rbs +149 -0
  134. data/sig/discorb/shard.rbs +63 -0
  135. data/sig/discorb/snowflake.rbs +58 -0
  136. data/sig/discorb/stage_instance.rbs +69 -0
  137. data/sig/discorb/sticker.rbs +116 -0
  138. data/sig/discorb/system_channel_flag.rbs +17 -0
  139. data/sig/discorb/unicode_emoji.rbs +53 -0
  140. data/sig/discorb/user.rbs +95 -0
  141. data/sig/discorb/utils.rbs +8 -0
  142. data/sig/discorb/voice_region.rbs +30 -0
  143. data/sig/discorb/voice_state.rbs +71 -0
  144. data/sig/discorb/webhook.rbs +338 -0
  145. data/sig/discorb/welcome_screen.rbs +79 -0
  146. data/sig/discorb.rbs +5 -8661
  147. data/sig/manifest.yaml +3 -0
  148. data/sig/override.rbs +21 -0
  149. metadata +80 -3
@@ -0,0 +1,57 @@
1
+ module Discorb
2
+ #
3
+ # Represents a category in a guild.
4
+ class CategoryChannel < Discorb::GuildChannel
5
+ include Discorb::ChannelContainer
6
+
7
+ %a{pure}
8
+ def channels: -> Array[Discorb::GuildChannel]
9
+
10
+ def create_text_channel: (
11
+ String name,
12
+ ?topic: String?,
13
+ ?rate_limit_per_user: Integer?,
14
+ ?slowmode: Integer?,
15
+ ?position: Integer?,
16
+ ?nsfw: bool?,
17
+ ?permission_overwrites: Hash[(Discorb::Role
18
+ | Discorb::Member), Discorb::PermissionOverwrite]?,
19
+ ?parent: Discorb::CategoryChannel?,
20
+ ?reason: String?
21
+ ) -> Async::Task[Discorb::TextChannel]
22
+
23
+ def create_voice_channel: (
24
+ String name,
25
+ ?bitrate: Integer,
26
+ ?user_limit: Integer?,
27
+ ?position: Integer?,
28
+ ?permission_overwrites: Hash[(Discorb::Role
29
+ | Discorb::Member), Discorb::PermissionOverwrite]?,
30
+ ?parent: Discorb::CategoryChannel?,
31
+ ?reason: String?
32
+ ) -> Async::Task[Discorb::VoiceChannel]
33
+
34
+ def create_news_channel: (
35
+ String name,
36
+ ?topic: String?,
37
+ ?rate_limit_per_user: Integer?,
38
+ ?slowmode: Integer?,
39
+ ?position: Integer?,
40
+ ?nsfw: bool?,
41
+ ?permission_overwrites: Hash[(Discorb::Role
42
+ | Discorb::Member), Discorb::PermissionOverwrite]?,
43
+ ?parent: Discorb::CategoryChannel?,
44
+ ?reason: String?
45
+ ) -> Async::Task[Discorb::NewsChannel]
46
+
47
+ def create_stage_channel: (
48
+ String name,
49
+ ?bitrate: Integer,
50
+ ?position: Integer?,
51
+ ?permission_overwrites: Hash[(Discorb::Role
52
+ | Discorb::Member), Discorb::PermissionOverwrite]?,
53
+ ?parent: Discorb::CategoryChannel?,
54
+ ?reason: String?
55
+ ) -> Async::Task[Discorb::StageChannel]
56
+ end
57
+ end
@@ -0,0 +1,33 @@
1
+ module Discorb
2
+ #
3
+ # Module for container of channels.
4
+ module ChannelContainer
5
+ #
6
+ # Returns text channels.
7
+ #
8
+ # @return [Array<Discorb::TextChannel>] The text channels.
9
+ %a{pure}
10
+ def text_channels: -> ::Array[Discorb::TextChannel]
11
+
12
+ #
13
+ # Returns voice channels.
14
+ #
15
+ # @return [Array<Discorb::VoiceChannel>] The voice channels.
16
+ %a{pure}
17
+ def voice_channels: -> ::Array[Discorb::VoiceChannel]
18
+
19
+ #
20
+ # Returns news channels.
21
+ #
22
+ # @return [Array<Discorb::NewsChannel>] The news channels.
23
+ %a{pure}
24
+ def news_channels: -> ::Array[Discorb::NewsChannel]
25
+
26
+ #
27
+ # Returns stage channels.
28
+ #
29
+ # @return [Array<Discorb::StageChannel>] The stage channels.
30
+ %a{pure}
31
+ def stage_channels: -> ::Array[Discorb::StageChannel]
32
+ end
33
+ end
@@ -0,0 +1,14 @@
1
+ module Discorb
2
+ #
3
+ # Represents a DM channel.
4
+ class DMChannel < Discorb::Channel
5
+ include Discorb::Messageable
6
+
7
+ #
8
+ # Returns the channel id to request.
9
+ # @private
10
+ #
11
+ # @return [Async::Task<Discorb::Snowflake>] A task that resolves to the channel id.
12
+ def channel_id: -> Async::Task[Discorb::Snowflake]
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ module Discorb
2
+ #
3
+ # Represents a news channel (announcement channel).
4
+ class NewsChannel < Discorb::TextChannel
5
+ DEFAULT_AUTO_ARCHIVE_DURATION: untyped
6
+
7
+ #
8
+ # Follow the existing announcement channel from self.
9
+ # @async
10
+ #
11
+ # @param [Discorb::TextChannel] target The channel to follow to.
12
+ # @param [String] reason The reason of following the channel.
13
+ #
14
+ # @return [Async::Task<void>] The task.
15
+ def follow_to: (
16
+ Discorb::TextChannel target,
17
+ ?reason: String?
18
+ ) -> Async::Task[void]
19
+ end
20
+ end
@@ -0,0 +1,81 @@
1
+ module Discorb
2
+ #
3
+ # Represents a stage channel.
4
+ class StageChannel < Discorb::GuildChannel
5
+ include Discorb::Connectable
6
+
7
+ #
8
+ # Initialize a new stage channel.
9
+ # @private
10
+ def initialize: -> void
11
+
12
+ def stage_instance: -> untyped
13
+
14
+ #
15
+ # Edit the stage channel.
16
+ # @async
17
+ # @macro edit
18
+ #
19
+ # @param [String] name The name of the stage channel.
20
+ # @param [Integer] position The position of the stage channel.
21
+ # @param [Integer] bitrate The bitrate of the stage channel.
22
+ # @param [Symbol] rtc_region The region of the stage channel.
23
+ # @param [String] reason The reason of editing the stage channel.
24
+ #
25
+ # @return [Async::Task<self>] The edited stage channel.
26
+ def edit: (
27
+ ?name: String,
28
+ ?position: Integer,
29
+ ?bitrate: Integer,
30
+ ?rtc_region: Symbol,
31
+ ?reason: String?
32
+ ) -> Async::Task[self]
33
+
34
+ #
35
+ # Start a stage instance.
36
+ # @async
37
+ #
38
+ # @param [String] topic The topic of the stage instance.
39
+ # @param [Boolean] public Whether the stage instance is public or not.
40
+ # @param [String] reason The reason of starting the stage instance.
41
+ #
42
+ # @return [Async::Task<Discorb::StageInstance>] The started stage instance.
43
+ def start: (
44
+ String topic,
45
+ ?public: bool,
46
+ ?reason: String?
47
+ ) -> Async::Task[Discorb::StageInstance]
48
+
49
+ #
50
+ # Fetch a current stage instance.
51
+ # @async
52
+ #
53
+ # @return [Async::Task<StageInstance>] The current stage instance.
54
+ # @return [Async::Task<nil>] If there is no current stage instance.
55
+ def fetch_stage_instance: -> Async::Task[StageInstance]
56
+
57
+ %a{pure}
58
+ def voice_states: -> Array[Discorb::VoiceState]
59
+
60
+ %a{pure}
61
+ def members: -> Array[Discorb::Member]
62
+
63
+ %a{pure}
64
+ def speakers: -> Array[Discorb::Member]
65
+
66
+ %a{pure}
67
+ def audiences: -> Array[Discorb::Member]
68
+
69
+ # @return [Integer] The bitrate of the voice channel.
70
+ attr_reader bitrate: Integer
71
+
72
+ # @return [Integer] The user limit of the voice channel.
73
+ attr_reader user_limit: Integer
74
+
75
+ #
76
+ # @private
77
+ # @return [Discorb::Dictionary{Discorb::Snowflake => StageInstance}]
78
+ # The stage instances associated with the stage channel.
79
+ attr_reader stage_instances: Discorb::Dictionary[Discorb::Snowflake, StageInstance]
80
+ end
81
+ end
@@ -0,0 +1,158 @@
1
+ module Discorb
2
+ #
3
+ # Represents a text channel.
4
+ class TextChannel < Discorb::GuildChannel
5
+ include Discorb::Messageable
6
+
7
+ #
8
+ # Edits the channel.
9
+ # @async
10
+ # @macro edit
11
+ #
12
+ # @param [String] name The name of the channel.
13
+ # @param [Integer] position The position of the channel.
14
+ # @param [Discorb::CategoryChannel, nil] category The parent of channel. Specify `nil` to remove the parent.
15
+ # @param [Discorb::CategoryChannel, nil] parent Alias of `category`.
16
+ # @param [String] topic The topic of the channel.
17
+ # @param [Boolean] nsfw Whether the channel is nsfw.
18
+ # @param [Boolean] announce Whether the channel is announce channel.
19
+ # @param [Integer] rate_limit_per_user The rate limit per user (Slowmode) in the channel.
20
+ # @param [Integer] slowmode Alias of `rate_limit_per_user`.
21
+ # @param [Integer] default_auto_archive_duration The default auto archive duration of the channel.
22
+ # @param [Integer] archive_in Alias of `default_auto_archive_duration`.
23
+ # @param [String] reason The reason of editing the channel.
24
+ #
25
+ # @return [Async::Task<self>] The edited channel.
26
+ def edit: (
27
+ ?name: String,
28
+ ?position: Integer,
29
+ ?category: Discorb::CategoryChannel?,
30
+ ?parent: Discorb::CategoryChannel?,
31
+ ?topic: String,
32
+ ?nsfw: bool,
33
+ ?announce: bool,
34
+ ?rate_limit_per_user: Integer,
35
+ ?slowmode: Integer,
36
+ ?default_auto_archive_duration: 60 | 1440 | 4320 | 10080,
37
+ ?archive_in: 60 | 1440 | 4320 | 10080,
38
+ ?reason: String?
39
+ ) -> Async::Task[self]
40
+
41
+ #
42
+ # Create webhook in the channel.
43
+ # @async
44
+ #
45
+ # @param [String] name The name of the webhook.
46
+ # @param [Discorb::Image] avatar The avatar of the webhook.
47
+ #
48
+ # @return [Async::Task<Discorb::Webhook::IncomingWebhook>] The created webhook.
49
+ def create_webhook: (
50
+ String name,
51
+ ?avatar: Discorb::Image?
52
+ ) -> Async::Task[Discorb::Webhook::IncomingWebhook]
53
+
54
+ #
55
+ # Fetch webhooks in the channel.
56
+ # @async
57
+ #
58
+ # @return [Async::Task<Array<Discorb::Webhook>>] The webhooks in the channel.
59
+ def fetch_webhooks: -> Async::Task[::Array[Discorb::Webhook]]
60
+
61
+ #
62
+ # Bulk delete messages in the channel.
63
+ # @async
64
+ #
65
+ # @param [Discorb::Message] messages The messages to delete.
66
+ # @param [Boolean] force Whether to ignore the validation for message (14 days limit).
67
+ #
68
+ # @return [Async::Task<void>] The task.
69
+ def delete_messages:
70
+ (*Discorb::Message messages, ?force: bool) -> Async::Task[void]
71
+ | (*Array[Discorb::Message] messages, ?force: bool) -> Async::Task[void]
72
+
73
+ #
74
+ # Follow the existing announcement channel.
75
+ # @async
76
+ #
77
+ # @param [Discorb::NewsChannel] target The channel to follow.
78
+ # @param [String] reason The reason of following the channel.
79
+ #
80
+ # @return [Async::Task<void>] The task.
81
+ def follow_from: (
82
+ Discorb::NewsChannel target,
83
+ ?reason: String?
84
+ ) -> Async::Task[void]
85
+
86
+ #
87
+ # Start thread in the channel.
88
+ # @async
89
+ #
90
+ # @param [String] name The name of the thread.
91
+ # @param [Discorb::Message] message The message to start the thread.
92
+ # @param [:hour, :day, :three_days, :week] auto_archive_duration The duration of auto-archiving.
93
+ # @param [Boolean] public Whether the thread is public.
94
+ # @param [Integer] rate_limit_per_user The rate limit per user.
95
+ # @param [Integer] slowmode Alias of `rate_limit_per_user`.
96
+ # @param [String] reason The reason of starting the thread.
97
+ #
98
+ # @return [Async::Task<Discorb::ThreadChannel>] The started thread.
99
+ def start_thread: (
100
+ String name,
101
+ ?message: Discorb::Message?,
102
+ ?auto_archive_duration: Symbol?,
103
+ ?public: bool,
104
+ ?rate_limit_per_user: Integer?,
105
+ ?slowmode: Integer?,
106
+ ?reason: String?
107
+ ) -> Async::Task[Discorb::ThreadChannel]
108
+
109
+ #
110
+ # Fetch archived threads in the channel.
111
+ # @async
112
+ #
113
+ # @return [Async::Task<Array<Discorb::ThreadChannel>>] The archived threads in the channel.
114
+ def fetch_archived_public_threads: -> Async::Task[::Array[Discorb::ThreadChannel]]
115
+
116
+ #
117
+ # Fetch archived private threads in the channel.
118
+ # @async
119
+ #
120
+ # @return [Async::Task<Array<Discorb::ThreadChannel>>] The archived private threads in the channel.
121
+ def fetch_archived_private_threads: -> Async::Task[::Array[Discorb::ThreadChannel]]
122
+
123
+ #
124
+ # Fetch joined archived private threads in the channel.
125
+ # @async
126
+ #
127
+ # @param [Integer] limit The limit of threads to fetch.
128
+ # @param [Time] before <description>
129
+ #
130
+ # @return [Async::Task<Array<Discorb::ThreadChannel>>] The joined archived private threads in the channel.
131
+ def fetch_joined_archived_private_threads: (
132
+ ?limit: Integer?,
133
+ ?before: Time?
134
+ ) -> Async::Task[::Array[Discorb::ThreadChannel]]
135
+
136
+ # @return [String] The topic of the channel.
137
+ attr_reader topic: String
138
+
139
+ # @return [Boolean] Whether the channel is nsfw.
140
+ attr_reader nsfw: bool
141
+
142
+ # @return [Discorb::Snowflake] The id of the last message.
143
+ attr_reader last_message_id: Discorb::Snowflake
144
+
145
+ # @return [Integer] The rate limit per user (Slowmode) in the channel.
146
+ attr_reader rate_limit_per_user: Integer
147
+
148
+ # @return [Time] The time when the last pinned message was pinned.
149
+ attr_reader last_pin_timestamp: Time
150
+
151
+ # @return [Integer] The default value of duration of auto archive.
152
+ attr_reader default_auto_archive_duration: 60 | 1440 | 4320 | 10080
153
+
154
+ # @!attribute [r] threads
155
+ # @return [Array<Discorb::ThreadChannel>] The threads in the channel.
156
+ attr_reader threads: untyped
157
+ end
158
+ end
@@ -0,0 +1,196 @@
1
+ module Discorb
2
+ #
3
+ # Represents a thread.
4
+ # @abstract
5
+ class ThreadChannel < Discorb::Channel
6
+ include Discorb::Messageable
7
+
8
+ #
9
+ # Initialize a new thread channel.
10
+ # @private
11
+ #
12
+ # @param [Discorb::Client] client The client.
13
+ # @param [Hash] data The data of the thread channel.
14
+ # @param [Boolean] no_cache Whether to disable the cache.
15
+ def initialize: (
16
+ Discorb::Client client,
17
+ Discorb::json data,
18
+ ?no_cache: bool
19
+ ) -> void
20
+
21
+ #
22
+ # Edit the thread.
23
+ # @async
24
+ # @macro edit
25
+ #
26
+ # @param [String] name The name of the thread.
27
+ # @param [Boolean] archived Whether the thread is archived or not.
28
+ # @param [Integer] auto_archive_duration The auto archive duration in seconds.
29
+ # @param [Integer] archive_in Alias of `auto_archive_duration`.
30
+ # @param [Boolean] locked Whether the thread is locked or not.
31
+ # @param [String] reason The reason of editing the thread.
32
+ #
33
+ # @return [Async::Task<self>] The edited thread.
34
+ #
35
+ # @see #archive
36
+ # @see #lock
37
+ # @see #unarchive
38
+ # @see #unlock
39
+ def edit: (
40
+ ?name: String,
41
+ ?archived: bool,
42
+ ?auto_archive_duration: Integer,
43
+ ?archive_in: Integer,
44
+ ?locked: bool,
45
+ ?reason: String?
46
+ ) -> Async::Task[self]
47
+
48
+ #
49
+ # Helper method to archive the thread.
50
+ #
51
+ # @param [String] reason The reason of archiving the thread.
52
+ #
53
+ # @return [Async::Task<self>] The archived thread.
54
+ def archive: (?reason: String?) -> Async::Task[self]
55
+
56
+ #
57
+ # Helper method to lock the thread.
58
+ #
59
+ # @param [String] reason The reason of locking the thread.
60
+ #
61
+ # @return [Async::Task<self>] The locked thread.
62
+ def lock: (?reason: String?) -> Async::Task[self]
63
+
64
+ #
65
+ # Helper method to unarchive the thread.
66
+ #
67
+ # @param [String] reason The reason of unarchiving the thread.
68
+ #
69
+ # @return [Async::Task<self>] The unarchived thread.
70
+ def unarchive: (?reason: String?) -> Async::Task[self]
71
+
72
+ #
73
+ # Helper method to unlock the thread.
74
+ #
75
+ # @param [String] reason The reason of unlocking the thread.
76
+ #
77
+ # @return [Async::Task<self>] The unlocked thread.
78
+ #
79
+ # @note This method won't unarchive the thread. Use {#unarchive} instead.
80
+ def unlock: (?reason: String?) -> Async::Task[self]
81
+
82
+ %a{pure}
83
+ def parent: -> untyped
84
+
85
+ %a{pure}
86
+ def me: -> untyped
87
+
88
+ %a{pure}
89
+ def joined?: -> bool
90
+
91
+ %a{pure}
92
+ def guild: -> untyped
93
+
94
+ %a{pure}
95
+ def owner: -> untyped
96
+
97
+ %a{pure}
98
+ def inspect: -> String
99
+
100
+ #
101
+ # Add a member to the thread.
102
+ #
103
+ # @param [Discorb::Member, :me] member The member to add. If `:me` is given, the bot will be added.
104
+ #
105
+ # @return [Async::Task<void>] The task.
106
+ def add_member: (?Discorb::Member | Symbol member) -> Async::Task[void]
107
+
108
+ #
109
+ # Remove a member from the thread.
110
+ #
111
+ # @param [Discorb::Member, :me] member The member to remove. If `:me` is given, the bot will be removed.
112
+ #
113
+ # @return [Async::Task<void>] The task.
114
+ def remove_member: (?Discorb::Member | Symbol member) -> Async::Task[void]
115
+
116
+ #
117
+ # Fetch members in the thread.
118
+ #
119
+ # @return [Array<Discorb::ThreadChannel::Member>] The members in the thread.
120
+ def fetch_members: -> ::Array[Discorb::ThreadChannel::Member]
121
+
122
+ # @return [Discorb::Snowflake] The ID of the channel.
123
+ # @note This ID is same as the starter message's ID
124
+ attr_reader id: Discorb::Snowflake
125
+
126
+ # @return [String] The name of the thread.
127
+ attr_reader name: String
128
+
129
+ # @return [Integer] The number of messages in the thread.
130
+ # @note This will stop counting at 50.
131
+ attr_reader message_count: Integer
132
+
133
+ # @return [Integer] The number of recipients in the thread.
134
+ # @note This will stop counting at 50.
135
+ attr_reader member_count: Integer
136
+
137
+ # @return [Integer] The rate limit per user (slowmode) in the thread.
138
+ attr_reader rate_limit_per_user: Integer
139
+
140
+ # @return [Array<Discorb::ThreadChannel::Member>] The members of the thread.
141
+ attr_reader members: ::Array[Discorb::ThreadChannel::Member]
142
+
143
+ # @return [Time] The time the thread was archived.
144
+ # @return [nil] If the thread is not archived.
145
+ attr_reader archived_timestamp: Time?
146
+
147
+ # @return [Integer] Auto archive duration in seconds.
148
+ attr_reader auto_archive_duration: Integer
149
+
150
+ # @return [Boolean] Whether the thread is archived or not.
151
+ attr_reader archived: bool
152
+
153
+ #
154
+ # Represents a thread in news channel(aka announcement channel).
155
+ class News < Discorb::ThreadChannel
156
+ end
157
+
158
+ #
159
+ # Represents a public thread in text channel.
160
+ class Public < Discorb::ThreadChannel
161
+ end
162
+
163
+ #
164
+ # Represents a private thread in text channel.
165
+ class Private < Discorb::ThreadChannel
166
+ end
167
+
168
+ #
169
+ # Represents a member in a thread.
170
+ class Member < Discorb::DiscordModel
171
+ def initialize: (
172
+ Discorb::Client client,
173
+ Discorb::json data,
174
+ _ToS guild_id
175
+ ) -> void
176
+
177
+ %a{pure}
178
+ def thread: -> Discorb::ThreadChannel
179
+
180
+ %a{pure}
181
+ def member: -> Discorb::Member
182
+
183
+ %a{pure}
184
+ def id: -> Discorb::Snowflake
185
+
186
+ %a{pure}
187
+ def user: -> Discorb::User
188
+
189
+ %a{pure}
190
+ def inspect: -> String
191
+
192
+ # Returns the value of attribute joined_at.
193
+ attr_reader joined_at: Time
194
+ end
195
+ end
196
+ end
@@ -0,0 +1,43 @@
1
+ module Discorb
2
+ #
3
+ # Represents a voice channel.
4
+ class VoiceChannel < Discorb::GuildChannel
5
+ include Discorb::Connectable
6
+ include Discorb::Messageable
7
+
8
+ #
9
+ # Edit the voice channel.
10
+ # @async
11
+ # @macro edit
12
+ #
13
+ # @param [String] name The name of the voice channel.
14
+ # @param [Integer] position The position of the voice channel.
15
+ # @param [Integer] bitrate The bitrate of the voice channel.
16
+ # @param [Integer] user_limit The user limit of the voice channel.
17
+ # @param [Symbol] rtc_region The region of the voice channel.
18
+ # @param [String] reason The reason of editing the voice channel.
19
+ #
20
+ # @return [Async::Task<self>] The edited voice channel.
21
+ def edit: (
22
+ ?name: String,
23
+ ?position: Integer,
24
+ ?bitrate: Integer,
25
+ ?user_limit: Integer,
26
+ ?rtc_region: Symbol,
27
+ ?reason: String?
28
+ ) -> Async::Task[self]
29
+
30
+ %a{pure}
31
+ def voice_states: -> Array[Discorb::VoiceState]
32
+
33
+ %a{pure}
34
+ def members: -> Array[Discorb::Member]
35
+
36
+ # @return [Integer] The bitrate of the voice channel.
37
+ attr_reader bitrate: Integer
38
+
39
+ # @return [Integer] The user limit of the voice channel.
40
+ # @return [nil] If the user limit is not set.
41
+ attr_reader user_limit: Integer?
42
+ end
43
+ end