discorb 0.16.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +1 -0
  3. data/.github/workflows/build_main.yml +2 -2
  4. data/.github/workflows/build_version.yml +1 -1
  5. data/.github/workflows/codeql-analysis.yml +1 -1
  6. data/.github/workflows/lint-push.yml +3 -5
  7. data/.github/workflows/lint.yml +2 -4
  8. data/.github/workflows/spec.yml +33 -0
  9. data/.github/workflows/validate.yml +21 -0
  10. data/.gitignore +2 -0
  11. data/.lefthook/commit-msg/validator.rb +5 -0
  12. data/.rspec +2 -0
  13. data/.rspec_parallel +2 -0
  14. data/.rubocop.yml +43 -6
  15. data/Changelog.md +30 -1
  16. data/Gemfile +20 -8
  17. data/Rakefile +226 -98
  18. data/Steepfile +28 -0
  19. data/bin/console +3 -3
  20. data/docs/Examples.md +1 -1
  21. data/docs/application_command.md +156 -47
  22. data/docs/cli/irb.md +2 -2
  23. data/docs/cli/new.md +14 -9
  24. data/docs/cli/run.md +7 -11
  25. data/docs/cli.md +17 -10
  26. data/docs/events.md +247 -213
  27. data/docs/extension.md +1 -2
  28. data/docs/faq.md +0 -1
  29. data/docs/tutorial.md +18 -18
  30. data/docs/voice_events.md +106 -106
  31. data/examples/commands/message.rb +68 -0
  32. data/examples/commands/permission.rb +19 -0
  33. data/examples/commands/slash.rb +48 -0
  34. data/examples/commands/user.rb +54 -0
  35. data/examples/components/authorization_button.rb +4 -3
  36. data/examples/components/select_menu.rb +6 -3
  37. data/examples/extension/main.rb +2 -1
  38. data/examples/extension/message_expander.rb +6 -2
  39. data/examples/sig/commands/message.rbs +5 -0
  40. data/examples/simple/eval.rb +3 -2
  41. data/examples/simple/ping_pong.rb +2 -1
  42. data/examples/simple/rolepanel.rb +17 -6
  43. data/examples/simple/shard.rb +3 -2
  44. data/examples/simple/wait_for_message.rb +4 -1
  45. data/exe/discorb +33 -18
  46. data/lefthook.yml +45 -0
  47. data/lib/discorb/allowed_mentions.rb +2 -1
  48. data/lib/discorb/app_command/command.rb +130 -72
  49. data/lib/discorb/app_command/common.rb +25 -0
  50. data/lib/discorb/app_command/handler.rb +130 -33
  51. data/lib/discorb/app_command.rb +2 -1
  52. data/lib/discorb/application.rb +1 -0
  53. data/lib/discorb/asset.rb +1 -2
  54. data/lib/discorb/attachment.rb +1 -1
  55. data/lib/discorb/audit_logs.rb +19 -10
  56. data/lib/discorb/automod.rb +269 -0
  57. data/lib/discorb/channel/base.rb +108 -0
  58. data/lib/discorb/channel/category.rb +32 -0
  59. data/lib/discorb/channel/container.rb +44 -0
  60. data/lib/discorb/channel/dm.rb +28 -0
  61. data/lib/discorb/channel/guild.rb +246 -0
  62. data/lib/discorb/channel/stage.rb +140 -0
  63. data/lib/discorb/channel/text.rb +336 -0
  64. data/lib/discorb/channel/thread.rb +325 -0
  65. data/lib/discorb/channel/voice.rb +79 -0
  66. data/lib/discorb/channel.rb +2 -1165
  67. data/lib/discorb/client.rb +50 -36
  68. data/lib/discorb/color.rb +37 -60
  69. data/lib/discorb/common.rb +2 -1
  70. data/lib/discorb/components/button.rb +2 -1
  71. data/lib/discorb/components/select_menu.rb +4 -2
  72. data/lib/discorb/components/text_input.rb +12 -2
  73. data/lib/discorb/components.rb +1 -1
  74. data/lib/discorb/dictionary.rb +1 -1
  75. data/lib/discorb/embed.rb +26 -10
  76. data/lib/discorb/emoji.rb +31 -4
  77. data/lib/discorb/emoji_table.rb +4969 -3
  78. data/lib/discorb/event.rb +29 -4
  79. data/lib/discorb/exe/about.rb +2 -1
  80. data/lib/discorb/exe/irb.rb +2 -4
  81. data/lib/discorb/exe/new.rb +89 -26
  82. data/lib/discorb/exe/run.rb +8 -22
  83. data/lib/discorb/exe/setup.rb +25 -12
  84. data/lib/discorb/exe/show.rb +4 -3
  85. data/lib/discorb/extend.rb +1 -0
  86. data/lib/discorb/extension.rb +6 -7
  87. data/lib/discorb/flag.rb +13 -2
  88. data/lib/discorb/gateway.rb +79 -589
  89. data/lib/discorb/gateway_events.rb +638 -0
  90. data/lib/discorb/guild.rb +318 -67
  91. data/lib/discorb/guild_template.rb +11 -5
  92. data/lib/discorb/http.rb +53 -24
  93. data/lib/discorb/integration.rb +4 -1
  94. data/lib/discorb/intents.rb +28 -19
  95. data/lib/discorb/interaction/autocomplete.rb +28 -16
  96. data/lib/discorb/interaction/command.rb +42 -14
  97. data/lib/discorb/interaction/components.rb +5 -2
  98. data/lib/discorb/interaction/modal.rb +0 -1
  99. data/lib/discorb/interaction/response.rb +125 -26
  100. data/lib/discorb/interaction/root.rb +13 -13
  101. data/lib/discorb/interaction.rb +1 -0
  102. data/lib/discorb/invite.rb +5 -2
  103. data/lib/discorb/member.rb +28 -8
  104. data/lib/discorb/message.rb +60 -25
  105. data/lib/discorb/message_meta.rb +3 -3
  106. data/lib/discorb/modules.rb +59 -16
  107. data/lib/discorb/presence.rb +2 -0
  108. data/lib/discorb/rate_limit.rb +7 -2
  109. data/lib/discorb/reaction.rb +2 -2
  110. data/lib/discorb/role.rb +20 -5
  111. data/lib/discorb/shard.rb +1 -1
  112. data/lib/discorb/sticker.rb +9 -8
  113. data/lib/discorb/user.rb +4 -3
  114. data/lib/discorb/utils/colored_puts.rb +1 -0
  115. data/lib/discorb/voice_state.rb +6 -2
  116. data/lib/discorb/webhook.rb +64 -31
  117. data/lib/discorb.rb +7 -5
  118. data/po/yard.pot +20 -20
  119. data/rbs_collection.lock.yaml +88 -0
  120. data/rbs_collection.yaml +21 -0
  121. data/sig/async.rbs +11 -0
  122. data/sig/discorb/activity.rbs +23 -0
  123. data/sig/discorb/allowed_mentions.rbs +44 -0
  124. data/sig/discorb/app_command/base.rbs +282 -0
  125. data/sig/discorb/app_command/handler.rbs +171 -0
  126. data/sig/discorb/application.rbs +142 -0
  127. data/sig/discorb/asset.rbs +32 -0
  128. data/sig/discorb/attachment.rbs +91 -0
  129. data/sig/discorb/audit_log.rbs +231 -0
  130. data/sig/discorb/automod.rbs +128 -0
  131. data/sig/discorb/avatar.rbs +26 -0
  132. data/sig/discorb/channel/base.rbs +179 -0
  133. data/sig/discorb/channel/category.rbs +56 -0
  134. data/sig/discorb/channel/container.rbs +29 -0
  135. data/sig/discorb/channel/dm.rbs +14 -0
  136. data/sig/discorb/channel/news.rbs +20 -0
  137. data/sig/discorb/channel/stage.rbs +77 -0
  138. data/sig/discorb/channel/text.rbs +158 -0
  139. data/sig/discorb/channel/thread.rbs +185 -0
  140. data/sig/discorb/channel/voice.rbs +41 -0
  141. data/sig/discorb/client.rbs +2495 -0
  142. data/sig/discorb/color.rbs +142 -0
  143. data/sig/discorb/component/base.rbs +28 -0
  144. data/sig/discorb/component/button.rbs +65 -0
  145. data/sig/discorb/component/select_menu.rbs +107 -0
  146. data/sig/discorb/component/text_input.rbs +69 -0
  147. data/sig/discorb/connectable.rbs +8 -0
  148. data/sig/discorb/custom_emoji.rbs +90 -0
  149. data/sig/discorb/dictionary.rbs +85 -0
  150. data/sig/discorb/discord_model.rbs +15 -0
  151. data/sig/discorb/embed.rbs +279 -0
  152. data/sig/discorb/emoji.rbs +13 -0
  153. data/sig/discorb/error.rbs +73 -0
  154. data/sig/discorb/event_handler.rbs +27 -0
  155. data/sig/discorb/extension.rbs +1734 -0
  156. data/sig/discorb/flag.rbs +72 -0
  157. data/sig/discorb/gateway.rbs +481 -0
  158. data/sig/discorb/guild.rbs +870 -0
  159. data/sig/discorb/guild_template.rbs +174 -0
  160. data/sig/discorb/http.rbs +147 -0
  161. data/sig/discorb/image.rbs +20 -0
  162. data/sig/discorb/integration.rbs +118 -0
  163. data/sig/discorb/intents.rbs +97 -0
  164. data/sig/discorb/interaction/autocomplete.rbs +9 -0
  165. data/sig/discorb/interaction/base.rbs +66 -0
  166. data/sig/discorb/interaction/command.rbs +66 -0
  167. data/sig/discorb/interaction/message_component.rbs +140 -0
  168. data/sig/discorb/interaction/modal.rbs +50 -0
  169. data/sig/discorb/interaction/responder.rbs +157 -0
  170. data/sig/discorb/invite.rbs +86 -0
  171. data/sig/discorb/member.rbs +187 -0
  172. data/sig/discorb/message.rbs +469 -0
  173. data/sig/discorb/messageable.rbs +153 -0
  174. data/sig/discorb/partial_emoji.rbs +35 -0
  175. data/sig/discorb/permissions.rbs +149 -0
  176. data/sig/discorb/presence.rbs +237 -0
  177. data/sig/discorb/reaction.rbs +33 -0
  178. data/sig/discorb/role.rbs +145 -0
  179. data/sig/discorb/scheduled_event.rbs +148 -0
  180. data/sig/discorb/shard.rbs +62 -0
  181. data/sig/discorb/snowflake.rbs +56 -0
  182. data/sig/discorb/stage_instance.rbs +63 -0
  183. data/sig/discorb/sticker.rbs +116 -0
  184. data/sig/discorb/system_channel_flag.rbs +17 -0
  185. data/sig/discorb/unicode_emoji.rbs +49 -0
  186. data/sig/discorb/user.rbs +93 -0
  187. data/sig/discorb/utils.rbs +8 -0
  188. data/sig/discorb/voice_region.rbs +30 -0
  189. data/sig/discorb/voice_state.rbs +71 -0
  190. data/sig/discorb/webhook.rbs +327 -0
  191. data/sig/discorb/welcome_screen.rbs +78 -0
  192. data/sig/discorb.rbs +6 -7230
  193. data/sig/manifest.yaml +3 -0
  194. data/sig/override.rbs +19 -0
  195. data/template-replace/files/css/common.css +4 -0
  196. metadata +102 -6
  197. data/examples/commands/bookmarker.rb +0 -42
  198. data/examples/commands/hello.rb +0 -10
  199. data/examples/commands/inspect.rb +0 -25
