discorb 0.19.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 +10 -0
- data/Rakefile +482 -454
- data/lib/discorb/allowed_mentions.rb +68 -72
- data/lib/discorb/app_command/command.rb +466 -398
- data/lib/discorb/app_command/common.rb +65 -25
- data/lib/discorb/app_command/handler.rb +304 -266
- 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 -621
- 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 -804
- 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 -336
- data/lib/discorb/interaction/root.rb +271 -257
- 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 -291
- 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/application.rbs +2 -0
- data/sig/discorb/automod.rbs +10 -1
- data/sig/discorb/guild.rbs +2 -0
- data/sig/discorb/message.rbs +2 -0
- data/sig/discorb/user.rbs +22 -20
- metadata +2 -2
data/lib/discorb/color.rb
CHANGED
@@ -1,182 +1,178 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Discorb
|
4
|
-
#
|
5
|
-
# Represents RGB color.
|
6
|
-
#
|
7
|
-
class Color
|
8
|
-
attr_accessor :value
|
9
|
-
|
10
|
-
@discord_colors = {
|
11
|
-
teal: 0x1abc9c,
|
12
|
-
dark_teal: 0x11806a,
|
13
|
-
green: 0x2ecc71,
|
14
|
-
dark_green: 0x1f8b4c,
|
15
|
-
blue: 0x3498db,
|
16
|
-
dark_blue: 0x206694,
|
17
|
-
purple: 0x9b59b6,
|
18
|
-
dark_purple: 0x71368a,
|
19
|
-
magenta: 0xe91e63,
|
20
|
-
dark_magenta: 0xad1457,
|
21
|
-
gold: 0xf1c40f,
|
22
|
-
dark_gold: 0xc27c0e,
|
23
|
-
orange: 0xe67e22,
|
24
|
-
dark_orange: 0xa84300,
|
25
|
-
red: 0xe74c3c,
|
26
|
-
dark_red: 0x992d22,
|
27
|
-
lighter_grey: 0x95a5a6,
|
28
|
-
lighter_gray: 0x95a5a6,
|
29
|
-
dark_grey: 0x607d8b,
|
30
|
-
dark_gray: 0x607d8b,
|
31
|
-
light_grey: 0x979c9f,
|
32
|
-
light_gray: 0x979c9f,
|
33
|
-
darker_grey: 0x546e7a,
|
34
|
-
darker_gray: 0x546e7a,
|
35
|
-
og_blurple: 0x7289da,
|
36
|
-
blurple: 0x5865f2,
|
37
|
-
greyple: 0x99aab5,
|
38
|
-
dark_theme: 0x36393f,
|
39
|
-
fuchsia: 0xeb459e,
|
40
|
-
yellow: 0xfee75c
|
41
|
-
}.freeze
|
42
|
-
|
43
|
-
#
|
44
|
-
# Create a color from a Integer.
|
45
|
-
#
|
46
|
-
# @param [Integer] value A color value.
|
47
|
-
#
|
48
|
-
def initialize(value)
|
49
|
-
@value = value
|
50
|
-
end
|
51
|
-
|
52
|
-
#
|
53
|
-
# Integerize a color.
|
54
|
-
#
|
55
|
-
# @return [Integer] A color value.
|
56
|
-
#
|
57
|
-
def to_i
|
58
|
-
@value
|
59
|
-
end
|
60
|
-
|
61
|
-
#
|
62
|
-
# Convert a color to a hexadecimal value.
|
63
|
-
#
|
64
|
-
# @return [String] A hexadecimal value.
|
65
|
-
#
|
66
|
-
def to_hex
|
67
|
-
@value.to_s(16).rjust(6, "0")
|
68
|
-
end
|
69
|
-
|
70
|
-
#
|
71
|
-
# Convert a color to RGB array.
|
72
|
-
#
|
73
|
-
# @return [Array(Integer, Integer, Integer)] A RGB array.
|
74
|
-
#
|
75
|
-
def to_rgb
|
76
|
-
[@value / (256 * 256), @value / 256 % 256, @value % 256]
|
77
|
-
end
|
78
|
-
|
79
|
-
alias to_a to_rgb
|
80
|
-
alias deconstruct to_rgb
|
81
|
-
|
82
|
-
#
|
83
|
-
# Convert a color to RGB hash.
|
84
|
-
#
|
85
|
-
# @return [Hash{:r, :g, :b => Integer}] A RGB hash.
|
86
|
-
#
|
87
|
-
def to_rgb_hash
|
88
|
-
{
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
#
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
def
|
103
|
-
"
|
104
|
-
end
|
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
|
-
# | `:
|
165
|
-
# | `:
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
# @return [Class] The alias of `Discorb::Color`.
|
181
|
-
Colour = Color
|
182
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Discorb
|
4
|
+
#
|
5
|
+
# Represents RGB color.
|
6
|
+
#
|
7
|
+
class Color
|
8
|
+
attr_accessor :value
|
9
|
+
|
10
|
+
@discord_colors = {
|
11
|
+
teal: 0x1abc9c,
|
12
|
+
dark_teal: 0x11806a,
|
13
|
+
green: 0x2ecc71,
|
14
|
+
dark_green: 0x1f8b4c,
|
15
|
+
blue: 0x3498db,
|
16
|
+
dark_blue: 0x206694,
|
17
|
+
purple: 0x9b59b6,
|
18
|
+
dark_purple: 0x71368a,
|
19
|
+
magenta: 0xe91e63,
|
20
|
+
dark_magenta: 0xad1457,
|
21
|
+
gold: 0xf1c40f,
|
22
|
+
dark_gold: 0xc27c0e,
|
23
|
+
orange: 0xe67e22,
|
24
|
+
dark_orange: 0xa84300,
|
25
|
+
red: 0xe74c3c,
|
26
|
+
dark_red: 0x992d22,
|
27
|
+
lighter_grey: 0x95a5a6,
|
28
|
+
lighter_gray: 0x95a5a6,
|
29
|
+
dark_grey: 0x607d8b,
|
30
|
+
dark_gray: 0x607d8b,
|
31
|
+
light_grey: 0x979c9f,
|
32
|
+
light_gray: 0x979c9f,
|
33
|
+
darker_grey: 0x546e7a,
|
34
|
+
darker_gray: 0x546e7a,
|
35
|
+
og_blurple: 0x7289da,
|
36
|
+
blurple: 0x5865f2,
|
37
|
+
greyple: 0x99aab5,
|
38
|
+
dark_theme: 0x36393f,
|
39
|
+
fuchsia: 0xeb459e,
|
40
|
+
yellow: 0xfee75c
|
41
|
+
}.freeze
|
42
|
+
|
43
|
+
#
|
44
|
+
# Create a color from a Integer.
|
45
|
+
#
|
46
|
+
# @param [Integer] value A color value.
|
47
|
+
#
|
48
|
+
def initialize(value)
|
49
|
+
@value = value
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Integerize a color.
|
54
|
+
#
|
55
|
+
# @return [Integer] A color value.
|
56
|
+
#
|
57
|
+
def to_i
|
58
|
+
@value
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# Convert a color to a hexadecimal value.
|
63
|
+
#
|
64
|
+
# @return [String] A hexadecimal value.
|
65
|
+
#
|
66
|
+
def to_hex
|
67
|
+
@value.to_s(16).rjust(6, "0")
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# Convert a color to RGB array.
|
72
|
+
#
|
73
|
+
# @return [Array(Integer, Integer, Integer)] A RGB array.
|
74
|
+
#
|
75
|
+
def to_rgb
|
76
|
+
[@value / (256 * 256), @value / 256 % 256, @value % 256]
|
77
|
+
end
|
78
|
+
|
79
|
+
alias to_a to_rgb
|
80
|
+
alias deconstruct to_rgb
|
81
|
+
|
82
|
+
#
|
83
|
+
# Convert a color to RGB hash.
|
84
|
+
#
|
85
|
+
# @return [Hash{:r, :g, :b => Integer}] A RGB hash.
|
86
|
+
#
|
87
|
+
def to_rgb_hash
|
88
|
+
{ r: @value / (256 * 256), g: @value / 256 % 256, b: @value % 256 }
|
89
|
+
end
|
90
|
+
|
91
|
+
alias deconstruct_keys to_rgb_hash
|
92
|
+
|
93
|
+
#
|
94
|
+
# Converts a color to a `#000000` string.
|
95
|
+
#
|
96
|
+
# @return [String] Converted string.
|
97
|
+
#
|
98
|
+
def to_s
|
99
|
+
"##{to_hex}"
|
100
|
+
end
|
101
|
+
|
102
|
+
def inspect
|
103
|
+
"#<#{self.class} #{@value}/#{self}>"
|
104
|
+
end
|
105
|
+
|
106
|
+
#
|
107
|
+
# Create a color from a hexadecimal string.
|
108
|
+
#
|
109
|
+
# @param [String] hex A hexadecimal string.
|
110
|
+
#
|
111
|
+
# @return [Discorb::Color] A color object.
|
112
|
+
#
|
113
|
+
def self.from_hex(hex)
|
114
|
+
new(hex.to_i(16))
|
115
|
+
end
|
116
|
+
|
117
|
+
#
|
118
|
+
# Create a color from a RGB array.
|
119
|
+
#
|
120
|
+
# @param [Integer] red A red value.
|
121
|
+
# @param [Integer] green A green value.
|
122
|
+
# @param [Integer] blue A blue value.
|
123
|
+
#
|
124
|
+
# @return [Discorb::Color] A color object.
|
125
|
+
#
|
126
|
+
def self.from_rgb(red, green, blue)
|
127
|
+
new((red * 256 * 256) + (green * 256) + blue)
|
128
|
+
end
|
129
|
+
|
130
|
+
#
|
131
|
+
# Create a color from a Discord's color.
|
132
|
+
# Currently these colors are supported:
|
133
|
+
#
|
134
|
+
# | Color name | Color code |
|
135
|
+
# |-----------------|------------|
|
136
|
+
# | `:teal` | `#1abc9c` |
|
137
|
+
# | `:dark_teal` | `#11806a` |
|
138
|
+
# | `:green` | `#2ecc71` |
|
139
|
+
# | `:dark_green` | `#1f8b4c` |
|
140
|
+
# | `:blue` | `#3498db` |
|
141
|
+
# | `:dark_blue` | `#206694` |
|
142
|
+
# | `:purple` | `#9b59b6` |
|
143
|
+
# | `:dark_purple` | `#71368a` |
|
144
|
+
# | `:magenta` | `#e91e63` |
|
145
|
+
# | `:dark_magenta` | `#ad1457` |
|
146
|
+
# | `:gold` | `#f1c40f` |
|
147
|
+
# | `:dark_gold` | `#c27c0e` |
|
148
|
+
# | `:orange` | `#e67e22` |
|
149
|
+
# | `:dark_orange` | `#a84300` |
|
150
|
+
# | `:red` | `#e74c3c` |
|
151
|
+
# | `:dark_red` | `#992d22` |
|
152
|
+
# | `:lighter_grey` | `#95a5a6` |
|
153
|
+
# | `:lighter_gray` | `#95a5a6` |
|
154
|
+
# | `:dark_grey` | `#607d8b` |
|
155
|
+
# | `:dark_gray` | `#607d8b` |
|
156
|
+
# | `:light_grey` | `#979c9f` |
|
157
|
+
# | `:light_gray` | `#979c9f` |
|
158
|
+
# | `:darker_grey` | `#546e7a` |
|
159
|
+
# | `:darker_gray` | `#546e7a` |
|
160
|
+
# | `:og_blurple` | `#7289da` |
|
161
|
+
# | `:blurple` | `#5865f2` |
|
162
|
+
# | `:greyple` | `#99aab5` |
|
163
|
+
# | `:dark_theme` | `#36393f` |
|
164
|
+
# | `:fuchsia` | `#eb459e` |
|
165
|
+
# | `:yellow` | `#fee75c` |
|
166
|
+
#
|
167
|
+
# @param [Symbol] color A Discord color name.
|
168
|
+
#
|
169
|
+
# @return [Discorb::Color] A color object.
|
170
|
+
#
|
171
|
+
def self.[](color)
|
172
|
+
new(@discord_colors[color])
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# @return [Class] The alias of `Discorb::Color`.
|
177
|
+
Colour = Color
|
178
|
+
end
|