discorb 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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/po/yard.pot CHANGED
@@ -2907,23 +2907,23 @@ msgid "### How can I send files?"
2907
2907
  msgstr ""
2908
2908
 
2909
2909
  #: ../docs/faq.md:65
2910
- msgid "Use {Discorb::File} class."
2910
+ msgid "Use {Discorb::Attachment} class."
2911
2911
  msgstr ""
2912
2912
 
2913
2913
  #: ../docs/faq.md:67
2914
2914
  msgid "```ruby\n"
2915
2915
  "# Send a file\n"
2916
- "message.channel.post file: Discorb::File.new(File.open(\"./README.md\"))"
2916
+ "message.channel.post file: Discorb::Attachment.new(File.open(\"./README.md\"))"
2917
2917
  msgstr ""
2918
2918
 
2919
2919
  #: ../docs/faq.md:71
2920
2920
  msgid "# Send some files with text\n"
2921
- "message.channel.post \"File!\", files: [Discorb::File.new(File.open(\"./README.md\")), Discorb::File.new(File.open(\"./License.txt\"))]"
2921
+ "message.channel.post \"File!\", files: [Discorb::Attachment.new(File.open(\"./README.md\")), Discorb::Attachment.new(File.open(\"./License.txt\"))]"
2922
2922
  msgstr ""
2923
2923
 
2924
2924
  #: ../docs/faq.md:74
2925
2925
  msgid "# Send a string as a file\n"
2926
- "message.channel.post file: Discorb::File.from_string(\"Hello world!\", \"hello.txt\")\n"
2926
+ "message.channel.post file: Discorb::Attachment.from_string(\"Hello world!\", \"hello.txt\")\n"
2927
2927
  "```"
2928
2928
  msgstr ""
2929
2929
 
@@ -4519,7 +4519,7 @@ msgid "Command block."
4519
4519
  msgstr ""
4520
4520
 
4521
4521
  # @return [Discorb::ApplicationCommand::Command::GroupCommand]
4522
- # @return [Discorb::ApplicationCommand::Command::SlashCommand]
4522
+ # @return [Discorb::ApplicationCommand::Command::ChatInputCommand]
4523
4523
  # @return [Discorb::ApplicationCommand::Command::SubcommandGroup]
4524
4524
  # @return [Discorb::ApplicationCommand::Command]
4525
4525
  #: ../lib/discorb/app_command.rb:40
@@ -4722,7 +4722,7 @@ msgstr ""
4722
4722
  msgid "a new instance of Command"
4723
4723
  msgstr ""
4724
4724
 
4725
- # Discorb::ApplicationCommand::Command::SlashCommand
4725
+ # Discorb::ApplicationCommand::Command::ChatInputCommand
4726
4726
  #: ../lib/discorb/app_command.rb:194
4727
4727
  msgid "Represents the slash command."
4728
4728
  msgstr ""
@@ -4738,12 +4738,12 @@ msgstr ""
4738
4738
  msgid "The options of the command."
4739
4739
  msgstr ""
4740
4740
 
4741
- # @return [SlashCommand]
4741
+ # @return [ChatInputCommand]
4742
4742
  #: ../lib/discorb/app_command.rb:203
4743
- msgid "a new instance of SlashCommand"
4743
+ msgid "a new instance of ChatInputCommand"
4744
4744
  msgstr ""
4745
4745
 
4746
- # Discorb::ApplicationCommand::Command::SlashCommand#to_s
4746
+ # Discorb::ApplicationCommand::Command::ChatInputCommand#to_s
4747
4747
  #: ../lib/discorb/app_command.rb:213
4748
4748
  msgid "Returns the commands name."
4749
4749
  msgstr ""
@@ -4753,8 +4753,8 @@ msgstr ""
4753
4753
  msgid "Represents the command with subcommands."
4754
4754
  msgstr ""
4755
4755
 
