discorb 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build_version.yml +2 -2
  3. data/.rubocop.yml +12 -75
  4. data/Changelog.md +10 -0
  5. data/Rakefile +482 -454
  6. data/lib/discorb/allowed_mentions.rb +68 -72
  7. data/lib/discorb/app_command/command.rb +466 -398
  8. data/lib/discorb/app_command/common.rb +65 -25
  9. data/lib/discorb/app_command/handler.rb +304 -266
  10. data/lib/discorb/app_command.rb +5 -5
  11. data/lib/discorb/application.rb +198 -197
  12. data/lib/discorb/asset.rb +101 -101
  13. data/lib/discorb/attachment.rb +134 -119
  14. data/lib/discorb/audit_logs.rb +412 -385
  15. data/lib/discorb/automod.rb +279 -269
  16. data/lib/discorb/channel/base.rb +107 -108
  17. data/lib/discorb/channel/category.rb +32 -32
  18. data/lib/discorb/channel/container.rb +44 -44
  19. data/lib/discorb/channel/dm.rb +26 -28
  20. data/lib/discorb/channel/guild.rb +311 -246
  21. data/lib/discorb/channel/stage.rb +156 -140
  22. data/lib/discorb/channel/text.rb +430 -336
  23. data/lib/discorb/channel/thread.rb +374 -325
  24. data/lib/discorb/channel/voice.rb +85 -79
  25. data/lib/discorb/channel.rb +5 -5
  26. data/lib/discorb/client.rb +635 -621
  27. data/lib/discorb/color.rb +178 -182
  28. data/lib/discorb/common.rb +168 -164
  29. data/lib/discorb/components/button.rb +107 -106
  30. data/lib/discorb/components/select_menu.rb +157 -145
  31. data/lib/discorb/components/text_input.rb +103 -106
  32. data/lib/discorb/components.rb +68 -66
  33. data/lib/discorb/dictionary.rb +135 -135
  34. data/lib/discorb/embed.rb +404 -398
  35. data/lib/discorb/emoji.rb +309 -302
  36. data/lib/discorb/emoji_table.rb +16099 -8857
  37. data/lib/discorb/error.rb +131 -131
  38. data/lib/discorb/event.rb +360 -314
  39. data/lib/discorb/event_handler.rb +39 -39
  40. data/lib/discorb/exe/about.rb +17 -17
  41. data/lib/discorb/exe/irb.rb +72 -67
  42. data/lib/discorb/exe/new.rb +323 -315
  43. data/lib/discorb/exe/run.rb +69 -68
  44. data/lib/discorb/exe/setup.rb +57 -55
  45. data/lib/discorb/exe/show.rb +12 -12
  46. data/lib/discorb/extend.rb +25 -45
  47. data/lib/discorb/extension.rb +89 -83
  48. data/lib/discorb/flag.rb +126 -128
  49. data/lib/discorb/gateway.rb +984 -804
  50. data/lib/discorb/gateway_events.rb +670 -638
  51. data/lib/discorb/gateway_requests.rb +45 -48
  52. data/lib/discorb/guild.rb +2115 -1626
  53. data/lib/discorb/guild_template.rb +280 -241
  54. data/lib/discorb/http.rb +247 -232
  55. data/lib/discorb/image.rb +42 -42
  56. data/lib/discorb/integration.rb +169 -161
  57. data/lib/discorb/intents.rb +161 -163
  58. data/lib/discorb/interaction/autocomplete.rb +76 -62
  59. data/lib/discorb/interaction/command.rb +279 -224
  60. data/lib/discorb/interaction/components.rb +114 -104
  61. data/lib/discorb/interaction/modal.rb +36 -32
  62. data/lib/discorb/interaction/response.rb +379 -336
  63. data/lib/discorb/interaction/root.rb +271 -257
  64. data/lib/discorb/interaction.rb +5 -5
  65. data/lib/discorb/invite.rb +154 -153
  66. data/lib/discorb/member.rb +344 -311
  67. data/lib/discorb/message.rb +615 -544
  68. data/lib/discorb/message_meta.rb +197 -186
  69. data/lib/discorb/modules.rb +371 -290
  70. data/lib/discorb/permission.rb +305 -291
  71. data/lib/discorb/presence.rb +352 -346
  72. data/lib/discorb/rate_limit.rb +81 -76
  73. data/lib/discorb/reaction.rb +55 -54
  74. data/lib/discorb/role.rb +272 -240
  75. data/lib/discorb/shard.rb +76 -74
  76. data/lib/discorb/sticker.rb +193 -171
  77. data/lib/discorb/user.rb +205 -188
  78. data/lib/discorb/utils/colored_puts.rb +16 -16
  79. data/lib/discorb/utils.rb +12 -16
  80. data/lib/discorb/voice_state.rb +305 -281
  81. data/lib/discorb/webhook.rb +537 -507
  82. data/lib/discorb.rb +62 -56
  83. data/sig/discorb/application.rbs +2 -0
  84. data/sig/discorb/automod.rbs +10 -1
  85. data/sig/discorb/guild.rbs +2 -0
  86. data/sig/discorb/message.rbs +2 -0
  87. data/sig/discorb/user.rbs +22 -20
  88. 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
