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
@@ -0,0 +1,142 @@
1
+ module Discorb
2
+ #
3
+ # Represents RGB color.
4
+ class Color
5
+ #
6
+ # Create a color from a Integer.
7
+ #
8
+ # @param [Integer] value A color value.
9
+ def initialize: (Integer value) -> void
10
+
11
+ #
12
+ # Integerize a color.
13
+ #
14
+ # @return [Integer] A color value.
15
+ def to_i: -> Integer
16
+
17
+ #
18
+ # Convert a color to a hexadecimal value.
19
+ #
20
+ # @return [String] A hexadecimal value.
21
+ def to_hex: -> String
22
+
23
+ #
24
+ # Convert a color to RGB array.
25
+ #
26
+ # @return [Array(Integer, Integer, Integer)] A RGB array.
27
+ def to_rgb: -> [Integer, Integer, Integer]
28
+
29
+ alias to_a to_rgb
30
+ alias deconstruct to_rgb
31
+
32
+ #
33
+ # Convert a color to RGB hash.
34
+ #
35
+ # @return [Hash{:r, :g, :b => Integer}] A RGB hash.
36
+ def to_rgb_hash: -> { r: Integer, g: Integer, b: Integer }
37
+
38
+ alias deconstruct_keys to_rgb_hash
39
+
40
+ #
41
+ # Converts a color to a `#000000` string.
42
+ #
43
+ # @return [String] Converted string.
44
+ def to_s: -> String
45
+
46
+ def inspect: -> String
47
+
48
+ #
49
+ # Create a color from a hexadecimal string.
50
+ #
51
+ # @param [String] hex A hexadecimal string.
52
+ #
53
+ # @return [Discorb::Color] A color object.
54
+ def self.from_hex: (String hex) -> Discorb::Color
55
+
56
+ #
57
+ # Create a color from a RGB array.
58
+ #
59
+ # @param [Integer] red A red value.
60
+ # @param [Integer] green A green value.
61
+ # @param [Integer] blue A blue value.
62
+ #
63
+ # @return [Discorb::Color] A color object.
64
+ def self.from_rgb: (
65
+ Integer red,
66
+ Integer green,
67
+ Integer blue
68
+ ) -> Discorb::Color
69
+
70
+ #
71
+ # Create a color from a Discord's color.
72
+ # Currently these colors are supported:
73
+ #
74
+ # | Color Name | Hexadecimal |
75
+ # |------------|------------|
76
+ # | `:teal` | `#1abc9c` |
77
+ # | `:dark_teal` | `#11806a` |
78
+ # | `:green` | `#2ecc71` |
79
+ # | `:dark_green` | `#1f8b4c` |
80
+ # | `:blue` | `#3498db` |
81
+ # | `:dark_blue` | `#206694` |
82
+ # | `:purple` | `#9b59b6` |
83
+ # | `:dark_purple` | `#71368a` |
84
+ # | `:magenta` | `#e91e63` |
85
+ # | `:dark_magenta` | `#ad1457` |
86
+ # | `:gold` | `#f1c40f` |
87
+ # | `:dark_gold` | `#c27c0e` |
88
+ # | `:orange` | `#e67e22` |
89
+ # | `:dark_orange` | `#a84300` |
90
+ # | `:red` | `#e74c3c` |
91
+ # | `:dark_red` | `#992d22` |
92
+ # | `:lighter_grey` | `#95a5a6` |
93
+ # | `:lighter_gray` | `#95a5a6` |
94
+ # | `:dark_grey` | `#607d8b` |
95
+ # | `:dark_gray` | `#607d8b` |
96
+ # | `:light_grey` | `#979c9f` |
97
+ # | `:light_gray` | `#979c9f` |
98
+ # | `:darker_grey` | `#546e7a` |
99
+ # | `:darker_gray` | `#546e7a` |
100
+ # | `:og_blurple` | `#7289da` |
101
+ # | `:blurple` | `#5865f2` |
102
+ # | `:greyple` | `#99aab5` |
103
+ # | `:dark_theme` | `#36393f` |
104
+ # | `:fuchsia` | `#eb459e` |
105
+ # | `:dark_teal` | `#11806a` |
106
+ # | `:green` | `#2ecc71` |
107
+ # | `:dark_green` | `#1f8b4c` |
108
+ # | `:blue` | `#3498db` |
109
+ # | `:dark_blue` | `#206694` |
110
+ # | `:purple` | `#9b59b6` |
111
+ # | `:dark_purple` | `#71368a` |
112
+ # | `:magenta` | `#e91e63` |
113
+ # | `:dark_magenta` | `#ad1457` |
114
+ # | `:gold` | `#f1c40f` |
115
+ # | `:dark_gold` | `#c27c0e` |
116
+ # | `:orange` | `#e67e22` |
117
+ # | `:dark_orange` | `#a84300` |
118
+ # | `:red` | `#e74c3c` |
119
+ # | `:dark_red` | `#992d22` |
120
+ # | `:lighter_grey` | `#95a5a6` |
121
+ # | `:lighter_gray` | `#95a5a6` |
122
+ # | `:dark_grey` | `#607d8b` |
123
+ # | `:dark_gray` | `#607d8b` |
124
+ # | `:light_grey` | `#979c9f` |
125
+ # | `:light_gray` | `#979c9f` |
126
+ # | `:darker_grey` | `#546e7a` |
127
+ # | `:darker_gray` | `#546e7a` |
128
+ # | `:og_blurple` | `#7289da` |
129
+ # | `:blurple` | `#5865f2` |
130
+ # | `:greyple` | `#99aab5` |
131
+ # | `:dark_theme` | `#36393f` |
132
+ # | `:fuchsia` | `#eb459e` |
133
+ #
134
+ # @param [Symbol] color A Discord color name.
135
+ #
136
+ # @return [Discorb::Color] A color object.
137
+ def self.[]: (Symbol color) -> Discorb::Color
138
+
139
+ # Returns the value of attribute value.
140
+ attr_accessor value: untyped
141
+ end
142
+ end
@@ -0,0 +1,28 @@
1
+ module Discorb
2
+ #
3
+ # @abstract
4
+ # Represents a Discord component.
5
+ class Component
6
+ def inspect: -> String
7
+
8
+ #
9
+ # Create a new component from hash data.
10
+ #
11
+ # @see https://discord.com/developers/docs/interactions/message-components Official Discord API documentation
12
+ # @param [Hash] data Hash data.
13
+ #
14
+ # @return [Component] A new component.
15
+ def self.from_hash: (Discorb::json data) -> Component
16
+
17
+ #
18
+ # Convert components to a hash.
19
+ #
20
+ # @param [Array<Discorb::Component>, Array<Array<Discorb::Component>>] components Components.
21
+ #
22
+ # @return [Array<Hash>] Hash data.
23
+ def self.to_payload: (
24
+ ::Array[Discorb::Component]
25
+ | ::Array[::Array[Discorb::Component]] components
26
+ ) -> Discorb::json
27
+ end
28
+ end
@@ -0,0 +1,65 @@
1
+ module Discorb
2
+ #
3
+ # Represents a button component.
4
+ class Button < Discorb::Component
5
+ STYLES: untyped
6
+
7
+ #
8
+ # Initialize a new button.
9
+ #
10
+ # @param [String] label The label of the button.
11
+ # @param [:primary, :secondary, :success, :danger, :link] style The style of the button.
12
+ # @param [Discorb::emoji] emoji The emoji of the button.
13
+ # @param [String] custom_id The custom ID of the button.
14
+ # @param [String] url The URL of the button.
15
+ # @param [Boolean] disabled Whether the button is disabled.
16
+ def initialize: (
17
+ String label,
18
+ ?Symbol style,
19
+ ?emoji: Discorb::emoji?,
20
+ ?custom_id: String?,
21
+ ?url: String?,
22
+ ?disabled: bool
23
+ ) -> void
24
+
25
+ #
26
+ # Converts the button to a hash.
27
+ #
28
+ # @see https://discord.com/developers/docs/interactions/message-components#button-object-button-structure
29
+ # Official Discord API docs
30
+ # @return [Hash] A hash representation of the button.
31
+ def to_hash: -> Discorb::json
32
+
33
+ def inspect: -> String
34
+
35
+ #
36
+ # Creates a new button from a hash.
37
+ #
38
+ # @param [Hash] data The hash to create the button from.
39
+ #
40
+ # @return [Discorb::Button] The created button.
41
+ def self.from_hash: (Discorb::json data) -> Discorb::Button
42
+
43
+ # @return [String] The label of the button.
44
+ attr_accessor label: String
45
+
46
+ # @return [:primary, :secondary, :success, :danger, :link] The style of the button.
47
+ attr_accessor style: Symbol
48
+
49
+ # @return [Discorb::emoji] The emoji of the button.
50
+ attr_accessor emoji: Discorb::emoji?
51
+
52
+ # @return [String] The custom ID of the button.
53
+ # Won't be used if the style is `:link`.
54
+ attr_accessor custom_id: String?
55
+
56
+ # @return [String] The URL of the button.
57
+ # Only used when the style is `:link`.
58
+ attr_accessor url: String?
59
+
60
+ # @return [Boolean] Whether the button is disabled.
61
+ attr_accessor disabled: bool
62
+
63
+ alias disabled? disabled
64
+ end
65
+ end
@@ -0,0 +1,107 @@
1
+ module Discorb
2
+ #
3
+ # Represents a select menu component.
4
+ class SelectMenu < Discorb::Component
5
+ #
6
+ # Initialize a new select menu.
7
+ #
8
+ # @param [String, Symbol] custom_id Custom ID of the select menu.
9
+ # @param [Array<Discorb::SelectMenu::Option>] options The options of the select menu.
10
+ # @param [String] placeholder The placeholder of the select menu.
11
+ # @param [Integer] min_values The minimum number of values.
12
+ # @param [Integer] max_values The maximum number of values.
13
+ def initialize: (
14
+ String | Symbol custom_id,
15
+ ::Array[Discorb::SelectMenu::Option] options,
16
+ ?placeholder: String?,
17
+ ?min_values: Integer,
18
+ ?max_values: Integer
19
+ ) -> void
20
+
21
+ #
22
+ # Converts the select menu to a hash.
23
+ #
24
+ # @see https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-structure
25
+ # Official Discord API docs
26
+ # @return [Hash] A hash representation of the select menu.
27
+ def to_hash: -> Discorb::json
28
+
29
+ def inspect: -> String
30
+
31
+ #
32
+ # Creates a new select menu from a hash.
33
+ #
34
+ # @param [Hash] data The hash to create the select menu from.
35
+ #
36
+ # @return [Discorb::SelectMenu] The created select menu.
37
+ def self.from_hash: (Discorb::json data) -> Discorb::SelectMenu
38
+
39
+ # @return [String] The custom ID of the select menu.
40
+ attr_accessor custom_id: String | Symbol
41
+
42
+ # @return [Array<SelectMenu::Option>] The options of the select menu.
43
+ attr_accessor options: ::Array[SelectMenu::Option]
44
+
45
+ # @return [Integer] The minimum number of values.
46
+ attr_accessor min_values: Integer
47
+
48
+ # @return [Integer] The maximum number of values.
49
+ attr_accessor max_values: Integer
50
+
51
+ # @return [Boolean] Whether the select menu is disabled.
52
+ attr_accessor disabled: bool
53
+
54
+ #
55
+ # Represents an option of a select menu.
56
+ class Option
57
+ #
58
+ # Initialize a new option.
59
+ #
60
+ # @param [String] label The label of the option.
61
+ # @param [String] value The value of the option.
62
+ # @param [String] description The description of the option.
63
+ # @param [Discorb::emoji] emoji The emoji of the option.
64
+ # @param [Boolean] default Whether the option is default.
65
+ def initialize: (
66
+ String label,
67
+ String value,
68
+ ?description: String?,
69
+ ?emoji: Discorb::emoji?,
70
+ ?default: bool
71
+ ) -> void
72
+
73
+ #
74
+ # Converts the option to a hash.
75
+ #
76
+ # @see https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure
77
+ # Official Discord API docs
78
+ # @return [Hash] Hash representation of the option.
79
+ def to_hash: -> Discorb::json
80
+
81
+ def inspect: -> String
82
+
83
+ #
84
+ # Creates a new option from a hash.
85
+ #
86
+ # @param [Hash] data A hash representing the option.
87
+ #
88
+ # @return [Discorb::SelectMenu::Option] A new option.
89
+ def self.from_hash: (Discorb::json data) -> Discorb::SelectMenu::Option
90
+
91
+ # @return [String] The label of the option.
92
+ attr_accessor label: String
93
+
94
+ # @return [String] The value of the option.
95
+ attr_accessor value: String
96
+
97
+ # @return [String] The description of the option.
98
+ attr_accessor description: String?
99
+
100
+ # @return [Discorb::emoji] The emoji of the option.
101
+ attr_accessor emoji: Discorb::emoji?
102
+
103
+ # @return [Boolean] Whether the option is default.
104
+ attr_accessor default: bool
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,69 @@
1
+ module Discorb
2
+ #
3
+ # Represents a text input component.
4
+ class TextInput < Discorb::Component
5
+ STYLES: untyped
6
+
7
+ #
8
+ # Initialize a new text input component.
9
+ #
10
+ # @param [String] label The label of the text input.
11
+ # @param [String] custom_id The custom id of the text input.
12
+ # @param [:short, :paragraph] style The style of the text input.
13
+ # @param [Integer, nil] min_length The minimum length of the text input.
14
+ # @param [Integer, nil] max_length The maximum length of the text input.
15
+ # @param [Boolean] required Whether the text input is required.
16
+ # @param [String, nil] value The prefilled value of the text input.
17
+ # @param [String, nil] placeholder The placeholder of the text input.
18
+ def initialize: (
19
+ String label,
20
+ String custom_id,
21
+ Symbol style,
22
+ ?min_length: Integer?,
23
+ ?max_length: Integer?,
24
+ ?required: bool,
25
+ ?value: String?,
26
+ ?placeholder: String?
27
+ ) -> void
28
+
29
+ #
30
+ # Converts the select menu to a hash.
31
+ #
32
+ # @see https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-structure
33
+ # Official Discord API docs
34
+ # @return [Hash] A hash representation of the text input.
35
+ def to_hash: -> Discorb::json
36
+
37
+ #
38
+ # Creates a new text input from a hash.
39
+ #
40
+ # @param [Hash] data The hash to create the text input from.
41
+ #
42
+ # @return [Discorb::TextInput] The created text input.
43
+ def self.from_hash: (Discorb::json data) -> Discorb::TextInput
44
+
45
+ # @return [String] The label of the text input.
46
+ attr_accessor label: String
47
+
48
+ # @return [String] The custom id of the text input.
49
+ attr_accessor custom_id: String
50
+
51
+ # @return [:short, :paragraph] The style of the text input.
52
+ attr_accessor style: Symbol
53
+
54
+ # @return [Integer, nil] The minimum length of the text input.
55
+ attr_accessor min_length: Integer?
56
+
57
+ # @return [Integer, nil] The maximum length of the text input.
58
+ attr_accessor max_length: Integer?
59
+
60
+ # @return [Boolean] Whether the text input is required.
61
+ attr_accessor required: bool
62
+
63
+ # @return [String, nil] The prefilled value of the text input.
64
+ attr_accessor value: String?
65
+
66
+ # @return [String, nil] The placeholder of the text input.
67
+ attr_accessor placeholder: String?
68
+ end
69
+ end
@@ -0,0 +1,8 @@
1
+ module Discorb
2
+ #
3
+ # Module for connecting to a voice channel.
4
+ # This will be discord-voice gem.
5
+ module Connectable
6
+ def connect: -> untyped
7
+ end
8
+ end
@@ -0,0 +1,90 @@
1
+ module Discorb
2
+ # Represents a custom emoji in discord.
3
+ class CustomEmoji < Discorb::Emoji
4
+ #
5
+ # Initialize a new custom emoji.
6
+ # @private
7
+ #
8
+ # @param [Discorb::Client] client The client that owns this emoji.
9
+ # @param [Discorb::Guild] guild The guild that owns this emoji.
10
+ # @param [Hash] data The data of the emoji.
11
+ def initialize: (
12
+ Discorb::Client client,
13
+ Discorb::Guild guild,
14
+ Discorb::json data
15
+ ) -> void
16
+
17
+ #
18
+ # Format the emoji for sending.
19
+ #
20
+ # @return [String] the formatted emoji.
21
+ def to_s: -> String
22
+
23
+ #
24
+ # Format the emoji for URI.
25
+ #
26
+ # @return [String] the formatted emoji.
27
+ def to_uri: -> String
28
+
29
+ def inspect: -> String
30
+
31
+ #
32
+ # Edit the emoji.
33
+ # @async
34
+ # @macro edit
35
+ #
36
+ # @param [String] name The new name of the emoji.
37
+ # @param [Array<Discorb::Role>] roles The new roles that can use this emoji.
38
+ # @param [String] reason The reason for editing the emoji.
39
+ #
40
+ # @return [Async::Task<self>] The edited emoji.
41
+ def edit: (
42
+ ?name: String,
43
+ ?roles: ::Array[Discorb::Role],
44
+ ?reason: String?
45
+ ) -> Async::Task[self]
46
+
47
+ #
48
+ # Delete the emoji.
49
+ # @async
50
+ #
51
+ # @param [String] reason The reason for deleting the emoji.
52
+ #
53
+ # @return [Async::Task<self>] The deleted emoji.
54
+ def delete!: (?reason: String?) -> Async::Task[self]
55
+
56
+ #
57
+ # Converts the object to a hash.
58
+ # @private
59
+ #
60
+ # @return [Hash] The hash represents the object.
61
+ def to_hash: -> Discorb::json
62
+
63
+ # @return [Discorb::Snowflake] The ID of the emoji.
64
+ attr_reader id: Discorb::Snowflake
65
+
66
+ # @return [String] The name of the emoji.
67
+ attr_reader name: String
68
+
69
+ # @return [Array<Discorb::Role>] The roles that can use this emoji.
70
+ attr_reader roles: ::Array[Discorb::Role]
71
+
72
+ # @return [Discorb::User] The user that created this emoji.
73
+ attr_reader user: Discorb::User
74
+
75
+ # @return [Discorb::Guild] The guild that owns this emoji.
76
+ attr_reader guild: Discorb::Guild
77
+
78
+ # @return [Boolean] whether the emoji is managed by integration (ex: Twitch).
79
+ attr_reader managed: bool
80
+
81
+ # @return [Boolean] whether the emoji requires colons.
82
+ attr_reader require_colons: bool
83
+
84
+ # @return [Boolean] whether the emoji is available.
85
+ attr_reader available: bool
86
+
87
+ # @return [Boolean] whether or not this emoji is restricted to certain roles.
88
+ attr_reader roles?: bool
89
+ end
90
+ end
@@ -0,0 +1,85 @@
1
+ module Discorb
2
+ #
3
+ # Extended hash class. This is used for storing pair of ID and object.
4
+ class Dictionary[K < _ToS, V] < Array[V]
5
+ #
6
+ # Initialize a new Dictionary.
7
+ #
8
+ # @param [Hash] hash A hash of items to add to the dictionary.
9
+ # @param [Integer] limit The maximum number of items in the dictionary.
10
+ # @param [false, Proc] sort Whether to sort the items in the dictionary.
11
+ def initialize: (
12
+ ?::Hash[untyped, untyped] hash,
13
+ ?limit: Integer?,
14
+ ?sort: bool | Proc
15
+ ) -> void
16
+
17
+ #
18
+ # Registers a new item in the dictionary.
19
+ #
20
+ # @param [#to_s] id The ID of the item.
21
+ # @param [Object] body The item to register.
22
+ #
23
+ # @return [self] The dictionary.
24
+ def register: (_ToS id, Object body) -> self
25
+
26
+ alias []= register
27
+
28
+ #
29
+ # Merges another dictionary into this one.
30
+ #
31
+ # @param [Discorb::Dictionary] other The dictionary to merge.
32
+ def merge: (Discorb::Dictionary[untyped, untyped] other) -> untyped
33
+
34
+ #
35
+ # Removes an item from the dictionary.
36
+ #
37
+ # @param [#to_s] id The ID of the item to remove.
38
+ def remove: (_ToS id) -> untyped
39
+
40
+ #
41
+ # Get an item from the dictionary.
42
+ #
43
+ # @param [#to_s] id The ID of the item.
44
+ # @return [Object] The item.
45
+ # @return [nil] if the item was not found.
46
+ #
47
+ # @overload get(index)
48
+ # @param [Integer] index The index of the item.
49
+ #
50
+ # @return [Object] The item.
51
+ # @return [nil] if the item is not found.
52
+ def get: (_ToS id) -> V | (Integer index) -> V
53
+
54
+ alias [] get
55
+
56
+ #
57
+ # Returns the values of the dictionary.
58
+ #
59
+ # @return [Array] The values of the dictionary.
60
+ def values: -> ::Array[V]
61
+
62
+ #
63
+ # Checks if the dictionary has an ID.
64
+ #
65
+ # @param [#to_s] id The ID to check.
66
+ #
67
+ # @return [Boolean] `true` if the dictionary has the ID, `false` otherwise.
68
+ def has?: (_ToS id) -> bool
69
+
70
+ #
71
+ # Send a message to the array of values.
72
+ def method_missing: (untyped name) -> untyped
73
+
74
+ def respond_to_missing?: (
75
+ untyped name,
76
+ untyped args,
77
+ untyped kwargs
78
+ ) -> bool
79
+
80
+ def inspect: -> String
81
+
82
+ # @return [Integer] The maximum number of items in the dictionary.
83
+ attr_accessor limit: Integer?
84
+ end
85
+ end
@@ -0,0 +1,15 @@
1
+ module Discorb
2
+ #
3
+ # @abstract
4
+ # Represents Discord model.
5
+ class DiscordModel
6
+ def eql?: (untyped other) -> bool
7
+
8
+ def ==: (untyped other) -> untyped
9
+
10
+ def inspect: -> String
11
+
12
+ # @private
13
+ def hash: -> untyped
14
+ end
15
+ end