4756
- # @return [Array<Discorb::ApplicationCommand::Command::SlashCommand, Discorb::ApplicationCommand::Command::SubcommandGroup>]
4757
- # @return [Array<Discorb::ApplicationCommand::Command::SlashCommand>]
4756
+ # @return [Array<Discorb::ApplicationCommand::Command::ChatInputCommand, Discorb::ApplicationCommand::Command::SubcommandGroup>]
4757
+ # @return [Array<Discorb::ApplicationCommand::Command::ChatInputCommand>]
4758
4758
  #: ../lib/discorb/app_command.rb:275
4759
4759
  #: ../lib/discorb/app_command.rb:372
4760
4760
  msgid "The subcommands of the command."
@@ -4772,7 +4772,7 @@ msgstr ""
4772
4772
  msgid "Add new subcommand."
4773
4773
  msgstr ""
4774
4774
 
4775
- # @return [Discorb::ApplicationCommand::Command::SlashCommand]
4775
+ # @return [Discorb::ApplicationCommand::Command::ChatInputCommand]
4776
4776
  #: ../lib/discorb/app_command.rb:294
4777
4777
  #: ../lib/discorb/app_command.rb:391
4778
4778
  msgid "The added subcommand."
@@ -9511,7 +9511,7 @@ msgstr ""
9511
9511
  msgid "a new instance of Attachment"
9512
9512
  msgstr ""
9513
9513
 
9514
- # Discorb::File
9514
+ # Discorb::Attachment
9515
9515
  #: ../lib/discorb/file.rb:53
9516
9516
  msgid "Represents a file to send as an attachment."
9517
9517
  msgstr ""
@@ -9537,7 +9537,7 @@ msgstr ""
9537
9537
  msgid "The content type of the file. If not set, it is guessed from the filename."
9538
9538
  msgstr ""
9539
9539
 
9540
- # Discorb::File#initialize
9540
+ # Discorb::Attachment#initialize
9541
9541
  #: ../lib/discorb/file.rb:64
9542
9542
  msgid "Creates a new file from IO."
9543
9543
  msgstr ""
@@ -9570,7 +9570,7 @@ msgstr ""
9570
9570
  msgid "tag|param|content_type"
9571
9571
  msgstr ""
9572
9572
 
9573
- # Discorb::File.from_string
9573
+ # Discorb::Attachment.from_string
9574
9574
  #: ../lib/discorb/file.rb:79
9575
9575
  msgid "Creates a new file from a string."
9576
9576
  msgstr ""
@@ -11738,7 +11738,7 @@ msgstr ""
11738
11738
  msgid "A helper method to send multipart/form-data requests for creating messages."
11739
11739
  msgstr ""
11740
11740
 
11741
- # @param [Array<Discorb::File>]
11741
+ # @param [Array<Discorb::Attachment>]
11742
11742
  #: ../lib/discorb/http.rb:154
11743
11743
  #: ../lib/discorb/interaction/response.rb:91
11744
11744
  #: ../lib/discorb/interaction/response.rb:115
@@ -11750,7 +11750,7 @@ msgstr ""
11750
11750
  msgid "tag|param|files"
11751
11751
  msgstr ""
11752
11752
 
11753
- # @param [Array<Discorb::File>] files
11753
+ # @param [Array<Discorb::Attachment>] files
11754
11754
  #: ../lib/discorb/http.rb:154
11755
11755
  #: ../lib/discorb/interaction/response.rb:91
11756
11756
  #: ../lib/discorb/interaction/response.rb:115
@@ -12122,7 +12122,7 @@ msgstr ""
12122
12122
  msgid "Represents a command interaction."
12123
12123
  msgstr ""
12124
12124
 
12125
- # Discorb::CommandInteraction::SlashCommand
12125
+ # Discorb::CommandInteraction::ChatInputCommand
12126
12126
  #: ../lib/discorb/interaction/command.rb:11
12127
12127
  msgid "Represents a slash command interaction."
