discorb 0.13.1 → 0.14.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.
- checksums.yaml +4 -4
- data/.gitattributes +2 -0
- data/.github/workflows/build_version.yml +3 -3
- data/.github/workflows/codeql-analysis.yml +70 -0
- data/.github/workflows/lint-push.yml +18 -0
- data/.github/workflows/lint.yml +16 -0
- data/.rubocop.yml +70 -0
- data/CODE_OF_CONDUCT.md +128 -0
- data/Changelog.md +33 -0
- data/Gemfile +7 -3
- data/README.md +1 -1
- data/Rakefile +35 -35
- data/discorb.gemspec +13 -1
- data/examples/commands/bookmarker.rb +2 -1
- data/examples/commands/hello.rb +1 -0
- data/examples/commands/inspect.rb +3 -2
- data/examples/components/authorization_button.rb +2 -1
- data/examples/components/select_menu.rb +2 -1
- data/examples/extension/main.rb +1 -0
- data/examples/extension/message_expander.rb +1 -0
- data/examples/simple/eval.rb +3 -2
- data/examples/simple/ping_pong.rb +1 -0
- data/examples/simple/rolepanel.rb +1 -0
- data/examples/simple/wait_for_message.rb +4 -3
- data/exe/discorb +8 -7
- data/lib/discorb/allowed_mentions.rb +64 -0
- data/lib/discorb/app_command/command.rb +274 -0
- data/lib/discorb/app_command/handler.rb +168 -0
- data/lib/discorb/app_command.rb +2 -404
- data/lib/discorb/asset.rb +3 -1
- data/lib/discorb/audit_logs.rb +3 -3
- data/lib/discorb/channel.rb +89 -53
- data/lib/discorb/client.rb +36 -33
- data/lib/discorb/common.rb +28 -21
- data/lib/discorb/components/button.rb +106 -0
- data/lib/discorb/components/select_menu.rb +157 -0
- data/lib/discorb/components/text_input.rb +96 -0
- data/lib/discorb/components.rb +11 -276
- data/lib/discorb/dictionary.rb +13 -2
- data/lib/discorb/embed.rb +2 -2
- data/lib/discorb/emoji.rb +21 -5
- data/lib/discorb/emoji_table.rb +1 -1
- data/lib/discorb/error.rb +4 -6
- data/lib/discorb/event.rb +13 -11
- data/lib/discorb/exe/about.rb +1 -0
- data/lib/discorb/exe/irb.rb +4 -3
- data/lib/discorb/exe/new.rb +6 -7
- data/lib/discorb/exe/run.rb +2 -1
- data/lib/discorb/exe/setup.rb +8 -5
- data/lib/discorb/exe/show.rb +1 -0
- data/lib/discorb/extend.rb +19 -14
- data/lib/discorb/extension.rb +5 -1
- data/lib/discorb/gateway.rb +75 -27
- data/lib/discorb/guild.rb +58 -80
- data/lib/discorb/guild_template.rb +5 -5
- data/lib/discorb/http.rb +34 -169
- data/lib/discorb/integration.rb +32 -3
- data/lib/discorb/intents.rb +1 -1
- data/lib/discorb/interaction/autocomplete.rb +5 -4
- data/lib/discorb/interaction/command.rb +34 -9
- data/lib/discorb/interaction/components.rb +5 -2
- data/lib/discorb/interaction/modal.rb +33 -0
- data/lib/discorb/interaction/response.rb +41 -12
- data/lib/discorb/interaction/root.rb +1 -0
- data/lib/discorb/interaction.rb +2 -1
- data/lib/discorb/invite.rb +1 -1
- data/lib/discorb/log.rb +4 -3
- data/lib/discorb/member.rb +4 -6
- data/lib/discorb/message.rb +31 -282
- data/lib/discorb/message_meta.rb +205 -0
- data/lib/discorb/modules.rb +11 -11
- data/lib/discorb/permission.rb +2 -2
- data/lib/discorb/presence.rb +6 -3
- data/lib/discorb/rate_limit.rb +15 -21
- data/lib/discorb/role.rb +3 -3
- data/lib/discorb/sticker.rb +2 -2
- data/lib/discorb/user.rb +3 -3
- data/lib/discorb/utils/colored_puts.rb +1 -0
- data/lib/discorb/voice_state.rb +7 -2
- data/lib/discorb/webhook.rb +8 -5
- data/lib/discorb.rb +1 -0
- data/template-replace/scripts/arrow.rb +1 -0
- data/template-replace/scripts/favicon.rb +1 -0
- data/template-replace/scripts/index.rb +2 -1
- data/template-replace/scripts/locale_ja.rb +5 -4
- data/template-replace/scripts/sidebar.rb +1 -0
- data/template-replace/scripts/version.rb +7 -10
- data/template-replace/scripts/yard_replace.rb +5 -4
- metadata +29 -4
data/lib/discorb/modules.rb
CHANGED
@@ -38,7 +38,7 @@ module Discorb
|
|
38
38
|
payload[:message_reference] = reference.to_reference if reference
|
39
39
|
payload[:components] = Component.to_payload(components) if components
|
40
40
|
files = [file]
|
41
|
-
_resp, data = @client.http.
|
41
|
+
_resp, data = @client.http.multipart_request(Route.new("/channels/#{channel_id.wait}/messages", "//channels/:channel_id/messages", :post), payload, files).wait
|
42
42
|
Message.new(@client, data.merge({ guild_id: @guild_id.to_s }))
|
43
43
|
end
|
44
44
|
end
|
@@ -74,7 +74,7 @@ module Discorb
|
|
74
74
|
allowed_mentions ? allowed_mentions.to_hash(@client.allowed_mentions) : @client.allowed_mentions.to_hash
|
75
75
|
payload[:components] = Component.to_payload(components) if components
|
76
76
|
payload[:flags] = (supress ? 1 << 2 : 0) unless supress.nil?
|
77
|
-
@client.http.
|
77
|
+
@client.http.request(Route.new("/channels/#{channel_id.wait}/messages/#{message_id}", "//channels/:channel_id/messages/:message_id", :patch), payload).wait
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -89,7 +89,7 @@ module Discorb
|
|
89
89
|
#
|
90
90
|
def delete_message!(message_id, reason: nil)
|
91
91
|
Async do
|
92
|
-
@client.http.
|
92
|
+
@client.http.request(Route.new("/channels/#{channel_id.wait}/messages/#{message_id}", "//channels/:channel_id/messages/:message_id", :delete), audit_log_reason: reason).wait
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -106,7 +106,7 @@ module Discorb
|
|
106
106
|
#
|
107
107
|
def fetch_message(id)
|
108
108
|
Async do
|
109
|
-
_resp, data = @client.http.
|
109
|
+
_resp, data = @client.http.request(Route.new("/channels/#{channel_id.wait}/messages/#{id}", "//channels/:channel_id/messages/:message_id", :get)).wait
|
110
110
|
Message.new(@client, data.merge({ guild_id: @guild_id.to_s }))
|
111
111
|
end
|
112
112
|
end
|
@@ -130,7 +130,7 @@ module Discorb
|
|
130
130
|
after: Discorb::Utils.try(around, :id),
|
131
131
|
around: Discorb::Utils.try(before, :id),
|
132
132
|
}.filter { |_k, v| !v.nil? }.to_h
|
133
|
-
_resp, messages = @client.http.
|
133
|
+
_resp, messages = @client.http.request(Route.new("/channels/#{channel_id.wait}/messages?#{URI.encode_www_form(params)}", "//channels/:channel_id/messages", :get)).wait
|
134
134
|
messages.map { |m| Message.new(@client, m.merge({ guild_id: @guild_id.to_s })) }
|
135
135
|
end
|
136
136
|
end
|
@@ -143,7 +143,7 @@ module Discorb
|
|
143
143
|
#
|
144
144
|
def fetch_pins
|
145
145
|
Async do
|
146
|
-
_resp, data = @client.http.
|
146
|
+
_resp, data = @client.http.request(Route.new("/channels/#{channel_id.wait}/pins", "//channels/:channel_id/pins", :get)).wait
|
147
147
|
data.map { |pin| Message.new(@client, pin) }
|
148
148
|
end
|
149
149
|
end
|
@@ -159,7 +159,7 @@ module Discorb
|
|
159
159
|
#
|
160
160
|
def pin_message(message, reason: nil)
|
161
161
|
Async do
|
162
|
-
@client.http.
|
162
|
+
@client.http.request(Route.new("/channels/#{channel_id.wait}/pins/#{message.id}", "//channels/:channel_id/pins/:message_id", :put), {}, audit_log_reason: reason).wait
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
@@ -174,7 +174,7 @@ module Discorb
|
|
174
174
|
#
|
175
175
|
def unpin_message(message, reason: nil)
|
176
176
|
Async do
|
177
|
-
@client.http.
|
177
|
+
@client.http.request(Route.new("/channels/#{channel_id.wait}/pins/#{message.id}", "//channels/:channel_id/pins/:message_id", :delete), audit_log_reason: reason).wait
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
@@ -195,7 +195,7 @@ module Discorb
|
|
195
195
|
begin
|
196
196
|
post_task = Async do
|
197
197
|
loop do
|
198
|
-
@client.http.
|
198
|
+
@client.http.request(Route.new("/channels/#{@id}/typing", "//channels/:channel_id/typing", :post), {})
|
199
199
|
sleep(5)
|
200
200
|
end
|
201
201
|
end
|
@@ -204,8 +204,8 @@ module Discorb
|
|
204
204
|
post_task.stop
|
205
205
|
end
|
206
206
|
else
|
207
|
-
Async do |
|
208
|
-
@client.http.
|
207
|
+
Async do |_task|
|
208
|
+
@client.http.request(Route.new("/channels/#{@id}/typing", "//channels/:channel_id/typing", :post), {})
|
209
209
|
end
|
210
210
|
end
|
211
211
|
end
|
data/lib/discorb/permission.rb
CHANGED
@@ -174,13 +174,13 @@ module Discorb
|
|
174
174
|
# @return [Hash] The permission overwrite as a hash.
|
175
175
|
#
|
176
176
|
def to_hash
|
177
|
-
self.class.bits.keys.
|
177
|
+
self.class.bits.keys.to_h do |field|
|
178
178
|
[field, if @allow & self.class.bits[field] != 0
|
179
179
|
true
|
180
180
|
elsif @deny & self.class.bits[method] != 0
|
181
181
|
false
|
182
182
|
end]
|
183
|
-
end
|
183
|
+
end
|
184
184
|
end
|
185
185
|
|
186
186
|
#
|
data/lib/discorb/presence.rb
CHANGED
@@ -105,7 +105,7 @@ module Discorb
|
|
105
105
|
@party = data[:party] && Party.new(data[:party])
|
106
106
|
@assets = data[:assets] && Asset.new(data[:assets])
|
107
107
|
@instance = data[:instance]
|
108
|
-
@buttons = data[:buttons]
|
108
|
+
@buttons = data[:buttons]&.map { |b| Button.new(b) }
|
109
109
|
@flags = data[:flags] && Flag.new(data[:flags])
|
110
110
|
end
|
111
111
|
|
@@ -147,6 +147,9 @@ module Discorb
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
+
#
|
151
|
+
# Represents the party of an activity.
|
152
|
+
#
|
150
153
|
class Party < DiscordModel
|
151
154
|
# @return [String] The id of the party.
|
152
155
|
attr_reader :id
|
@@ -175,12 +178,12 @@ module Discorb
|
|
175
178
|
# Represents the assets of an activity.
|
176
179
|
#
|
177
180
|
class Asset < DiscordModel
|
178
|
-
# @return [String] The large image ID of the asset.
|
181
|
+
# @return [String] The large image ID or URL of the asset.
|
179
182
|
attr_reader :large_image
|
180
183
|
alias large_id large_image
|
181
184
|
# @return [String] The large text of the activity.
|
182
185
|
attr_reader :large_text
|
183
|
-
# @return [String] The small image ID of the activity.
|
186
|
+
# @return [String] The small image ID or URL of the activity.
|
184
187
|
attr_reader :small_image
|
185
188
|
alias small_id small_image
|
186
189
|
# @return [String] The small text of the activity.
|
data/lib/discorb/rate_limit.rb
CHANGED
@@ -9,8 +9,8 @@ module Discorb
|
|
9
9
|
# @private
|
10
10
|
def initialize(client)
|
11
11
|
@client = client
|
12
|
-
@current_ratelimits = {}
|
13
12
|
@path_ratelimit_bucket = {}
|
13
|
+
@path_ratelimit_hash = {}
|
14
14
|
@global = false
|
15
15
|
end
|
16
16
|
|
@@ -21,12 +21,10 @@ module Discorb
|
|
21
21
|
#
|
22
22
|
# Wait for the rate limit to reset.
|
23
23
|
#
|
24
|
-
# @param [
|
25
|
-
# @param [String] path The path.
|
24
|
+
# @param [Discorb::Route] path The path.
|
26
25
|
#
|
27
|
-
def wait(
|
28
|
-
return if path.start_with?("https://")
|
29
|
-
|
26
|
+
def wait(path)
|
27
|
+
# return if path.url.start_with?("https://")
|
30
28
|
if @global && @global > Time.now.to_f
|
31
29
|
time = @global - Time.now.to_f
|
32
30
|
@client.log.info("global rate limit reached, waiting #{time} seconds")
|
@@ -34,36 +32,32 @@ module Discorb
|
|
34
32
|
@global = false
|
35
33
|
end
|
36
34
|
|
37
|
-
return unless hash = @
|
35
|
+
return unless hash = @path_ratelimit_hash[path.identifier]
|
38
36
|
|
39
|
-
return unless
|
37
|
+
return unless bucket = @path_ratelimit_bucket[hash + path.major_param]
|
40
38
|
|
41
|
-
if
|
42
|
-
@
|
39
|
+
if bucket[:reset_at] < Time.now.to_f
|
40
|
+
@path_ratelimit_bucket.delete(path.identifier + path.major_param)
|
43
41
|
return
|
44
42
|
end
|
45
|
-
return if
|
43
|
+
return if (bucket[:remaining]).positive?
|
46
44
|
|
47
|
-
time =
|
48
|
-
@client.log.info("rate limit for #{
|
45
|
+
time = bucket[:reset_at] - Time.now.to_f
|
46
|
+
@client.log.info("rate limit for #{path.identifier} with #{path.major_param} reached, waiting #{time.round(4)} seconds")
|
49
47
|
sleep(time)
|
50
48
|
end
|
51
49
|
|
52
50
|
#
|
53
51
|
# Save the rate limit.
|
54
52
|
#
|
55
|
-
# @param [String] method The HTTP method.
|
56
53
|
# @param [String] path The path.
|
57
54
|
# @param [Net::HTTPResponse] resp The response.
|
58
55
|
#
|
59
|
-
def save(
|
60
|
-
if resp["X-Ratelimit-Global"] == "true"
|
61
|
-
@global = Time.now.to_f + JSON.parse(resp.body, symbolize_names: true)[:retry_after]
|
62
|
-
end
|
56
|
+
def save(path, resp)
|
57
|
+
@global = Time.now.to_f + JSON.parse(resp.body, symbolize_names: true)[:retry_after] if resp["X-Ratelimit-Global"] == "true"
|
63
58
|
return unless resp["X-RateLimit-Remaining"]
|
64
|
-
|
65
|
-
@path_ratelimit_bucket[
|
66
|
-
@current_ratelimits[resp["X-RateLimit-Bucket"]] = {
|
59
|
+
@path_ratelimit_hash[path.identifier] = resp["X-Ratelimit-Bucket"]
|
60
|
+
@path_ratelimit_bucket[resp["X-Ratelimit-Bucket"] + path.major_param] = {
|
67
61
|
remaining: resp["X-RateLimit-Remaining"].to_i,
|
68
62
|
reset_at: Time.now.to_f + resp["X-RateLimit-Reset-After"].to_f,
|
69
63
|
}
|
data/lib/discorb/role.rb
CHANGED
@@ -99,7 +99,7 @@ module Discorb
|
|
99
99
|
#
|
100
100
|
def move(position, reason: nil)
|
101
101
|
Async do
|
102
|
-
@client.http.
|
102
|
+
@client.http.request(Route.new("/guilds/#{@guild.id}/roles", "//guilds/:guild_id/roles", :patch), { id: @id, position: position }, audit_log_reason: reason).wait
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -133,7 +133,7 @@ module Discorb
|
|
133
133
|
payload[:unicode_emoji] = icon.to_s
|
134
134
|
end
|
135
135
|
end
|
136
|
-
@client.http.
|
136
|
+
@client.http.request(Route.new("/guilds/#{@guild.id}/roles/#{@id}", "//guilds/:guild_id/roles/:role_id", :patch), payload, audit_log_reason: reason).wait
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -148,7 +148,7 @@ module Discorb
|
|
148
148
|
#
|
149
149
|
def delete!(reason: nil)
|
150
150
|
Async do
|
151
|
-
@client.http.
|
151
|
+
@client.http.request(Route.new("/guilds/#{@guild.id}/roles/#{@id}", "//guilds/:guild_id/roles/:role_id", :delete), audit_log_reason: reason).wait
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
data/lib/discorb/sticker.rb
CHANGED
@@ -83,7 +83,7 @@ module Discorb
|
|
83
83
|
payload[:name] = name unless name == Discorb::Unset
|
84
84
|
payload[:description] = description unless description == Discorb::Unset
|
85
85
|
payload[:tags] = tag.name unless tag == Discorb::Unset
|
86
|
-
@client.http.
|
86
|
+
@client.http.request(Route.new("/guilds/#{@guild_id}/stickers/#{@id}", "//guilds/:guild_id/stickers/:sticker_id", :patch), payload, audit_log_reason: reason).wait
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -97,7 +97,7 @@ module Discorb
|
|
97
97
|
#
|
98
98
|
def delete!(reason: nil)
|
99
99
|
Async do
|
100
|
-
@client.http.
|
100
|
+
@client.http.request(Route.new("/guilds/#{@guild_id}/stickers/#{@id}", "//guilds/:guild_id/stickers/:sticker_id", :delete), audit_log_reason: reason).wait
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
data/lib/discorb/user.rb
CHANGED
@@ -84,7 +84,7 @@ module Discorb
|
|
84
84
|
Async do
|
85
85
|
next @dm_channel_id if @dm_channel_id
|
86
86
|
|
87
|
-
_resp, dm_channel = @client.http.
|
87
|
+
_resp, dm_channel = @client.http.request(Route.new("/users/@me/channels", "//users/@me/channels", :post), { recipient_id: @id }).wait
|
88
88
|
@dm_channel_id = dm_channel[:id]
|
89
89
|
@dm_channel_id
|
90
90
|
end
|
@@ -137,7 +137,7 @@ module Discorb
|
|
137
137
|
@avatar = data[:avatar] ? Asset.new(self, data[:avatar]) : DefaultAvatar.new(data[:discriminator])
|
138
138
|
@bot = data[:bot]
|
139
139
|
@raw_data = data
|
140
|
-
@client.users[@id] = self
|
140
|
+
@client.users[@id] = self unless data[:no_cache]
|
141
141
|
@created_at = @id.timestamp
|
142
142
|
@data.update(data)
|
143
143
|
end
|
@@ -168,7 +168,7 @@ module Discorb
|
|
168
168
|
else
|
169
169
|
payload[:avatar] = avatar.to_s
|
170
170
|
end
|
171
|
-
@client.http.
|
171
|
+
@client.http.request(Route.new("/users/@me", "//users/@me", :patch), payload).wait
|
172
172
|
self
|
173
173
|
end
|
174
174
|
end
|
data/lib/discorb/voice_state.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Discorb
|
4
|
+
#
|
5
|
+
# Represents a state of user in voice channel.
|
6
|
+
#
|
4
7
|
class VoiceState < DiscordModel
|
5
8
|
# @return [Discorb::Member] The member associated with this voice state.
|
6
9
|
attr_reader :member
|
@@ -180,7 +183,9 @@ module Discorb
|
|
180
183
|
payload = {}
|
181
184
|
payload[:topic] = topic if topic != Discorb::Unset
|
182
185
|
payload[:privacy_level] = self.class.privacy_level.key(privacy_level) if privacy_level != Discorb::Unset
|
183
|
-
@client.http.
|
186
|
+
@client.http.request(
|
187
|
+
Route.new("/stage-instances/#{@channel_id}", "//stage-instances/:channel_id", :patch), payload, audit_log_reason: reason,
|
188
|
+
).wait
|
184
189
|
self
|
185
190
|
end
|
186
191
|
end
|
@@ -196,7 +201,7 @@ module Discorb
|
|
196
201
|
#
|
197
202
|
def delete!(reason: nil)
|
198
203
|
Async do
|
199
|
-
@client.http.
|
204
|
+
@client.http.request(Route.new("/stage-instances/#{@channel_id}", "//stage-instances/:stage_instance_id", :delete), audit_log_reason: reason).wait
|
200
205
|
self
|
201
206
|
end
|
202
207
|
end
|
data/lib/discorb/webhook.rb
CHANGED
@@ -75,7 +75,7 @@ module Discorb
|
|
75
75
|
payload[:username] = username if username
|
76
76
|
payload[:avatar_url] = avatar_url if avatar_url != Discorb::Unset
|
77
77
|
files = [file]
|
78
|
-
_resp, data = @http.
|
78
|
+
_resp, data = @http.multipart_request(Route.new("#{url}?wait=#{wait}", "//webhooks/:webhook_id/:token", :post), files, payload, headers: headers).wait
|
79
79
|
data && Webhook::Message.new(self, data)
|
80
80
|
end
|
81
81
|
end
|
@@ -99,7 +99,7 @@ module Discorb
|
|
99
99
|
payload[:name] = name if name != Discorb::Unset
|
100
100
|
payload[:avatar] = avatar if avatar != Discorb::Unset
|
101
101
|
payload[:channel_id] = Utils.try(channel, :id) if channel != Discorb::Unset
|
102
|
-
@http.
|
102
|
+
@http.request(Route.new(url, "//webhooks/:webhook_id/:token", :patch), payload).wait
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -113,7 +113,7 @@ module Discorb
|
|
113
113
|
#
|
114
114
|
def delete!
|
115
115
|
Async do
|
116
|
-
@http.
|
116
|
+
@http.request(Route.new(url, "//webhooks/:webhook_id/:token", :delete)).wait
|
117
117
|
self
|
118
118
|
end
|
119
119
|
end
|
@@ -151,7 +151,7 @@ module Discorb
|
|
151
151
|
payload[:attachments] = attachments.map(&:to_hash) if attachments != Discorb::Unset
|
152
152
|
payload[:allowed_mentions] = allowed_mentions if allowed_mentions != Discorb::Unset
|
153
153
|
files = [file] if file != Discorb::Unset
|
154
|
-
_resp, data = @http.
|
154
|
+
_resp, data = @http.multipart_request(Route.new("#{url}/messages/#{Utils.try(message, :id)}", "//webhooks/:webhook_id/:token/messages/:message_id", :patch), payload, files).wait
|
155
155
|
message.send(:_set_data, data)
|
156
156
|
message
|
157
157
|
end
|
@@ -166,7 +166,10 @@ module Discorb
|
|
166
166
|
#
|
167
167
|
def delete_message!(message)
|
168
168
|
Async do
|
169
|
-
@http.
|
169
|
+
@http.request(Route.new(
|
170
|
+
"#{url}/messages/#{Utils.try(message, :id)}",
|
171
|
+
"//webhooks/:webhook_id/:token/messages/:message_id", :delete
|
172
|
+
)).wait
|
170
173
|
message
|
171
174
|
end
|
172
175
|
end
|
data/lib/discorb.rb
CHANGED
@@ -40,6 +40,7 @@ module Discorb
|
|
40
40
|
end
|
41
41
|
|
42
42
|
require_order = %w[common flag dictionary error rate_limit http intents emoji_table modules] +
|
43
|
+
%w[message_meta allowed_mentions] +
|
43
44
|
%w[user member guild emoji channel embed message] +
|
44
45
|
%w[application audit_logs color components event event_handler] +
|
45
46
|
%w[file guild_template image integration interaction invite log permission] +
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "fileutils"
|
2
3
|
|
3
4
|
def replace_index(dir, version)
|
@@ -5,7 +6,7 @@ def replace_index(dir, version)
|
|
5
6
|
next if (m = file.match(/[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?/)) && m[0] != version
|
6
7
|
|
7
8
|
content = File.read(file)
|
8
|
-
content.gsub!(
|
9
|
+
content.gsub!(%r{(?<=["/])_index.html}, "a_index.html")
|
9
10
|
File.write(file, content)
|
10
11
|
end
|
11
12
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
LOCALES = {
|
2
3
|
"ja" => {
|
3
4
|
selector: {
|
@@ -14,15 +15,15 @@ LOCALES = {
|
|
14
15
|
},
|
15
16
|
},
|
16
17
|
|
17
|
-
}
|
18
|
+
}.freeze
|
18
19
|
|
19
20
|
def replace_sidebar_name(dir)
|
20
|
-
regex =
|
21
|
+
regex = %r{<a target="_self" href="(.+)_list\.html">\s*([a-zA-Z ]+?)\s*</a>}
|
21
22
|
|
22
23
|
Dir.glob("#{dir}/*_list.html") do |file|
|
23
24
|
content = File.read(file)
|
24
25
|
new_content = content.dup
|
25
|
-
content.scan(regex) do |
|
26
|
+
content.scan(regex) do |_url, name|
|
26
27
|
new_content.gsub!(
|
27
28
|
Regexp.last_match[0],
|
28
29
|
Regexp.last_match[0].gsub(name, LOCALES[ENV["rake_locale"]][:selector][name])
|
@@ -33,7 +34,7 @@ def replace_sidebar_name(dir)
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def replace_title(dir)
|
36
|
-
regex =
|
37
|
+
regex = %r{(?:<h1 id="full_list_header">|<title>)([a-zA-Z ]+?)(?:</title>|</h1>)}
|
37
38
|
|
38
39
|
Dir.glob("#{dir}/*.html") do |file|
|
39
40
|
content = File.read(file)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
def build_version_sidebar(dir, version)
|
2
3
|
raw = File.read("template-replace/resources/version_list.html")
|
3
4
|
template = raw.match(/<!--template-->(.*)<!--endtemplate-->/m)[1]
|
@@ -9,14 +10,12 @@ def build_version_sidebar(dir, version)
|
|
9
10
|
.split("\n")
|
10
11
|
.sort_by { |v| Gem::Version.new(v[1..]) }
|
11
12
|
.reverse
|
12
|
-
.each
|
13
|
+
.each do |tag|
|
13
14
|
i += 1
|
14
15
|
sha = `git rev-parse #{tag}`.force_encoding("utf-8").strip
|
15
16
|
tag_version = tag.delete_prefix("v")
|
16
|
-
cls = i
|
17
|
-
if tag_version == version
|
18
|
-
cls += " current"
|
19
|
-
end
|
17
|
+
cls = i.even? ? "even" : "odd"
|
18
|
+
cls += " current" if tag_version == version
|
20
19
|
res += template
|
21
20
|
.gsub("!version!", tag_version)
|
22
21
|
.gsub("!path!", "/" + tag_version)
|
@@ -24,17 +23,15 @@ def build_version_sidebar(dir, version)
|
|
24
23
|
.gsub("!sha!", sha)
|
25
24
|
end
|
26
25
|
i += 1
|
27
|
-
cls = i
|
28
|
-
if version == "main"
|
29
|
-
cls += " current"
|
30
|
-
end
|
26
|
+
cls = i.even? ? "even" : "odd"
|
27
|
+
cls += " current" if version == "main"
|
31
28
|
res.insert 0, template
|
32
29
|
.gsub("!version!", "main")
|
33
30
|
.gsub("!path!", "/main")
|
34
31
|
.gsub("!class!", cls)
|
35
32
|
.gsub("!sha!", "Latest on GitHub")
|
36
33
|
i += 1
|
37
|
-
cls = i
|
34
|
+
cls = i.even? ? "even" : "odd"
|
38
35
|
res.insert 0, template
|
39
36
|
.gsub("!version!", "Latest")
|
40
37
|
.gsub("!path!", "")
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "yard"
|
2
3
|
|
3
4
|
def yard_replace(dir, version)
|
@@ -22,11 +23,11 @@ def yard_replace(dir, version)
|
|
22
23
|
<h1 class="noborder title">Documentation by YARD 0.9.26</h1>
|
23
24
|
HTML3
|
24
25
|
HTML4
|
25
|
-
if version == "main"
|
26
|
-
|
26
|
+
display_version = if version == "main"
|
27
|
+
"(main)"
|
27
28
|
else
|
28
|
-
|
29
|
-
|
29
|
+
"v" + version
|
30
|
+
end
|
30
31
|
contents.gsub!(/Documentation by YARD \d+\.\d+\.\d+/, "discorb #{display_version} documentation")
|
31
32
|
File.write(file, contents)
|
32
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discorb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sevenc-nanashi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -66,7 +66,16 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.3'
|
69
|
-
description:
|
69
|
+
description: |+
|
70
|
+
== discorb
|
71
|
+
discorb is a Discord API wrapper for Ruby, Using {socketry/async}[https://github.com/socketry/async].
|
72
|
+
|
73
|
+
=== Contributing
|
74
|
+
Bug reports, feature requests, and pull requests are welcome on {the GitHub repository}[https://github.com/discorb-lib/discorb].
|
75
|
+
|
76
|
+
=== License
|
77
|
+
This gem is licensed under the MIT License.
|
78
|
+
|
70
79
|
email:
|
71
80
|
- sevenc-nanashi@sevenbot.jp
|
72
81
|
executables:
|
@@ -74,16 +83,22 @@ executables:
|
|
74
83
|
extensions: []
|
75
84
|
extra_rdoc_files: []
|
76
85
|
files:
|
86
|
+
- ".gitattributes"
|
77
87
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
78
88
|
- ".github/ISSUE_TEMPLATE/config.yml"
|
79
89
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
80
90
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
81
91
|
- ".github/workflows/build_main.yml"
|
82
92
|
- ".github/workflows/build_version.yml"
|
93
|
+
- ".github/workflows/codeql-analysis.yml"
|
83
94
|
- ".github/workflows/crowdin.yml"
|
95
|
+
- ".github/workflows/lint-push.yml"
|
96
|
+
- ".github/workflows/lint.yml"
|
84
97
|
- ".github/workflows/package_register.yml"
|
85
98
|
- ".gitignore"
|
99
|
+
- ".rubocop.yml"
|
86
100
|
- ".yardopts"
|
101
|
+
- CODE_OF_CONDUCT.md
|
87
102
|
- CONTRIBUTING.md
|
88
103
|
- Changelog.md
|
89
104
|
- Gemfile
|
@@ -130,7 +145,10 @@ files:
|
|
130
145
|
- examples/simple/wait_for_message.rb
|
131
146
|
- exe/discorb
|
132
147
|
- lib/discorb.rb
|
148
|
+
- lib/discorb/allowed_mentions.rb
|
133
149
|
- lib/discorb/app_command.rb
|
150
|
+
- lib/discorb/app_command/command.rb
|
151
|
+
- lib/discorb/app_command/handler.rb
|
134
152
|
- lib/discorb/application.rb
|
135
153
|
- lib/discorb/asset.rb
|
136
154
|
- lib/discorb/audit_logs.rb
|
@@ -139,6 +157,9 @@ files:
|
|
139
157
|
- lib/discorb/color.rb
|
140
158
|
- lib/discorb/common.rb
|
141
159
|
- lib/discorb/components.rb
|
160
|
+
- lib/discorb/components/button.rb
|
161
|
+
- lib/discorb/components/select_menu.rb
|
162
|
+
- lib/discorb/components/text_input.rb
|
142
163
|
- lib/discorb/dictionary.rb
|
143
164
|
- lib/discorb/embed.rb
|
144
165
|
- lib/discorb/emoji.rb
|
@@ -168,12 +189,14 @@ files:
|
|
168
189
|
- lib/discorb/interaction/autocomplete.rb
|
169
190
|
- lib/discorb/interaction/command.rb
|
170
191
|
- lib/discorb/interaction/components.rb
|
192
|
+
- lib/discorb/interaction/modal.rb
|
171
193
|
- lib/discorb/interaction/response.rb
|
172
194
|
- lib/discorb/interaction/root.rb
|
173
195
|
- lib/discorb/invite.rb
|
174
196
|
- lib/discorb/log.rb
|
175
197
|
- lib/discorb/member.rb
|
176
198
|
- lib/discorb/message.rb
|
199
|
+
- lib/discorb/message_meta.rb
|
177
200
|
- lib/discorb/modules.rb
|
178
201
|
- lib/discorb/permission.rb
|
179
202
|
- lib/discorb/presence.rb
|
@@ -206,6 +229,7 @@ metadata:
|
|
206
229
|
source_code_uri: https://github.com/discorb-lib/discorb
|
207
230
|
changelog_uri: https://discorb-lib.github.io/file.Changelog.html
|
208
231
|
documentation_uri: https://discorb-lib.github.io
|
232
|
+
rubygems_mfa_required: 'true'
|
209
233
|
post_install_message:
|
210
234
|
rdoc_options: []
|
211
235
|
require_paths:
|
@@ -224,5 +248,6 @@ requirements: []
|
|
224
248
|
rubygems_version: 3.2.32
|
225
249
|
signing_key:
|
226
250
|
specification_version: 4
|
227
|
-
summary: A
|
251
|
+
summary: A Discord API wrapper for Ruby, Using socketry/async.
|
228
252
|
test_files: []
|
253
|
+
...
|