discorb 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,140 +1,156 @@
1
- # frozen_string_literal: true
2
-
3
- module Discorb
4
- #
5
- # Represents a stage channel.
6
- #
7
- class StageChannel < GuildChannel
8
- # @return [Integer] The bitrate of the voice channel.
9
- attr_reader :bitrate
10
- # @return [Integer] The user limit of the voice channel.
11
- attr_reader :user_limit
12
- #
13
- # @private
14
- # @return [Discorb::Dictionary{Discorb::Snowflake => StageInstance}]
15
- # The stage instances associated with the stage channel.
16
- #
17
- attr_reader :stage_instances
18
-
19
- include Connectable
20
-
21
- # @!attribute [r] stage_instance
22
- # @return [Discorb::StageInstance] The stage instance of the channel.
23
-
24
- @channel_type = 13
25
- #
26
- # Initialize a new stage channel.
27
- # @private
28
- #
29
- def initialize(...)
30
- @stage_instances = Dictionary.new
31
- super(...)
32
- end
33
-
34
- def stage_instance
35
- @stage_instances[0]
36
- end
37
-
38
- #
39
- # Edit the stage channel.
40
- # @async
41
- # @macro edit
42
- #
43
- # @param [String] name The name of the stage channel.
44
- # @param [Integer] position The position of the stage channel.
45
- # @param [Integer] bitrate The bitrate of the stage channel.
46
- # @param [Symbol] rtc_region The region of the stage channel.
47
- # @param [String] reason The reason of editing the stage channel.
48
- #
49
- # @return [Async::Task<self>] The edited stage channel.
50
- #
51
- def edit(
52
- name: Discorb::Unset,
53
- position: Discorb::Unset,
54
- bitrate: Discorb::Unset,
55
- rtc_region: Discorb::Unset,
56
- reason: nil
57
- )
58
- Async do
59
- payload = {}
60
- payload[:name] = name if name != Discorb::Unset
61
- payload[:position] = position if position != Discorb::Unset
62
- payload[:bitrate] = bitrate if bitrate != Discorb::Unset
63
- payload[:rtc_region] = rtc_region if rtc_region != Discorb::Unset
64
- @client.http.request(Route.new("/channels/#{@id}", "//channels/:channel_id", :patch), payload,
65
- audit_log_reason: reason).wait
66
- self
67
- end
68
- end
69
-
70
- alias modify edit
71
-
72
- #
73
- # Start a stage instance.
74
- # @async
75
- #
76
- # @param [String] topic The topic of the stage instance.
77
- # @param [Boolean] public Whether the stage instance is public or not.
78
- # @param [String] reason The reason of starting the stage instance.
79
- #
80
- # @return [Async::Task<Discorb::StageInstance>] The started stage instance.
81
- #
82
- def start(topic, public: false, reason: nil)
83
- Async do
84
- _resp, data = @client.http.request(
85
- Route.new("/stage-instances", "//stage-instances", :post),
86
- {
87
- channel_id: @id,
88
- topic: topic,
89
- public: public ? 2 : 1,
90
- }, audit_log_reason: reason,
91
- ).wait
92
- StageInstance.new(@client, data)
93
- end
94
- end
95
-
96
- #
97
- # Fetch a current stage instance.
98
- # @async
99
- #
100
- # @return [Async::Task<StageInstance>] The current stage instance.
101
- # @return [Async::Task<nil>] If there is no current stage instance.
102
- #
103
- def fetch_stage_instance
104
- Async do
105
- _resp, data = @client.http.request(Route.new("/stage-instances/#{@id}", "//stage-instances/:stage_instance_id",
106
- :get)).wait
107
- rescue Discorb::NotFoundError
108
- nil
109
- else
110
- StageInstance.new(@client, data)
111
- end
112
- end
113
-
114
- def voice_states
115
- guild.voice_states.select { |state| state.channel&.id == @id }
116
- end
117
-
118
- def members
119
- voice_states.map(&:member)
120
- end
121
-
122
- def speakers
123
- voice_states.reject(&:suppress?).map(&:member)
124
- end
125
-
126
- def audiences
127
- voice_states.filter(&:suppress?).map(&:member)
128
- end
129
-
130
- private
131
-
132
- def _set_data(data)
133
- @bitrate = data[:bitrate]
134
- @user_limit = data[:user_limit]
135
- @topic = data[:topic]
136
- @rtc_region = data[:rtc_region]&.to_sym
137
- super
138
- end
139
- end
140
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Discorb
4
+ #
5
+ # Represents a stage channel.
6
+ #
7
+ class StageChannel < GuildChannel
8
+ # @return [Integer] The bitrate of the voice channel.
9
+ attr_reader :bitrate
10
+ # @return [Integer] The user limit of the voice channel.
11
+ attr_reader :user_limit
12
+ #
13
+ # @private
14
+ # @return [Discorb::Dictionary{Discorb::Snowflake => StageInstance}]
15
+ # The stage instances associated with the stage channel.
16
+ #
17
+ attr_reader :stage_instances
18
+
19
+ include Connectable
20
+
21
+ # @!attribute [r] stage_instance
22
+ # @return [Discorb::StageInstance] The stage instance of the channel.
23
+
24
+ @channel_type = 13
25
+ #
26
+ # Initialize a new stage channel.
27
+ # @private
28
+ #
29
+ def initialize(...)
30
+ @stage_instances = Dictionary.new
31
+ super(...)
32
+ end
33
+
34
+ def stage_instance
35
+ @stage_instances[0]
36
+ end
37
+
38
+ #
39
+ # Edit the stage channel.
40
+ # @async
41
+ # @macro edit
42
+ #
43
+ # @param [String] name The name of the stage channel.
44
+ # @param [Integer] position The position of the stage channel.
45
+ # @param [Integer] bitrate The bitrate of the stage channel.
46
+ # @param [Symbol] rtc_region The region of the stage channel.
47
+ # @param [String] reason The reason of editing the stage channel.
48
+ #
49
+ # @return [Async::Task<self>] The edited stage channel.
50
+ #
51
+ def edit(
52
+ name: Discorb::Unset,
53
+ position: Discorb::Unset,
54
+ bitrate: Discorb::Unset,
55
+ rtc_region: Discorb::Unset,
56
+ reason: nil
57
+ )
58
+ Async do
59
+ payload = {}
60
+ payload[:name] = name if name != Discorb::Unset
61
+ payload[:position] = position if position != Discorb::Unset
62
+ payload[:bitrate] = bitrate if bitrate != Discorb::Unset
63
+ payload[:rtc_region] = rtc_region if rtc_region != Discorb::Unset
64
+ @client
65
+ .http
66
+ .request(
67
+ Route.new("/channels/#{@id}", "//channels/:channel_id", :patch),
68
+ payload,
69
+ audit_log_reason: reason
70
+ )
71
+ .wait
72
+ self
73
+ end
74
+ end
75
+
76
+ alias modify edit
77
+
78
+ #
79
+ # Start a stage instance.
80
+ # @async
81
+ #
82
+ # @param [String] topic The topic of the stage instance.
83
+ # @param [Boolean] public Whether the stage instance is public or not.
84
+ # @param [String] reason The reason of starting the stage instance.
85
+ #
86
+ # @return [Async::Task<Discorb::StageInstance>] The started stage instance.
87
+ #
88
+ def start(topic, public: false, reason: nil)
89
+ Async do
90
+ _resp, data =
91
+ @client
92
+ .http
93
+ .request(
94
+ Route.new("/stage-instances", "//stage-instances", :post),
95
+ { channel_id: @id, topic: topic, public: public ? 2 : 1 },
96
+ audit_log_reason: reason
97
+ )
98
+ .wait
99
+ StageInstance.new(@client, data)
100
+ end
101
+ end
102
+
103
+ #
104
+ # Fetch a current stage instance.
105
+ # @async
106
+ #
107
+ # @return [Async::Task<StageInstance>] The current stage instance.
108
+ # @return [Async::Task<nil>] If there is no current stage instance.
109
+ #
110
+ def fetch_stage_instance
111
+ Async do
112
+ _resp, data =
113
+ @client
114
+ .http
115
+ .request(
116
+ Route.new(
117
+ "/stage-instances/#{@id}",
118
+ "//stage-instances/:stage_instance_id",
119
+ :get
120
+ )
121
+ )
122
+ .wait
123
+ rescue Discorb::NotFoundError
124
+ nil
125
+ else
126
+ StageInstance.new(@client, data)
127
+ end
128
+ end
129
+
130
+ def voice_states
131
+ guild.voice_states.select { |state| state.channel&.id == @id }
132
+ end
133
+
134
+ def members
135
+ voice_states.map(&:member)
136
+ end
137
+
138
+ def speakers
139
+ voice_states.reject(&:suppress?).map(&:member)
140
+ end
141
+
142
+ def audiences
143
+ voice_states.filter(&:suppress?).map(&:member)
144
+ end
145
+
146
+ private
147
+
148
+ def _set_data(data)
149
+ @bitrate = data[:bitrate]
150
+ @user_limit = data[:user_limit]
151
+ @topic = data[:topic]
152
+ @rtc_region = data[:rtc_region]&.to_sym
153
+ super
154
+ end
155
+ end
156
+ end