12128
12128
  msgstr ""
@@ -12357,7 +12357,7 @@ msgstr ""
12357
12357
  msgid "tag|param|attachments"
12358
12358
  msgstr ""
12359
12359
 
12360
- # @param [Discorb::File]
12360
+ # @param [Discorb::Attachment]
12361
12361
  #: ../lib/discorb/interaction/response.rb:91
12362
12362
  #: ../lib/discorb/interaction/response.rb:115
12363
12363
  #: ../lib/discorb/modules.rb:25
@@ -12375,7 +12375,7 @@ msgstr ""
12375
12375
  msgid "The new embeds of the message."
12376
12376
  msgstr ""
12377
12377
 
12378
- # @param [Discorb::File] file
12378
+ # @param [Discorb::Attachment] file
12379
12379
  #: ../lib/discorb/interaction/response.rb:91
12380
12380
  #: ../lib/discorb/interaction/response.rb:115
12381
12381
  #: ../lib/discorb/modules.rb:25
@@ -0,0 +1,88 @@
1
+ ---
2
+ sources:
3
+ - name: ruby/gem_rbs_collection
4
+ remote: https://github.com/ruby/gem_rbs_collection.git
5
+ revision: main
6
+ repo_dir: gems
7
+ path: ".gem_rbs_collection"
8
+ gems:
9
+ - name: net-http
10
+ version: '0'
11
+ source:
12
+ type: stdlib
13
+ - name: logger
14
+ version: '0'
15
+ source:
16
+ type: stdlib
17
+ - name: ast
18
+ version: '2.4'
19
+ source:
20
+ type: git
21
+ name: ruby/gem_rbs_collection
22
+ revision: 347858a6750d478f6cf1285b4ebd6ae945af2609
23
+ remote: https://github.com/ruby/gem_rbs_collection.git
24
+ repo_dir: gems
25
+ - name: forwardable
26
+ version: '0'
27
+ source:
28
+ type: stdlib
29
+ - name: i18n
30
+ version: '1.10'
31
+ source:
32
+ type: git
33
+ name: ruby/gem_rbs_collection
34
+ revision: 347858a6750d478f6cf1285b4ebd6ae945af2609
35
+ remote: https://github.com/ruby/gem_rbs_collection.git
36
+ repo_dir: gems
37
+ - name: listen
38
+ version: '3.2'
39
+ source:
40
+ type: git
41
+ name: ruby/gem_rbs_collection
42
+ revision: 347858a6750d478f6cf1285b4ebd6ae945af2609
43
+ remote: https://github.com/ruby/gem_rbs_collection.git
44
+ repo_dir: gems
45
+ - name: minitest
46
+ version: '0'
47
+ source:
48
+ type: stdlib
49
+ - name: parallel
50
+ version: '1.20'
51
+ source:
52
+ type: git
53
+ name: ruby/gem_rbs_collection
54
+ revision: 347858a6750d478f6cf1285b4ebd6ae945af2609
55
+ remote: https://github.com/ruby/gem_rbs_collection.git
56
+ repo_dir: gems
57
+ - name: prime
58
+ version: '0'
59
+ source:
60
+ type: stdlib
61
+ - name: rainbow
62
+ version: '3.0'
63
+ source:
64
+ type: git
65
+ name: ruby/gem_rbs_collection
66
+ revision: 347858a6750d478f6cf1285b4ebd6ae945af2609
67
+ remote: https://github.com/ruby/gem_rbs_collection.git
68
+ repo_dir: gems
69
+ - name: singleton
70
+ version: '0'
71
+ source:
72
+ type: stdlib
73
+ - name: uri
74
+ version: '0'
75
+ source:
76
+ type: stdlib
77
+ - name: timeout
78
+ version: '0'
79
+ source:
80
+ type: stdlib
81
+ - name: monitor
82
+ version: '0'
83
+ source:
84
+ type: stdlib
85
+ - name: mutex_m
86
+ version: '0'
87
+ source:
88
+ type: stdlib
@@ -0,0 +1,21 @@
1
+ # Download sources
2
+ sources:
3
+ - name: ruby/gem_rbs_collection
4
+ remote: https://github.com/ruby/gem_rbs_collection.git
5
+ revision: main
6
+ repo_dir: gems
7
+
8
+ # A directory to install the downloaded RBSs
9
+ path: .gem_rbs_collection
10
+
11
+ gems:
12
+ # Skip loading rbs gem's RBS.
13
+ # It's unnecessary if you don't use rbs as a library.
14
+ - name: rbs
15
+ ignore: true
16
+ - name: discorb
17
+ ignore: true
18
+ - name: net-http
19
+ - name: logger
20
+ - name: activesupport
21
+ ignore: true
data/sig/async.rbs ADDED
@@ -0,0 +1,11 @@
1
+ module Async
2
+ class Task[T]
3
+ def wait: -> T
4
+ end
5
+
6
+ module WebSocket
7
+ class Connection
8
+ def initialize: (untyped, ?untyped, response: untyped, **untyped) -> void
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ module Discorb
2
+ #
3
+ # Represents an activity for Gateway Command.
4
+ class Activity
5
+ TYPES: untyped
6
+
7
+ #
8
+ # Initializes a new Activity.
9
+ #
10
+ # @param [String] name The name of the activity.
11
+ # @param [:playing, :streaming, :listening, :watching, :competing] type The type of activity.
12
+ # @param [String] url The URL of the activity.
13
+ def initialize: (String name, ?Symbol `type`, ?String? url) -> void
14
+
15
+ #
16
+ # Converts the activity to a hash.
17
+ #
18
+ # @return [Hash] A hash representation of the activity.
19
+ def to_hash: -> Discorb::json
20
+
21
+ def inspect: -> String
22
+ end
23
+ end
@@ -0,0 +1,44 @@
1
+ module Discorb
2
+ #
3
+ # Represents a allowed mentions in a message.
4
+ class AllowedMentions
5
+ #
6
+ # Initializes a new instance of the AllowedMentions class.
7
+ #
8
+ # @param [Boolean] everyone Whether to allow @everyone or @here.
9
+ # @param [Boolean, Array<Discorb::Role>] roles The roles to allow, or false to disable.
10
+ # @param [Boolean, Array<Discorb::User>] users The users to allow, or false to disable.
11
+ # @param [Boolean] replied_user Whether to ping the user that sent the message to reply.
12
+ def initialize: (
13
+ ?everyone: bool?,
14
+ ?roles: (bool | ::Array[Discorb::Role])?,
15
+ ?users: (bool | ::Array[Discorb::User])?,
16
+ ?replied_user: bool?
17
+ ) -> void
18
+
19
+ def inspect: -> String
20
+
21
+ #
22
+ # Converts the object to a hash.
23
+ # @private
24
+ #
25
+ # @param [Discorb::AllowedMentions, nil] other The object to merge.
26
+ #
27
+ # @return [Hash] The hash.
28
+ def to_hash: (?Discorb::AllowedMentions? other) -> ::Hash[untyped, untyped]
29
+
30
+ def nil_merge: (*untyped args) -> untyped
31
+
32
+ # @return [Boolean] Whether to allow @everyone or @here.
33
+ attr_accessor everyone: bool?
34
+
35
+ # @return [Boolean, Array<Discorb::Role>] The roles to allow, or false to disable.
36
+ attr_accessor roles: (bool | ::Array[Discorb::Role])?
37
+
38
+ # @return [Boolean, Array<Discorb::User>] The users to allow, or false to disable.
39
+ attr_accessor users: (bool | ::Array[Discorb::User])?
40
+
41
+ # @return [Boolean] Whether to ping the user that sent the message to reply.
42
+ attr_accessor replied_user: bool?
43
+ end
44
+ end
@@ -0,0 +1,282 @@
1
+ module Discorb
2
+ #
3
+ # Handles application commands.
4
+ module ApplicationCommand
5
+ VALID_LOCALES: untyped
6
+ type option =
7
+ {
8
+ name_localizations: Hash[(Symbol | String), String]?,
9
+ description: localizable?,
10
+ required: bool?,
11
+ optional: bool?,
12
+ default: untyped?,
13
+ type: (singleton(String)
14
+ | :string
15
+ | :str
16
+ | singleton(Integer)
17
+ | :integer
18
+ | :int
19
+ | singleton(TrueClass)
20
+ | singleton(FalseClass)
21
+ | :boolean
22
+ | :bool
23
+ | singleton(Discorb::User)
24
+ | singleton(Discorb::Member)
25
+ | :user
26
+ | :member
27
+ | singleton(Discorb::Channel)
28
+ | :channel
29
+ | singleton(Discorb::Role)
30
+ | :role
31
+ | :mentionable
32
+ | singleton(Float)
33
+ | :float
34
+ | :attachment)?,
35
+ choices: Hash[String, (String | Integer | Float)]?,
36
+ choices_localizations: Hash[String, Hash[(Symbol | String), String]]?,
37
+ channel_types: Array[Class]?,
38
+ autocomplete: ^(Discorb::CommandInteraction) -> Hash[String, String]?,
39
+ range: Range[(Integer | Float)]?
40
+ }
41
+ type options = ::Hash[String, option]
42
+ type localizable = String | Hash[Symbol | String, String]
43
+ type guild_ids = Array[_ToS] | false | nil
44
+
45
+ def self?.modify_localization_hash: (
46
+ Hash[Symbol | String, String] hash
47
+ ) -> Hash[String, String]
48
+
49
+ #
50
+ # Represents a application command.
51
+ # @abstract
52
+ class Command < Discorb::DiscordModel
53
+ TYPES: Hash[Integer, Symbol]
54
+
55
+ #
56
+ # Initialize a new command.
57
+ # @private
58
+ #
59
+ # @param [String, Hash{Symbol => String}] name The name of the command.
60
+ # @param [Array<#to_s>, false, nil] guild_ids The guild ids that the command is enabled in.
61
+ # @param [Proc] block The block of the command.
62
+ # @param [Integer] type The type of the command.
63
+ # @param [Boolean] dm_permission Whether the command is enabled in DMs.
64
+ # @param [Discorb::Permission] default_permission The default permission of the command.
65
+ def initialize: (
66
+ Discorb::ApplicationCommand::localizable name,
67
+ Discorb::ApplicationCommand::guild_ids guild_ids,
68
+ ^(Discorb::Interaction, *untyped) -> untyped block,
69
+ Integer `type`,
70
+ ?bool? dm_permission,
71
+ ?Discorb::Permission? default_permission
72
+ ) -> void
73
+
74
+ #
75
+ # Changes the self pointer of block to the given object.
76
+ # @private
77
+ #
78
+ # @param [Object] instance The object to change the self pointer to.
79
+ def replace_block: (Object `instance`) -> untyped
80
+
81
+ #
82
+ # Converts the object to a hash.
83
+ # @private
84
+ #
85
+ # @return [Hash] The hash represents the object.
86
+ def to_hash: -> Discorb::json
87
+
88
+ # @return [Hash{String => String}] The name of the command.
89
+ attr_reader name: ::Hash[String, String]
90
+
91
+ # @return [Array<#to_s>] The guild ids that the command is enabled in.
92
+ attr_reader guild_ids: Discorb::ApplicationCommand::guild_ids
93
+
94
+ # @return [Proc] The block of the command.
95
+ attr_reader block: ^(Discorb::Interaction, *untyped) -> untyped
96
+
97
+ # @return [:chat_input, :user, :message] The type of the command.
98
+ attr_reader type: Symbol
99
+
100
+ # @return [Integer] The raw type of the command.
101
+ attr_reader type_raw: Integer
102
+
103
+ # @return [Discorb::Permission] The default permissions for this command.
104
+ attr_reader default_permission: Discorb::Permission?
105
+
106
+ # @return [Boolean] Whether the command is enabled in DMs.
107
+ attr_reader dm_permission: bool?
108
+
109
+ #
110
+ # Represents the slash command.
111
+ class ChatInputCommand < Discorb::ApplicationCommand::Command
112
+ #
113
+ # Initialize a new slash command.
114
+ # @private
115
+ #
116
+ # @param [String, Hash{Symbol => String}] name The name of the command.
117
+ # The hash should have `default`, and language keys.
118
+ # @param [String, Hash{Symbol => String}] description The description of the command.
119
+ # The hash should have `default`, and language keys.
120
+ # @param [Hash{String => Hash}] options The options of the command.
121
+ # @param [Array<#to_s>] guild_ids The guild ids that the command is enabled in.
122
+ # @param [Proc] block The block of the command.
123
+ # @param [Integer] type The type of the command.
124
+ # @param [Discorb::ApplicationCommand::Command, nil] parent The parent command.
125
+ # @param [Boolean] dm_permission Whether the command is enabled in DMs.
126
+ # @param [Discorb::Permission] default_permission The default permission of the command.
127
+ def initialize: (
128
+ Discorb::ApplicationCommand::localizable name,
129
+ Discorb::ApplicationCommand::localizable description,
130
+ Discorb::ApplicationCommand::options options,
131
+ Discorb::ApplicationCommand::guild_ids guild_ids,
132
+ ^(
133
+ Discorb::CommandInteraction::ChatInputCommand,
134
+ *untyped
135
+ ) -> untyped block,
136
+ Integer `type`,
137
+ Discorb::ApplicationCommand::Command? parent,
138
+ bool? dm_permission,
139
+ Discorb::Permission? default_permission
140
+ ) -> void
141
+
142
+ #
143
+ # Returns the commands name.
144
+ #
145
+ # @return [String] The name of the command.
146
+ def to_s: -> String
147
+
148
+ #
149
+ # Converts the object to a hash.
150
+ # @private
151
+ #
152
+ # @return [Hash] The hash represents the object.
153
+ def to_hash: -> Discorb::json
154
+
155
+ # @return [Hash{String => String}] The description of the command.
156
+ attr_reader description: ::Hash[String, String]
157
+
158
+ # @return [Hash{String => Hash}] The options of the command.
159
+ attr_reader options: ::Hash[String, ::Hash[untyped, untyped]]
160
+ end
161
+
162
+ #
163
+ # Represents the command with subcommands.
164
+ class GroupCommand < Discorb::ApplicationCommand::Command
165
+ #
166
+ # Initialize a new group command.
167
+ # @private
168
+ #
169
+ # @param [String, Hash{Symbol => String}] name The name of the command.
170
+ # @param [String, Hash{Symbol => String}] description The description of the command.
171
+ # @param [Array<#to_s>] guild_ids The guild ids that the command is enabled in.
172
+ # @param [Discorb::Client] client The client of the command.
173
+ # @param [Boolean] dm_permission Whether the command is enabled in DMs.
174
+ # @param [Discorb::Permission] default_permission The default permission of the command.
175
+ def initialize: (
176
+ Discorb::ApplicationCommand::localizable name,
177
+ Discorb::ApplicationCommand::localizable description,
178
+ Discorb::ApplicationCommand::guild_ids guild_ids,
179
+ Discorb::Client client,
180
+ bool? dm_permission,
181
+ Discorb::Permission? default_permission
182
+ ) -> void
183
+
184
+ #
185
+ # Add new subcommand.
186
+ #
187
+ # @param (see Discorb::ApplicationCommand::Handler#slash)
188
+ # @return [Discorb::ApplicationCommand::Command::ChatInputCommand] The added subcommand.
189
+ def slash: (
190
+ String | ::Hash[Symbol, String] command_name,
191
+ String | ::Hash[Symbol, String] description,
192
+ ?Discorb::ApplicationCommand::options options,
193
+ ?dm_permission: bool,
194
+ ?default_permission: Discorb::Permission?
195
+ ) {
196
+ (Discorb::CommandInteraction::ChatInputCommand, *untyped) -> void
197
+ } -> Discorb::ApplicationCommand::Command::ChatInputCommand
198
+
199
+ #
200
+ # Add new subcommand group.
201
+ #
202
+ # @param [String] command_name Group name.
203
+ # @param [String] description Group description.
204
+ #
205
+ # @yield Block to yield with the command.
206
+ # @yieldparam [Discorb::ApplicationCommand::Command::SubcommandGroup] group Group command.
207
+ #
208
+ # @return [Discorb::ApplicationCommand::Command::SubcommandGroup] Command object.
209
+ #
210
+ # @see file:docs/application_command.md Application Commands
211
+ def group: (
212
+ String command_name,
213
+ String description
214
+ ) ?{
215
+ (Discorb::ApplicationCommand::Command::SubcommandGroup group) -> void
216
+ } -> Discorb::ApplicationCommand::Command::SubcommandGroup
217
+
218
+ #
219
+ # Returns the command name.
220
+ #
221
+ # @return [String] The command name.
222
+ def to_s: -> String
223
+
224
+ #
225
+ # Changes the self pointer to the given object.
226
+ # @private
227
+ #
228
+ # @param [Object] instance The object to change to.
229
+ def block_replace: (Object `instance`) -> untyped
230
+
231
+ #
232
+ # Converts the object to a hash.
233
+ # @private
234
+ #
235
+ # @return [Hash] The hash represents the object.
236
+ def to_hash: -> Discorb::json
237
+
238
+ # @return [Array<Discorb::ApplicationCommand::Command>] The subcommands of the command.
239
+ attr_reader commands: ::Array[Discorb::ApplicationCommand::Command]
240
+
241
+ # @return [String] The description of the command.
242
+ attr_reader description: ::Hash[String, String]
243
+ end
244
+
245
+ #
246
+ # Represents the subcommand group.
247
+ class SubcommandGroup < Discorb::ApplicationCommand::Command::GroupCommand
248
+ #
249
+ # Initialize a new subcommand group.
250
+ # @private
251
+ #
252
+ # @param [String] name The name of the command.
253
+ # @param [String] description The description of the command.
254
+ # @param [Discorb::ApplicationCommand::Command::GroupCommand] parent The parent command.
255
+ # @param [Discorb::Client] client The client.
256
+ def initialize: (
257
+ String name,
258
+ String description,
259
+ Discorb::ApplicationCommand::Command::GroupCommand parent,
260
+ Discorb::Client client
261
+ ) -> void
262
+
263
+ def to_s: -> untyped
264
+
265
+ #
266
+ # Add new subcommand.
267
+ # @param (see Discorb::ApplicationCommand::Handler#slash)
268
+ # @return [Discorb::ApplicationCommand::Command::ChatInputCommand] The added subcommand.
269
+ def slash: (
270
+ Discorb::ApplicationCommand::localizable command_name,
271
+ Discorb::ApplicationCommand::localizable description,
272
+ ?Discorb::ApplicationCommand::options options
273
+ ) {
274
+ (Discorb::CommandInteraction::ChatInputCommand, *untyped) -> void
275
+ } -> Discorb::ApplicationCommand::Command::ChatInputCommand
276
+
277
+ # @return [Array<Discorb::ApplicationCommand::Command::ChatInputCommand>] The subcommands of the command.
278
+ attr_reader commands: ::Array[Discorb::ApplicationCommand::Command]
279
+ end
280
+ end
281
+ end
282
+ end