- r: @value / (256 * 256),
90
- g: @value / 256 % 256,
91
- b: @value % 256,
92
- }
93
- end
94
-
95
- alias deconstruct_keys to_rgb_hash
96
-
97
- #
98
- # Converts a color to a `#000000` string.
99
- #
100
- # @return [String] Converted string.
101
- #
102
- def to_s
103
- "##{to_hex}"
104
- end
105
-
106
- def inspect
107
- "#<#{self.class} #{@value}/#{self}>"
108
- end
109
-
110
- #
111
- # Create a color from a hexadecimal string.
112
- #
113
- # @param [String] hex A hexadecimal string.
114
- #
115
- # @return [Discorb::Color] A color object.
116
- #
117
- def self.from_hex(hex)
118
- new(hex.to_i(16))
119
- end
120
-
121
- #
122
- # Create a color from a RGB array.
123
- #
124
- # @param [Integer] red A red value.
125
- # @param [Integer] green A green value.
126
- # @param [Integer] blue A blue value.
127
- #
128
- # @return [Discorb::Color] A color object.
129
- #
130
- def self.from_rgb(red, green, blue)
131
- new(red * 256 * 256 + green * 256 + blue)
132
- end
133
-
134
- #
135
- # Create a color from a Discord's color.
136
- # Currently these colors are supported:
137
- #
138
- # | Color name | Color code |
139
- # |-----------------|------------|
140
- # | `:teal` | `#1abc9c` |
141
- # | `:dark_teal` | `#11806a` |
142
- # | `:green` | `#2ecc71` |
143
- # | `:dark_green` | `#1f8b4c` |
144
- # | `:blue` | `#3498db` |
145
- # | `:dark_blue` | `#206694` |
146
- # | `:purple` | `#9b59b6` |
147
- # | `:dark_purple` | `#71368a` |
148
- # | `:magenta` | `#e91e63` |
149
- # | `:dark_magenta` | `#ad1457` |
150
- # | `:gold` | `#f1c40f` |
151
- # | `:dark_gold` | `#c27c0e` |
152
- # | `:orange` | `#e67e22` |
153
- # | `:dark_orange` | `#a84300` |
154
- # | `:red` | `#e74c3c` |
155
- # | `:dark_red` | `#992d22` |
156
- # | `:lighter_grey` | `#95a5a6` |
157
- # | `:lighter_gray` | `#95a5a6` |
158
- # | `:dark_grey` | `#607d8b` |
159
- # | `:dark_gray` | `#607d8b` |
160
- # | `:light_grey` | `#979c9f` |
161
- # | `:light_gray` | `#979c9f` |
162
- # | `:darker_grey` | `#546e7a` |
163
- # | `:darker_gray` | `#546e7a` |
164
- # | `:og_blurple` | `#7289da` |
165
- # | `:blurple` | `#5865f2` |
166
- # | `:greyple` | `#99aab5` |
167
- # | `:dark_theme` | `#36393f` |
168
- # | `:fuchsia` | `#eb459e` |
169
- # | `:yellow` | `#fee75c` |
170
- #
171
- # @param [Symbol] color A Discord color name.
172
- #
173
- # @return [Discorb::Color] A color object.
174
- #
175
- def self.[](color)
176
- new(@discord_colors[color])
177
- end
178
- end
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