discorb 0.12.0 → 0.12.4
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/.github/PULL_REQUEST_TEMPLATE.md +30 -0
- data/CONTRIBUTING.md +25 -0
- data/Changelog.md +21 -0
- data/discorb.gemspec +1 -1
- data/docs/application_command.md +1 -0
- data/docs/cli/run.md +2 -1
- data/lib/discorb/app_command.rb +5 -0
- data/lib/discorb/client.rb +2 -2
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/emoji_table.rb +3891 -3806
- data/lib/discorb/exe/run.rb +16 -1
- data/lib/discorb/http.rb +11 -4
- data/lib/discorb/integration.rb +1 -1
- data/lib/discorb/interaction/autocomplete.rb +1 -1
- data/lib/discorb/interaction/command.rb +2 -2
- data/lib/discorb/message.rb +25 -23
- data/lib/discorb/user.rb +7 -0
- data/template-replace/scripts/yard_replace.rb +6 -0
- metadata +5 -3
data/lib/discorb/exe/run.rb
CHANGED
@@ -42,7 +42,22 @@ opt.parse!(ARGV)
|
|
42
42
|
|
43
43
|
script = ARGV[0]
|
44
44
|
|
45
|
-
script
|
45
|
+
if script.nil?
|
46
|
+
script = "main.rb"
|
47
|
+
dir = Dir.pwd
|
48
|
+
loop do
|
49
|
+
if File.exist?(File.join(dir, "main.rb"))
|
50
|
+
script = File.join(dir, "main.rb")
|
51
|
+
break
|
52
|
+
end
|
53
|
+
break if dir == File.dirname(dir)
|
54
|
+
dir = File.dirname(dir)
|
55
|
+
end
|
56
|
+
if File.dirname(script) != Dir.pwd
|
57
|
+
Dir.chdir(File.dirname(script))
|
58
|
+
iputs "Changed directory to \e[m#{File.dirname(script)}"
|
59
|
+
end
|
60
|
+
end
|
46
61
|
|
47
62
|
ENV["DISCORB_CLI_FLAG"] = "run"
|
48
63
|
ENV["DISCORB_CLI_OPTIONS"] = JSON.generate(options)
|
data/lib/discorb/http.rb
CHANGED
@@ -144,7 +144,7 @@ module Discorb
|
|
144
144
|
end
|
145
145
|
|
146
146
|
#
|
147
|
-
# A helper method to send multipart/form-data requests.
|
147
|
+
# A helper method to send multipart/form-data requests for creating messages.
|
148
148
|
#
|
149
149
|
# @param [Hash] payload The payload to send.
|
150
150
|
# @param [Array<Discorb::File>] files The files to send.
|
@@ -159,15 +159,22 @@ module Discorb
|
|
159
159
|
|
160
160
|
#{payload.to_json}
|
161
161
|
HTTP
|
162
|
-
files.
|
162
|
+
files.each_with_index do |single_file, i|
|
163
163
|
str_payloads << <<~HTTP
|
164
|
-
Content-Disposition: form-data; name="
|
164
|
+
Content-Disposition: form-data; name="files[#{i}]"; filename="#{single_file.filename}"
|
165
165
|
Content-Type: #{single_file.content_type}
|
166
166
|
|
167
167
|
#{single_file.io.read}
|
168
168
|
HTTP
|
169
169
|
end
|
170
|
-
|
170
|
+
payload = +"--#{boundary}".encode(Encoding::ASCII_8BIT)
|
171
|
+
str_payloads.each do |str_payload|
|
172
|
+
payload << "\r\n".encode(Encoding::ASCII_8BIT)
|
173
|
+
payload << str_payload.force_encoding(Encoding::ASCII_8BIT)
|
174
|
+
payload << "\r\n--#{boundary}".encode(Encoding::ASCII_8BIT)
|
175
|
+
end
|
176
|
+
payload += +"--".encode(Encoding::ASCII_8BIT)
|
177
|
+
[boundary, payload]
|
171
178
|
end
|
172
179
|
|
173
180
|
private
|
data/lib/discorb/integration.rb
CHANGED
@@ -84,7 +84,7 @@ module Discorb
|
|
84
84
|
@account = Account.new(data[:account])
|
85
85
|
@subscriber_count = data[:subscriber_count]
|
86
86
|
@revoked = data[:revoked]
|
87
|
-
@application = Application.new(@client, data[:application])
|
87
|
+
@application = data[:application] and Application.new(@client, data[:application])
|
88
88
|
end
|
89
89
|
|
90
90
|
class << self
|
@@ -18,7 +18,7 @@ module Discorb
|
|
18
18
|
end
|
19
19
|
|
20
20
|
option_map = command.options.map { |k, v| [k.to_s, v[:default]] }.to_h
|
21
|
-
Discorb::CommandInteraction::SlashCommand.modify_option_map(option_map, options)
|
21
|
+
Discorb::CommandInteraction::SlashCommand.modify_option_map(option_map, options, guild)
|
22
22
|
focused_index = options.find_index { |o| o[:focused] }
|
23
23
|
val = command.options.values[focused_index][:autocomplete]&.call(self, *command.options.map { |k, v| option_map[k.to_s] })
|
24
24
|
send_complete_result(val)
|
@@ -26,7 +26,7 @@ module Discorb
|
|
26
26
|
end
|
27
27
|
|
28
28
|
option_map = command.options.map { |k, v| [k.to_s, v[:default]] }.to_h
|
29
|
-
SlashCommand.modify_option_map(option_map, options)
|
29
|
+
SlashCommand.modify_option_map(option_map, options, guild)
|
30
30
|
|
31
31
|
command.block.call(self, *command.options.map { |k, v| option_map[k.to_s] })
|
32
32
|
end
|
@@ -59,7 +59,7 @@ module Discorb
|
|
59
59
|
end
|
60
60
|
|
61
61
|
# @private
|
62
|
-
def modify_option_map(option_map, options)
|
62
|
+
def modify_option_map(option_map, options, guild)
|
63
63
|
options ||= []
|
64
64
|
options.each_with_index do |option|
|
65
65
|
val = case option[:type]
|
data/lib/discorb/message.rb
CHANGED
@@ -109,9 +109,10 @@ module Discorb
|
|
109
109
|
# * `:guild_discovery_grace_period_final_warning`
|
110
110
|
# * `:thread_created`
|
111
111
|
# * `:reply`
|
112
|
-
# * `:
|
112
|
+
# * `:chat_input_command`
|
113
113
|
# * `:thread_starter_message`
|
114
114
|
# * `:guild_invite_reminder`
|
115
|
+
# * `:context_menu_command`
|
115
116
|
attr_reader :type
|
116
117
|
# @return [Discorb::Message::Activity] The activity of the message.
|
117
118
|
attr_reader :activity
|
@@ -143,28 +144,29 @@ module Discorb
|
|
143
144
|
attr_reader :pinned
|
144
145
|
alias pinned? pinned
|
145
146
|
@message_type = {
|
146
|
-
default
|
147
|
-
recipient_add
|
148
|
-
recipient_remove
|
149
|
-
call
|
150
|
-
channel_name_change
|
151
|
-
channel_icon_change
|
152
|
-
channel_pinned_message
|
153
|
-
guild_member_join
|
154
|
-
user_premium_guild_subscription
|
155
|
-
user_premium_guild_subscription_tier_1
|
156
|
-
user_premium_guild_subscription_tier_2
|
157
|
-
user_premium_guild_subscription_tier_3
|
158
|
-
channel_follow_add
|
159
|
-
guild_discovery_disqualified
|
160
|
-
guild_discovery_requalified
|
161
|
-
guild_discovery_grace_period_initial_warning
|
162
|
-
guild_discovery_grace_period_final_warning
|
163
|
-
thread_created
|
164
|
-
reply
|
165
|
-
|
166
|
-
thread_starter_message
|
167
|
-
guild_invite_reminder
|
147
|
+
0 => :default,
|
148
|
+
1 => :recipient_add,
|
149
|
+
2 => :recipient_remove,
|
150
|
+
3 => :call,
|
151
|
+
4 => :channel_name_change,
|
152
|
+
5 => :channel_icon_change,
|
153
|
+
6 => :channel_pinned_message,
|
154
|
+
7 => :guild_member_join,
|
155
|
+
8 => :user_premium_guild_subscription,
|
156
|
+
9 => :user_premium_guild_subscription_tier_1,
|
157
|
+
10 => :user_premium_guild_subscription_tier_2,
|
158
|
+
11 => :user_premium_guild_subscription_tier_3,
|
159
|
+
12 => :channel_follow_add,
|
160
|
+
14 => :guild_discovery_disqualified,
|
161
|
+
15 => :guild_discovery_requalified,
|
162
|
+
16 => :guild_discovery_grace_period_initial_warning,
|
163
|
+
17 => :guild_discovery_grace_period_final_warning,
|
164
|
+
18 => :thread_created,
|
165
|
+
19 => :reply,
|
166
|
+
20 => :chat_input_command,
|
167
|
+
21 => :thread_starter_message,
|
168
|
+
22 => :guild_invite_reminder,
|
169
|
+
23 => :context_menu_command,
|
168
170
|
}.freeze
|
169
171
|
|
170
172
|
# @!attribute [r] channel
|
data/lib/discorb/user.rb
CHANGED
@@ -26,6 +26,9 @@ module Discorb
|
|
26
26
|
|
27
27
|
include Discorb::Messageable
|
28
28
|
|
29
|
+
# @!attribute [r] mention
|
30
|
+
# @return [String] The user's mention.
|
31
|
+
|
29
32
|
# @private
|
30
33
|
def initialize(client, data)
|
31
34
|
@client = client
|
@@ -43,6 +46,10 @@ module Discorb
|
|
43
46
|
"#{@username}##{@discriminator}"
|
44
47
|
end
|
45
48
|
|
49
|
+
def mention
|
50
|
+
"<@#{@id}>"
|
51
|
+
end
|
52
|
+
|
46
53
|
alias to_s_user to_s
|
47
54
|
|
48
55
|
def inspect
|
@@ -22,6 +22,12 @@ def yard_replace(dir, version)
|
|
22
22
|
<h1 class="noborder title">Documentation by YARD 0.9.26</h1>
|
23
23
|
HTML3
|
24
24
|
HTML4
|
25
|
+
if version == "main"
|
26
|
+
display_version = "(main)"
|
27
|
+
else
|
28
|
+
display_version = "v" + version
|
29
|
+
end
|
30
|
+
contents.gsub!(/Documentation by YARD \d+\.\d+\.\d+/, "discorb #{display_version} documentation")
|
25
31
|
File.write(file, contents)
|
26
32
|
end
|
27
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.12.
|
4
|
+
version: 0.12.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sevenc-nanashi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -77,11 +77,13 @@ files:
|
|
77
77
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
78
78
|
- ".github/ISSUE_TEMPLATE/config.yml"
|
79
79
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
80
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
80
81
|
- ".github/workflows/build_main.yml"
|
81
82
|
- ".github/workflows/build_version.yml"
|
82
83
|
- ".github/workflows/package_register.yml"
|
83
84
|
- ".gitignore"
|
84
85
|
- ".yardopts"
|
86
|
+
- CONTRIBUTING.md
|
85
87
|
- Changelog.md
|
86
88
|
- Gemfile
|
87
89
|
- LICENSE.txt
|
@@ -219,5 +221,5 @@ requirements: []
|
|
219
221
|
rubygems_version: 3.2.22
|
220
222
|
signing_key:
|
221
223
|
specification_version: 4
|
222
|
-
summary:
|
224
|
+
summary: A discord API wrapper written in Ruby
|
223
225
|
test_files: []
|