discorb 0.18.0 → 0.20.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/build_version.yml +2 -2
- data/.rubocop.yml +12 -75
- data/Changelog.md +25 -0
- data/Gemfile +4 -4
- data/README.md +2 -1
- data/Rakefile +482 -459
- data/Steepfile +8 -6
- data/docs/application_command.md +1 -0
- data/docs/events.md +2 -2
- data/docs/voice_events.md +6 -6
- data/lib/discorb/allowed_mentions.rb +68 -72
- data/lib/discorb/app_command/command.rb +466 -394
- data/lib/discorb/app_command/common.rb +65 -25
- data/lib/discorb/app_command/handler.rb +304 -265
- data/lib/discorb/app_command.rb +5 -5
- data/lib/discorb/application.rb +198 -197
- data/lib/discorb/asset.rb +101 -101
- data/lib/discorb/attachment.rb +134 -119
- data/lib/discorb/audit_logs.rb +412 -385
- data/lib/discorb/automod.rb +279 -269
- data/lib/discorb/channel/base.rb +107 -108
- data/lib/discorb/channel/category.rb +32 -32
- data/lib/discorb/channel/container.rb +44 -44
- data/lib/discorb/channel/dm.rb +26 -28
- data/lib/discorb/channel/guild.rb +311 -246
- data/lib/discorb/channel/stage.rb +156 -140
- data/lib/discorb/channel/text.rb +430 -336
- data/lib/discorb/channel/thread.rb +374 -325
- data/lib/discorb/channel/voice.rb +85 -79
- data/lib/discorb/channel.rb +5 -5
- data/lib/discorb/client.rb +635 -623
- data/lib/discorb/color.rb +178 -182
- data/lib/discorb/common.rb +168 -164
- data/lib/discorb/components/button.rb +107 -106
- data/lib/discorb/components/select_menu.rb +157 -145
- data/lib/discorb/components/text_input.rb +103 -106
- data/lib/discorb/components.rb +68 -66
- data/lib/discorb/dictionary.rb +135 -135
- data/lib/discorb/embed.rb +404 -398
- data/lib/discorb/emoji.rb +309 -302
- data/lib/discorb/emoji_table.rb +16099 -8857
- data/lib/discorb/error.rb +131 -131
- data/lib/discorb/event.rb +360 -314
- data/lib/discorb/event_handler.rb +39 -39
- data/lib/discorb/exe/about.rb +17 -17
- data/lib/discorb/exe/irb.rb +72 -67
- data/lib/discorb/exe/new.rb +323 -315
- data/lib/discorb/exe/run.rb +69 -68
- data/lib/discorb/exe/setup.rb +57 -55
- data/lib/discorb/exe/show.rb +12 -12
- data/lib/discorb/extend.rb +25 -45
- data/lib/discorb/extension.rb +89 -83
- data/lib/discorb/flag.rb +126 -128
- data/lib/discorb/gateway.rb +984 -794
- data/lib/discorb/gateway_events.rb +670 -638
- data/lib/discorb/gateway_requests.rb +45 -48
- data/lib/discorb/guild.rb +2115 -1626
- data/lib/discorb/guild_template.rb +280 -241
- data/lib/discorb/http.rb +247 -232
- data/lib/discorb/image.rb +42 -42
- data/lib/discorb/integration.rb +169 -161
- data/lib/discorb/intents.rb +161 -163
- data/lib/discorb/interaction/autocomplete.rb +76 -62
- data/lib/discorb/interaction/command.rb +279 -224
- data/lib/discorb/interaction/components.rb +114 -104
- data/lib/discorb/interaction/modal.rb +36 -32
- data/lib/discorb/interaction/response.rb +379 -330
- data/lib/discorb/interaction/root.rb +271 -118
- data/lib/discorb/interaction.rb +5 -5
- data/lib/discorb/invite.rb +154 -153
- data/lib/discorb/member.rb +344 -311
- data/lib/discorb/message.rb +615 -544
- data/lib/discorb/message_meta.rb +197 -186
- data/lib/discorb/modules.rb +371 -290
- data/lib/discorb/permission.rb +305 -289
- data/lib/discorb/presence.rb +352 -346
- data/lib/discorb/rate_limit.rb +81 -76
- data/lib/discorb/reaction.rb +55 -54
- data/lib/discorb/role.rb +272 -240
- data/lib/discorb/shard.rb +76 -74
- data/lib/discorb/sticker.rb +193 -171
- data/lib/discorb/user.rb +205 -188
- data/lib/discorb/utils/colored_puts.rb +16 -16
- data/lib/discorb/utils.rb +12 -16
- data/lib/discorb/voice_state.rb +305 -281
- data/lib/discorb/webhook.rb +537 -507
- data/lib/discorb.rb +62 -56
- data/sig/discorb/activity.rbs +1 -0
- data/sig/discorb/allowed_mentions.rbs +1 -0
- data/sig/discorb/app_command/base.rbs +7 -1
- data/sig/discorb/application.rbs +6 -0
- data/sig/discorb/asset.rbs +2 -0
- data/sig/discorb/attachment.rbs +8 -0
- data/sig/discorb/audit_log.rbs +7 -0
- data/sig/discorb/automod.rbs +32 -6
- data/sig/discorb/avatar.rbs +1 -0
- data/sig/discorb/channel/base.rbs +8 -1
- data/sig/discorb/channel/category.rbs +1 -0
- data/sig/discorb/channel/container.rbs +4 -0
- data/sig/discorb/channel/stage.rbs +4 -0
- data/sig/discorb/channel/text.rbs +2 -2
- data/sig/discorb/channel/thread.rbs +11 -0
- data/sig/discorb/channel/voice.rbs +2 -0
- data/sig/discorb/client.rbs +21 -20
- data/sig/discorb/color.rbs +6 -0
- data/sig/discorb/component/base.rbs +1 -0
- data/sig/discorb/component/button.rbs +2 -0
- data/sig/discorb/component/select_menu.rbs +4 -0
- data/sig/discorb/component/text_input.rbs +1 -0
- data/sig/discorb/custom_emoji.rbs +5 -1
- data/sig/discorb/dictionary.rbs +2 -0
- data/sig/discorb/discord_model.rbs +2 -0
- data/sig/discorb/embed.rbs +7 -0
- data/sig/discorb/emoji.rbs +1 -0
- data/sig/discorb/event_handler.rbs +2 -1
- data/sig/discorb/extension.rbs +13 -12
- data/sig/discorb/flag.rbs +2 -0
- data/sig/discorb/gateway.rbs +5 -0
- data/sig/discorb/guild.rbs +8 -4
- data/sig/discorb/guild_template.rbs +1 -1
- data/sig/discorb/http.rbs +4 -1
- data/sig/discorb/image.rbs +2 -0
- data/sig/discorb/integration.rbs +1 -1
- data/sig/discorb/intents.rbs +4 -3
- data/sig/discorb/interaction/base.rbs +36 -0
- data/sig/discorb/interaction/message_component.rbs +1 -2
- data/sig/discorb/interaction/modal.rbs +1 -2
- data/sig/discorb/interaction/responder.rbs +49 -49
- data/sig/discorb/invite.rbs +1 -1
- data/sig/discorb/member.rbs +2 -0
- data/sig/discorb/message.rbs +8 -1
- data/sig/discorb/messageable.rbs +1 -4
- data/sig/discorb/partial_emoji.rbs +3 -0
- data/sig/discorb/permissions.rbs +7 -0
- data/sig/discorb/presence.rbs +2 -0
- data/sig/discorb/reaction.rbs +5 -1
- data/sig/discorb/role.rbs +7 -1
- data/sig/discorb/scheduled_event.rbs +2 -1
- data/sig/discorb/shard.rbs +2 -1
- data/sig/discorb/snowflake.rbs +2 -0
- data/sig/discorb/stage_instance.rbs +9 -3
- data/sig/discorb/sticker.rbs +1 -1
- data/sig/discorb/unicode_emoji.rbs +4 -0
- data/sig/discorb/user.rbs +24 -20
- data/sig/discorb/webhook.rbs +17 -6
- data/sig/discorb/welcome_screen.rbs +1 -0
- data/sig/override.rbs +2 -0
- metadata +3 -3
data/lib/discorb/common.rb
CHANGED
@@ -1,164 +1,168 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Discorb
|
4
|
-
# @return [String] The API base URL.
|
5
|
-
API_BASE_URL = "https://discord.com/api/v10"
|
6
|
-
# @return [String] The version of discorb.
|
7
|
-
VERSION = "0.
|
8
|
-
# @return [Array<Integer>] The version array of discorb.
|
9
|
-
VERSION_ARRAY = VERSION.split(".").map(&:to_i).freeze
|
10
|
-
# @return [String] The user agent for the bot.
|
11
|
-
USER_AGENT =
|
12
|
-
|
13
|
-
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
|
45
|
-
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
|
79
|
-
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
#
|
94
|
-
#
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
@
|
137
|
-
@
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Discorb
|
4
|
+
# @return [String] The API base URL.
|
5
|
+
API_BASE_URL = "https://discord.com/api/v10"
|
6
|
+
# @return [String] The version of discorb.
|
7
|
+
VERSION = "0.20.0"
|
8
|
+
# @return [Array<Integer>] The version array of discorb.
|
9
|
+
VERSION_ARRAY = VERSION.split(".").map(&:to_i).freeze
|
10
|
+
# @return [String] The user agent for the bot.
|
11
|
+
USER_AGENT =
|
12
|
+
"DiscordBot (https://discorb-lib.github.io #{VERSION}) Ruby/#{RUBY_VERSION}".freeze
|
13
|
+
|
14
|
+
#
|
15
|
+
# @abstract
|
16
|
+
# Represents Discord model.
|
17
|
+
#
|
18
|
+
class DiscordModel
|
19
|
+
def eql?(other)
|
20
|
+
self == other
|
21
|
+
end
|
22
|
+
|
23
|
+
def ==(other)
|
24
|
+
if respond_to?(:id) && other.respond_to?(:id)
|
25
|
+
id == other.id
|
26
|
+
else
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def inspect
|
32
|
+
"#<#{self.class}: #{@id}>"
|
33
|
+
end
|
34
|
+
|
35
|
+
# @private
|
36
|
+
def hash
|
37
|
+
@id.hash
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Represents Snowflake of Discord.
|
43
|
+
#
|
44
|
+
# @see https://discord.com/developers/docs/reference#snowflakes Official Discord API docs
|
45
|
+
class Snowflake < String
|
46
|
+
#
|
47
|
+
# Initialize new snowflake.
|
48
|
+
# @private
|
49
|
+
#
|
50
|
+
# @param [#to_s] value The value of the snowflake.
|
51
|
+
#
|
52
|
+
def initialize(value)
|
53
|
+
@value = value.to_i
|
54
|
+
super(@value.to_s)
|
55
|
+
end
|
56
|
+
|
57
|
+
# @!attribute [r] timestamp
|
58
|
+
# Timestamp of snowflake.
|
59
|
+
#
|
60
|
+
# @return [Time] Timestamp of snowflake.
|
61
|
+
#
|
62
|
+
# @!attribute [r] worker_id
|
63
|
+
# Worker ID of snowflake.
|
64
|
+
#
|
65
|
+
# @return [Integer] Worker ID of snowflake.
|
66
|
+
#
|
67
|
+
# @!attribute [r] process_id
|
68
|
+
# Process ID of snowflake.
|
69
|
+
#
|
70
|
+
# @return [Integer] Process ID of snowflake.
|
71
|
+
# @!attribute [r] increment
|
72
|
+
# Increment of snowflake.
|
73
|
+
#
|
74
|
+
# @return [Integer] Increment of snowflake.
|
75
|
+
# @!attribute [r] id
|
76
|
+
# Alias of to_s.
|
77
|
+
#
|
78
|
+
# @return [String] The snowflake.
|
79
|
+
|
80
|
+
#
|
81
|
+
# Compares snowflake with other object.
|
82
|
+
#
|
83
|
+
# @param [#to_s] other Object to compare with.
|
84
|
+
#
|
85
|
+
# @return [Boolean] True if snowflake is equal to other object.
|
86
|
+
#
|
87
|
+
def ==(other)
|
88
|
+
return false unless other.respond_to?(:to_s)
|
89
|
+
|
90
|
+
to_s == other.to_s
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# Alias of {#==}.
|
95
|
+
#
|
96
|
+
def eql?(other)
|
97
|
+
self == other
|
98
|
+
end
|
99
|
+
|
100
|
+
# Return hash of snowflake.
|
101
|
+
def hash
|
102
|
+
to_s.hash
|
103
|
+
end
|
104
|
+
|
105
|
+
def timestamp
|
106
|
+
Time.at(((@value >> 22) + 1_420_070_400_000) / 1000.0)
|
107
|
+
end
|
108
|
+
|
109
|
+
def worker_id
|
110
|
+
(@value & 0x3E0000) >> 17
|
111
|
+
end
|
112
|
+
|
113
|
+
def process_id
|
114
|
+
(@value & 0x1F000) >> 12
|
115
|
+
end
|
116
|
+
|
117
|
+
def increment
|
118
|
+
@value & 0xFFF
|
119
|
+
end
|
120
|
+
|
121
|
+
def inspect
|
122
|
+
"#<#{self.class} #{self}>"
|
123
|
+
end
|
124
|
+
|
125
|
+
alias id to_s
|
126
|
+
end
|
127
|
+
|
128
|
+
#
|
129
|
+
# Represents an endpoint.
|
130
|
+
# @private
|
131
|
+
#
|
132
|
+
class Route
|
133
|
+
attr_reader :url, :key, :method
|
134
|
+
|
135
|
+
def initialize(url, key, method)
|
136
|
+
@url = url
|
137
|
+
@key = key
|
138
|
+
@method = method
|
139
|
+
end
|
140
|
+
|
141
|
+
def inspect
|
142
|
+
"#<#{self.class} #{identifier}>"
|
143
|
+
end
|
144
|
+
|
145
|
+
def hash
|
146
|
+
@url.hash
|
147
|
+
end
|
148
|
+
|
149
|
+
def identifier
|
150
|
+
"#{@method} #{@key}"
|
151
|
+
end
|
152
|
+
|
153
|
+
def major_param
|
154
|
+
param_type = @key.split("/").find { |k| k.start_with?(":") }
|
155
|
+
return "" unless param_type
|
156
|
+
|
157
|
+
param =
|
158
|
+
url.gsub(API_BASE_URL, "").split("/")[
|
159
|
+
@key.split("/").index(param_type) - 1
|
160
|
+
]
|
161
|
+
%w[:channel_id :guild_id :webhook_id].include?(param_type) ? param : ""
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# @return [Object] Object that represents unspecified value.
|
166
|
+
# This is used as a default value for optional parameters.
|
167
|
+
Unset = Object.new
|
168
|
+
end
|
@@ -1,106 +1,107 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Discorb
|
4
|
-
#
|
5
|
-
# Represents a button component.
|
6
|
-
#
|
7
|
-
class Button < Component
|
8
|
-
# @return [String] The label of the button.
|
9
|
-
attr_accessor :label
|
10
|
-
# @return [:primary, :secondary, :success, :danger, :link] The style of the button.
|
11
|
-
attr_accessor :style
|
12
|
-
# @return [Discorb::Emoji] The emoji of the button.
|
13
|
-
attr_accessor :emoji
|
14
|
-
# @return [String] The custom ID of the button.
|
15
|
-
# Won't be used if the style is `:link`.
|
16
|
-
attr_accessor :custom_id
|
17
|
-
# @return [String] The URL of the button.
|
18
|
-
# Only used when the style is `:link`.
|
19
|
-
attr_accessor :url
|
20
|
-
# @return [Boolean] Whether the button is disabled.
|
21
|
-
attr_accessor :disabled
|
22
|
-
alias disabled? disabled
|
23
|
-
|
24
|
-
# @private
|
25
|
-
# @return [{Symbol => Integer}] The mapping of button styles.
|
26
|
-
STYLES = {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@
|
49
|
-
@
|
50
|
-
@
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
data[:
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Discorb
|
4
|
+
#
|
5
|
+
# Represents a button component.
|
6
|
+
#
|
7
|
+
class Button < Component
|
8
|
+
# @return [String] The label of the button.
|
9
|
+
attr_accessor :label
|
10
|
+
# @return [:primary, :secondary, :success, :danger, :link] The style of the button.
|
11
|
+
attr_accessor :style
|
12
|
+
# @return [Discorb::Emoji] The emoji of the button.
|
13
|
+
attr_accessor :emoji
|
14
|
+
# @return [String] The custom ID of the button.
|
15
|
+
# Won't be used if the style is `:link`.
|
16
|
+
attr_accessor :custom_id
|
17
|
+
# @return [String] The URL of the button.
|
18
|
+
# Only used when the style is `:link`.
|
19
|
+
attr_accessor :url
|
20
|
+
# @return [Boolean] Whether the button is disabled.
|
21
|
+
attr_accessor :disabled
|
22
|
+
alias disabled? disabled
|
23
|
+
|
24
|
+
# @private
|
25
|
+
# @return [{Symbol => Integer}] The mapping of button styles.
|
26
|
+
STYLES = { primary: 1, secondary: 2, success: 3, danger: 4, link: 5 }.freeze
|
27
|
+
|
28
|
+
#
|
29
|
+
# Initialize a new button.
|
30
|
+
#
|
31
|
+
# @param [String] label The label of the button.
|
32
|
+
# @param [:primary, :secondary, :success, :danger, :link] style The style of the button.
|
33
|
+
# @param [Discorb::Emoji] emoji The emoji of the button.
|
34
|
+
# @param [String] custom_id The custom ID of the button.
|
35
|
+
# @param [String] url The URL of the button.
|
36
|
+
# @param [Boolean] disabled Whether the button is disabled.
|
37
|
+
#
|
38
|
+
def initialize(
|
39
|
+
label,
|
40
|
+
style = :primary,
|
41
|
+
emoji: nil,
|
42
|
+
custom_id: nil,
|
43
|
+
url: nil,
|
44
|
+
disabled: false
|
45
|
+
)
|
46
|
+
@label = label
|
47
|
+
@style = style
|
48
|
+
@emoji = emoji
|
49
|
+
@custom_id = custom_id
|
50
|
+
@url = url
|
51
|
+
@disabled = disabled
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Converts the button to a hash.
|
56
|
+
#
|
57
|
+
# @see https://discord.com/developers/docs/interactions/message-components#button-object-button-structure
|
58
|
+
# Official Discord API docs
|
59
|
+
# @return [Hash] A hash representation of the button.
|
60
|
+
#
|
61
|
+
def to_hash
|
62
|
+
if @style == :link
|
63
|
+
{
|
64
|
+
type: 2,
|
65
|
+
label: @label,
|
66
|
+
style: STYLES[@style],
|
67
|
+
url: @url,
|
68
|
+
emoji: @emoji&.to_hash,
|
69
|
+
disabled: @disabled
|
70
|
+
}
|
71
|
+
else
|
72
|
+
{
|
73
|
+
type: 2,
|
74
|
+
label: @label,
|
75
|
+
style: STYLES[@style],
|
76
|
+
custom_id: @custom_id,
|
77
|
+
emoji: @emoji&.to_hash,
|
78
|
+
disabled: @disabled
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def inspect
|
84
|
+
"#<#{self.class}: #{@custom_id || @url}>"
|
85
|
+
end
|
86
|
+
|
87
|
+
class << self
|
88
|
+
#
|
89
|
+
# Creates a new button from a hash.
|
90
|
+
#
|
91
|
+
# @param [Hash] data The hash to create the button from.
|
92
|
+
#
|
93
|
+
# @return [Discorb::Button] The created button.
|
94
|
+
#
|
95
|
+
def from_hash(data)
|
96
|
+
new(
|
97
|
+
data[:label],
|
98
|
+
data[:style],
|
99
|
+
emoji: data[:emoji],
|
100
|
+
custom_id: data[:custom_id],
|
101
|
+
url: data[:url],
|
102
|
+
disabled: data[:disabled]
|
103
|
+
)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|