discorb 0.17.1 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/lint.yml +1 -3
- data/.github/workflows/validate.yml +21 -0
- data/Changelog.md +10 -0
- data/Gemfile +6 -0
- data/Rakefile +210 -98
- data/Steepfile +28 -0
- data/docs/events.md +42 -6
- data/docs/tutorial.md +7 -7
- data/docs/voice_events.md +2 -2
- data/examples/commands/message.rb +12 -7
- data/examples/commands/permission.rb +2 -1
- data/examples/commands/slash.rb +23 -19
- data/examples/commands/user.rb +15 -12
- data/examples/components/authorization_button.rb +2 -1
- data/examples/components/select_menu.rb +4 -1
- data/examples/extension/main.rb +1 -0
- data/examples/extension/message_expander.rb +1 -0
- data/examples/sig/commands/message.rbs +5 -0
- data/examples/simple/eval.rb +1 -0
- data/examples/simple/ping_pong.rb +1 -0
- data/examples/simple/rolepanel.rb +16 -5
- data/examples/simple/shard.rb +2 -1
- data/examples/simple/wait_for_message.rb +3 -0
- data/exe/discorb +3 -3
- data/lib/discorb/allowed_mentions.rb +1 -1
- data/lib/discorb/app_command/command.rb +12 -13
- data/lib/discorb/app_command/handler.rb +20 -6
- data/lib/discorb/audit_logs.rb +6 -2
- data/lib/discorb/automod.rb +269 -0
- data/lib/discorb/channel/guild.rb +2 -1
- data/lib/discorb/channel/stage.rb +1 -1
- data/lib/discorb/channel/text.rb +11 -20
- data/lib/discorb/channel/thread.rb +15 -11
- data/lib/discorb/client.rb +12 -10
- data/lib/discorb/color.rb +37 -60
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/dictionary.rb +1 -1
- data/lib/discorb/embed.rb +4 -3
- data/lib/discorb/emoji.rb +2 -2
- data/lib/discorb/exe/about.rb +1 -1
- data/lib/discorb/exe/new.rb +1 -5
- data/lib/discorb/extension.rb +0 -4
- data/lib/discorb/flag.rb +2 -2
- data/lib/discorb/gateway.rb +21 -582
- data/lib/discorb/gateway_events.rb +638 -0
- data/lib/discorb/guild.rb +136 -17
- data/lib/discorb/guild_template.rb +1 -1
- data/lib/discorb/http.rb +47 -25
- data/lib/discorb/intents.rb +27 -18
- data/lib/discorb/interaction/command.rb +14 -10
- data/lib/discorb/interaction/response.rb +74 -14
- data/lib/discorb/member.rb +3 -3
- data/lib/discorb/message.rb +13 -11
- data/lib/discorb/message_meta.rb +2 -3
- data/lib/discorb/modules.rb +3 -2
- data/lib/discorb/presence.rb +4 -2
- data/lib/discorb/reaction.rb +2 -2
- data/lib/discorb/role.rb +1 -1
- data/lib/discorb/sticker.rb +3 -3
- data/lib/discorb/user.rb +2 -2
- data/lib/discorb/voice_state.rb +5 -5
- data/lib/discorb/webhook.rb +15 -6
- data/lib/discorb.rb +2 -2
- data/rbs_collection.lock.yaml +88 -96
- data/rbs_collection.yaml +21 -17
- data/sig/async.rbs +11 -5
- data/sig/discorb/activity.rbs +23 -0
- data/sig/discorb/allowed_mentions.rbs +44 -0
- data/sig/discorb/app_command/base.rbs +282 -0
- data/sig/discorb/app_command/handler.rbs +171 -0
- data/sig/discorb/application.rbs +142 -0
- data/sig/discorb/asset.rbs +32 -0
- data/sig/discorb/attachment.rbs +91 -0
- data/sig/discorb/audit_log.rbs +231 -0
- data/sig/discorb/automod.rbs +128 -0
- data/sig/discorb/avatar.rbs +26 -0
- data/sig/discorb/channel/base.rbs +179 -0
- data/sig/discorb/channel/category.rbs +56 -0
- data/sig/discorb/channel/container.rbs +29 -0
- data/sig/discorb/channel/dm.rbs +14 -0
- data/sig/discorb/channel/news.rbs +20 -0
- data/sig/discorb/channel/stage.rbs +77 -0
- data/sig/discorb/channel/text.rbs +158 -0
- data/sig/discorb/channel/thread.rbs +185 -0
- data/sig/discorb/channel/voice.rbs +41 -0
- data/sig/discorb/client.rbs +2495 -0
- data/sig/discorb/color.rbs +142 -0
- data/sig/discorb/component/base.rbs +28 -0
- data/sig/discorb/component/button.rbs +65 -0
- data/sig/discorb/component/select_menu.rbs +107 -0
- data/sig/discorb/component/text_input.rbs +69 -0
- data/sig/discorb/connectable.rbs +8 -0
- data/sig/discorb/custom_emoji.rbs +90 -0
- data/sig/discorb/dictionary.rbs +85 -0
- data/sig/discorb/discord_model.rbs +15 -0
- data/sig/discorb/embed.rbs +279 -0
- data/sig/discorb/emoji.rbs +13 -0
- data/sig/discorb/error.rbs +73 -0
- data/sig/discorb/event_handler.rbs +27 -0
- data/sig/discorb/extension.rbs +1734 -0
- data/sig/discorb/flag.rbs +72 -0
- data/sig/discorb/gateway.rbs +481 -0
- data/sig/discorb/guild.rbs +870 -0
- data/sig/discorb/guild_template.rbs +174 -0
- data/sig/discorb/http.rbs +147 -0
- data/sig/discorb/image.rbs +20 -0
- data/sig/discorb/integration.rbs +118 -0
- data/sig/discorb/intents.rbs +97 -0
- data/sig/discorb/interaction/autocomplete.rbs +9 -0
- data/sig/discorb/interaction/base.rbs +66 -0
- data/sig/discorb/interaction/command.rbs +66 -0
- data/sig/discorb/interaction/message_component.rbs +140 -0
- data/sig/discorb/interaction/modal.rbs +50 -0
- data/sig/discorb/interaction/responder.rbs +157 -0
- data/sig/discorb/invite.rbs +86 -0
- data/sig/discorb/member.rbs +187 -0
- data/sig/discorb/message.rbs +469 -0
- data/sig/discorb/messageable.rbs +153 -0
- data/sig/discorb/partial_emoji.rbs +35 -0
- data/sig/discorb/permissions.rbs +149 -0
- data/sig/discorb/presence.rbs +237 -0
- data/sig/discorb/reaction.rbs +33 -0
- data/sig/discorb/role.rbs +145 -0
- data/sig/discorb/scheduled_event.rbs +148 -0
- data/sig/discorb/shard.rbs +62 -0
- data/sig/discorb/snowflake.rbs +56 -0
- data/sig/discorb/stage_instance.rbs +63 -0
- data/sig/discorb/sticker.rbs +116 -0
- data/sig/discorb/system_channel_flag.rbs +17 -0
- data/sig/discorb/unicode_emoji.rbs +49 -0
- data/sig/discorb/user.rbs +93 -0
- data/sig/discorb/utils.rbs +8 -0
- data/sig/discorb/voice_region.rbs +30 -0
- data/sig/discorb/voice_state.rbs +71 -0
- data/sig/discorb/webhook.rbs +327 -0
- data/sig/discorb/welcome_screen.rbs +78 -0
- data/sig/discorb.rbs +5 -8661
- data/sig/manifest.yaml +3 -0
- data/sig/override.rbs +19 -0
- metadata +80 -3
@@ -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,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
|