data/sig/manifest.yaml ADDED
@@ -0,0 +1,3 @@
1
+ dependencies:
2
+ - name: net-http
3
+ - name: logger
data/sig/override.rbs ADDED
@@ -0,0 +1,19 @@
1
+ # rubocop: disable Style/Documentation
2
+ class Time
3
+ #
4
+ # Format a time object to a Discord formatted string.
5
+ #
6
+ # @param ["f", "F", "d", "D", "t", "T", "R"] type The format to use.
7
+ #
8
+ # @return [String] The formatted time.
9
+ def to_df: (?("f" | "F" | "d" | "D" | "t" | "T" | "R")? `type`) -> String
10
+ end
11
+
12
+ # @private
13
+ module Async
14
+ class Node
15
+ def description: -> untyped
16
+
17
+ def to_s: -> untyped
18
+ end
19
+ end
@@ -553,4 +553,8 @@ dd pre.code {
553
553
 
554
554
  p.signature, h3.signature, p.signature tt, h3.signature tt{
555
555
  font-family: var(--monospace-font);
556
+ }
557
+
558
+ @media (min-width: 920px) {
559
+ #class_list_link { display: none !important; }
556
560
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discorb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sevenc-nanashi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-20 00:00:00.000000000 Z
11
+ date: 2022-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -95,7 +95,12 @@ files:
95
95
  - ".github/workflows/lint-push.yml"
96
96
  - ".github/workflows/lint.yml"
97
97
  - ".github/workflows/package_register.yml"
98
+ - ".github/workflows/spec.yml"
99
+ - ".github/workflows/validate.yml"
98
100
  - ".gitignore"
101
+ - ".lefthook/commit-msg/validator.rb"
102
+ - ".rspec"
103
+ - ".rspec_parallel"
99
104
  - ".rubocop.yml"
100
105
  - ".yardopts"
101
106
  - CODE_OF_CONDUCT.md
@@ -105,6 +110,7 @@ files:
105
110
  - LICENSE.txt
106
111
  - README.md
107
112
  - Rakefile
113
+ - Steepfile
108
114
  - assets/banner.svg
109
115
  - bin/console
110
116
  - bin/setup
@@ -132,29 +138,43 @@ files:
132
138
  - docs/license.md
133
139
  - docs/tutorial.md
134
140
  - docs/voice_events.md
135
- - examples/commands/bookmarker.rb
136
- - examples/commands/hello.rb
137
- - examples/commands/inspect.rb
141
+ - examples/commands/message.rb
142
+ - examples/commands/permission.rb
143
+ - examples/commands/slash.rb
144
+ - examples/commands/user.rb
138
145
  - examples/components/authorization_button.rb
139
146
  - examples/components/select_menu.rb
140
147
  - examples/extension/main.rb
141
148
  - examples/extension/message_expander.rb
149
+ - examples/sig/commands/message.rbs
142
150
  - examples/simple/eval.rb
143
151
  - examples/simple/ping_pong.rb
144
152
  - examples/simple/rolepanel.rb
145
153
  - examples/simple/shard.rb
146
154
  - examples/simple/wait_for_message.rb
147
155
  - exe/discorb
156
+ - lefthook.yml
148
157
  - lib/discorb.rb
149
158
  - lib/discorb/allowed_mentions.rb
150
159
  - lib/discorb/app_command.rb
151
160
  - lib/discorb/app_command/command.rb
161
+ - lib/discorb/app_command/common.rb
152
162
  - lib/discorb/app_command/handler.rb
153
163
  - lib/discorb/application.rb
154
164
  - lib/discorb/asset.rb
155
165
  - lib/discorb/attachment.rb
156
166
  - lib/discorb/audit_logs.rb
167
+ - lib/discorb/automod.rb
157
168
  - lib/discorb/channel.rb
169
+ - lib/discorb/channel/base.rb
170
+ - lib/discorb/channel/category.rb
171
+ - lib/discorb/channel/container.rb
172
+ - lib/discorb/channel/dm.rb
173
+ - lib/discorb/channel/guild.rb
174
+ - lib/discorb/channel/stage.rb
175
+ - lib/discorb/channel/text.rb
176
+ - lib/discorb/channel/thread.rb
177
+ - lib/discorb/channel/voice.rb
158
178
  - lib/discorb/client.rb
159
179
  - lib/discorb/color.rb
160
180
  - lib/discorb/common.rb
@@ -179,6 +199,7 @@ files:
179
199
  - lib/discorb/extension.rb
180
200
  - lib/discorb/flag.rb
181
201
  - lib/discorb/gateway.rb
202
+ - lib/discorb/gateway_events.rb
182
203
  - lib/discorb/gateway_requests.rb
183
204
  - lib/discorb/guild.rb
184
205
  - lib/discorb/guild_template.rb
@@ -211,7 +232,82 @@ files:
211
232
  - lib/discorb/voice_state.rb
212
233
  - lib/discorb/webhook.rb
213
234
  - po/yard.pot
235
+ - rbs_collection.lock.yaml
236
+ - rbs_collection.yaml
237
+ - sig/async.rbs
214
238
  - sig/discorb.rbs
239
+ - sig/discorb/activity.rbs
240
+ - sig/discorb/allowed_mentions.rbs
241
+ - sig/discorb/app_command/base.rbs
242
+ - sig/discorb/app_command/handler.rbs
243
+ - sig/discorb/application.rbs
244
+ - sig/discorb/asset.rbs
245
+ - sig/discorb/attachment.rbs
246
+ - sig/discorb/audit_log.rbs
247
+ - sig/discorb/automod.rbs
248
+ - sig/discorb/avatar.rbs
249
+ - sig/discorb/channel/base.rbs
250
+ - sig/discorb/channel/category.rbs
251
+ - sig/discorb/channel/container.rbs
252
+ - sig/discorb/channel/dm.rbs
253
+ - sig/discorb/channel/news.rbs
254
+ - sig/discorb/channel/stage.rbs
255
+ - sig/discorb/channel/text.rbs
256
+ - sig/discorb/channel/thread.rbs
257
+ - sig/discorb/channel/voice.rbs
258
+ - sig/discorb/client.rbs
259
+ - sig/discorb/color.rbs
260
+ - sig/discorb/component/base.rbs
261
+ - sig/discorb/component/button.rbs
262
+ - sig/discorb/component/select_menu.rbs
263
+ - sig/discorb/component/text_input.rbs
264
+ - sig/discorb/connectable.rbs
265
+ - sig/discorb/custom_emoji.rbs
266
+ - sig/discorb/dictionary.rbs
267
+ - sig/discorb/discord_model.rbs
268
+ - sig/discorb/embed.rbs
269
+ - sig/discorb/emoji.rbs
270
+ - sig/discorb/error.rbs
271
+ - sig/discorb/event_handler.rbs
272
+ - sig/discorb/extension.rbs
273
+ - sig/discorb/flag.rbs
274
+ - sig/discorb/gateway.rbs
275
+ - sig/discorb/guild.rbs
276
+ - sig/discorb/guild_template.rbs
277
+ - sig/discorb/http.rbs
278
+ - sig/discorb/image.rbs
279
+ - sig/discorb/integration.rbs
280
+ - sig/discorb/intents.rbs
281
+ - sig/discorb/interaction/autocomplete.rbs
282
+ - sig/discorb/interaction/base.rbs
283
+ - sig/discorb/interaction/command.rbs
284
+ - sig/discorb/interaction/message_component.rbs
285
+ - sig/discorb/interaction/modal.rbs
286
+ - sig/discorb/interaction/responder.rbs
287
+ - sig/discorb/invite.rbs
288
+ - sig/discorb/member.rbs
289
+ - sig/discorb/message.rbs
290
+ - sig/discorb/messageable.rbs
291
+ - sig/discorb/partial_emoji.rbs
292
+ - sig/discorb/permissions.rbs
293
+ - sig/discorb/presence.rbs
294
+ - sig/discorb/reaction.rbs
295
+ - sig/discorb/role.rbs
296
+ - sig/discorb/scheduled_event.rbs
297
+ - sig/discorb/shard.rbs
298
+ - sig/discorb/snowflake.rbs
299
+ - sig/discorb/stage_instance.rbs
300
+ - sig/discorb/sticker.rbs
301
+ - sig/discorb/system_channel_flag.rbs
302
+ - sig/discorb/unicode_emoji.rbs
303
+ - sig/discorb/user.rbs
304
+ - sig/discorb/utils.rbs
305
+ - sig/discorb/voice_region.rbs
306
+ - sig/discorb/voice_state.rbs
307
+ - sig/discorb/webhook.rbs
308
+ - sig/discorb/welcome_screen.rbs
309
+ - sig/manifest.yaml
310
+ - sig/override.rbs
215
311
  - template-replace/files/css/common.css
216
312
  - template-replace/files/favicon.png
217
313
  - template-replace/resources/version_list.html
@@ -246,7 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
342
  - !ruby/object:Gem::Version
247
343
  version: '0'
248
344
  requirements: []
249
- rubygems_version: 3.2.32
345
+ rubygems_version: 3.3.3
250
346
  signing_key:
251
347
  specification_version: 4
252
348
  summary: A Discord API wrapper for Ruby, Using socketry/async.
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
- require "discorb"
3
- require "json"
4
-
5
- client = Discorb::Client.new
6
-
7
- client.once :standby do
8
- puts "Logged in as #{client.user}"
9
- end
10
-
11
- def bookmark_channel(guild)
12
- guild.channels.find { |c| c.is_a?(Discorb::TextChannel) && c.name == "bookmarks" }
13
- end
14
-
15
- def build_embed_from_message(message)
16
- embed = Discorb::Embed.new
17
- embed.description = message.content
18
- embed.author = Discorb::Embed::Author.new(message.author.to_s_user, icon: message.author.avatar.url)
19
- embed.timestamp = message.timestamp
20
- embed.footer = Discorb::Embed::Footer.new("Message ID: #{message.id}")
21
- embed
22
- end
23
-
24
- client.message_command("Bookmark", guild_ids: [857_373_681_096_327_180]) do |interaction, message|
25
- unless channel = bookmark_channel(interaction.guild)
26
- interaction.post("Bookmark channel not found. Please create one called `bookmarks`.", ephemeral: true)
27
- next
28
- end
29
- channel.post(
30
- message.jump_url,
31
- embed: build_embed_from_message(message),
32
- ).wait
33
- interaction.post("Bookmarked!", ephemeral: true)
34
- end
35
-
36
- client.change_presence(
37
- Discorb::Activity.new(
38
- "Open message context menu to bookmark"
39
- )
40
- )
41
-
42
- client.run(ENV["DISCORD_BOT_TOKEN"])
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
- require "discorb"
3
-
4
- client = Discorb::Client.new
5
-
6
- client.slash("hello", "Greet for you") do |interaction|
7
- interaction.post("Hello!", ephemeral: true)
8
- end
9
-
10
- client.run(ENV["DISCORD_BOT_TOKEN"])
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
- require "discorb"
3
-
4
- client = Discorb::Client.new
5
-
6
- client.once :standby do
7
- puts "Logged in as #{client.user}"
8
- end
9
-
10
- client.user_command("Info", guild_ids: [857_373_681_096_327_180]) do |interaction|
11
- interaction.post(embed: Discorb::Embed.new(
12
- "Information of #{interaction.target.to_s_user}",
13
- fields: [
14
- Discorb::Embed::Field.new("User", interaction.target.to_s_user),
15
- Discorb::Embed::Field.new("ID", interaction.target.id),
16
- Discorb::Embed::Field.new("Bot", interaction.target.bot? ? "Yes" : "No"),
17
- Discorb::Embed::Field.new("Joined at", interaction.target.joined_at.to_df("F")),
18
- Discorb::Embed::Field.new("Created at", interaction.target.created_at.to_df("F"))
19
- ],
20
- thumbnail: interaction.target.avatar&.url,
21
-
22
- ), ephemeral: true)
23
- end
24
-
25
- client.run(ENV["DISCORD_BOT_TOKEN"])