discorb 0.9.5 → 0.10.2
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/Changelog.md +309 -260
- data/docs/application_command.md +1 -0
- data/docs/cli/init.md +3 -3
- data/docs/cli/run.md +5 -1
- data/docs/extension.md +16 -22
- data/docs/license.md +4 -0
- data/docs/tutorial.md +1 -1
- data/examples/extension/main.rb +1 -1
- data/examples/extension/message_expander.rb +4 -6
- data/lib/discorb/app_command.rb +4 -0
- data/lib/discorb/client.rb +32 -22
- data/lib/discorb/common.rb +4 -23
- data/lib/discorb/components.rb +29 -1
- data/lib/discorb/exe/{init.rb → new.rb} +1 -1
- data/lib/discorb/exe/run.rb +20 -3
- data/lib/discorb/extension.rb +60 -47
- data/lib/discorb/interaction.rb +4 -2
- data/lib/discorb/modules.rb +5 -41
- data/template-replace/files/css/common.css +1 -0
- data/template-replace/scripts/version.rb +25 -5
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ea8e05d77b37b7a269b43dff64422e3d49b08d6c09a639d40dc019baaa26a8c
|
|
4
|
+
data.tar.gz: c8ea6f45759aaf22112f6400f7d950fb09f427f98d01302a18094ad3d6a3ae08
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b3f5e77107192aec6943087251c5b61ab1476eb421ddb0297d61178e5146466a5a59c50f4665a2b81c362d927765259142ed1bc08ed9c07e3018102becab3294
|
|
7
|
+
data.tar.gz: b88f74d4f3e0f0025f7086e95c2b1e2b96ed19a35a258a72dd29f1814986465ac9fdd8443f920fe8b7dcd610d35871b59354ba8cc6b478bcf883797cd17d463d
|
data/Changelog.md
CHANGED
|
@@ -1,260 +1,309 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- Add: Add
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
- Add: Add `
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
-
|
|
53
|
-
- Add:
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
- Fix: Fix
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
- Fix: Fix
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
- Add: Add
|
|
76
|
-
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
- Add: Add `
|
|
87
|
-
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
- Add:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
- Add:
|
|
113
|
-
-
|
|
114
|
-
- Fix: Fix
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
- Add: Add
|
|
124
|
-
-
|
|
125
|
-
- Add: Add `
|
|
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
|
-
- Add: Add `
|
|
157
|
-
-
|
|
158
|
-
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
- Fix: Fix error
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
-
|
|
185
|
-
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
- Add: Add `
|
|
213
|
-
-
|
|
214
|
-
-
|
|
215
|
-
|
|
216
|
-
##
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
- Add: Add `
|
|
221
|
-
- Fix: Fix
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
- Add: Add
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
1
|
+
# @title Changelog
|
|
2
|
+
|
|
3
|
+
# Changelog
|
|
4
|
+
|
|
5
|
+
## v0.10
|
|
6
|
+
|
|
7
|
+
### v0.10.2
|
|
8
|
+
|
|
9
|
+
- Change: `discorb init` is now `discorb new`
|
|
10
|
+
- Add: Add `:channel_types` parameter to `ApplicationCommand::Handler#slash` and some
|
|
11
|
+
|
|
12
|
+
### v0.10.1
|
|
13
|
+
|
|
14
|
+
- Add: Add `Client#extensions`
|
|
15
|
+
- Change: `Client#load_extension` allows instance of `Extension`
|
|
16
|
+
- Add: Add `-b` option to `discorb run`
|
|
17
|
+
|
|
18
|
+
### v0.10.0
|
|
19
|
+
|
|
20
|
+
- Change: Sort versions
|
|
21
|
+
- Change: Snowflake is now String
|
|
22
|
+
- Change: Extension is now Class
|
|
23
|
+
- Add: Add `SelectMenu#disabled=`
|
|
24
|
+
|
|
25
|
+
## v0.9
|
|
26
|
+
|
|
27
|
+
### v0.9.6
|
|
28
|
+
|
|
29
|
+
- Add: Add `Messageable#send_message` as alias of `Messageable#post`
|
|
30
|
+
- Fix: Fix interaction responding with updating message
|
|
31
|
+
- Fix: Fix `MessageComponentInteraction#message`
|
|
32
|
+
|
|
33
|
+
### v0.9.5
|
|
34
|
+
|
|
35
|
+
- Fix: Fix editing message
|
|
36
|
+
- Add: Add `required` in slash command argument
|
|
37
|
+
- Add: Add `default` in slash command argument
|
|
38
|
+
|
|
39
|
+
### v0.9.4
|
|
40
|
+
|
|
41
|
+
- Change: `Messageable#typing` with block is now synchronous
|
|
42
|
+
- Fix: Fix some issues in document
|
|
43
|
+
- Add: Add some attributes to `Message`
|
|
44
|
+
- Fix: Fix guild parameter in message of message command
|
|
45
|
+
|
|
46
|
+
### v0.9.3
|
|
47
|
+
|
|
48
|
+
- Fix: Fix interaction responding
|
|
49
|
+
|
|
50
|
+
### v0.9.2 (yanked)
|
|
51
|
+
|
|
52
|
+
- Add: Make `Async::Task#inspect` shorter
|
|
53
|
+
- Add: `SourceResponse#post` will return message now
|
|
54
|
+
- Fix: Fix member caching
|
|
55
|
+
|
|
56
|
+
### v0.9.1
|
|
57
|
+
|
|
58
|
+
- Fix: Fix member fetching
|
|
59
|
+
|
|
60
|
+
### v0.9.0
|
|
61
|
+
|
|
62
|
+
- Delete: Delete `-d` parameter from `discorb run`; This is caused by segement fault error.
|
|
63
|
+
- Change: Rename `-t`, `--token` to `-e`, `--env` parameter
|
|
64
|
+
- Add: Add `-t`, `--title` parameter to `discorb run`
|
|
65
|
+
- Add: Add `title` parameter to `Client#initialize`
|
|
66
|
+
|
|
67
|
+
## v0.8
|
|
68
|
+
|
|
69
|
+
### v0.8.2
|
|
70
|
+
|
|
71
|
+
- Fix: Fix `Client#initialize`
|
|
72
|
+
|
|
73
|
+
### v0.8.1
|
|
74
|
+
|
|
75
|
+
- Add: Add FAQ
|
|
76
|
+
- Fix: Fix sending files
|
|
77
|
+
- Add: Add `File.from_string`
|
|
78
|
+
- Fix: Fix `Client#update_presence`
|
|
79
|
+
- Add: Add information in `discorb run -d`
|
|
80
|
+
|
|
81
|
+
### v0.8.0
|
|
82
|
+
|
|
83
|
+
- Add: Add `Guild#fetch_members`
|
|
84
|
+
- Add: Add `Guild#fetch_member_list` as alias of `Guild#fetch_members`
|
|
85
|
+
- Add: Add `Intents#to_h`
|
|
86
|
+
- Add: Add `fetch_member` parameter to `Client#initialize`; Note you should set `false` if your bot doesn't have `GUILD_MEMBERS` intent
|
|
87
|
+
- Change: Change `ready` to `standby` event
|
|
88
|
+
- Change: `ready` will be fired when client receives `READY` event
|
|
89
|
+
|
|
90
|
+
## v0.7
|
|
91
|
+
|
|
92
|
+
### v0.7.6
|
|
93
|
+
|
|
94
|
+
- Fix: Fix heartbeating error
|
|
95
|
+
|
|
96
|
+
### v0.7.5 (yanked)
|
|
97
|
+
|
|
98
|
+
- Fix: Fix critical error
|
|
99
|
+
|
|
100
|
+
### v0.7.4 (yanked)
|
|
101
|
+
|
|
102
|
+
- Fix: Fix disconnected client
|
|
103
|
+
|
|
104
|
+
### v0.7.3
|
|
105
|
+
|
|
106
|
+
- Add: Improve `discorb init`
|
|
107
|
+
|
|
108
|
+
### v0.7.2
|
|
109
|
+
|
|
110
|
+
- Add: Add `Member#owner?`
|
|
111
|
+
- Fix: Fix `Member#permissions`
|
|
112
|
+
- Add: Add `Member#guild_permissions` as alias of `Member#permissions`
|
|
113
|
+
- Add: Add default role to `Member#roles`
|
|
114
|
+
- Fix: Fix error in `Integration#_set_data`
|
|
115
|
+
- Change: Reverse `Member#roles`
|
|
116
|
+
|
|
117
|
+
### v0.7.1
|
|
118
|
+
|
|
119
|
+
- Fix: Fix error of responding to interaction
|
|
120
|
+
|
|
121
|
+
### v0.7.0
|
|
122
|
+
|
|
123
|
+
- Add: Add `error` event
|
|
124
|
+
- Fix: Fix some issues with client without guild intent
|
|
125
|
+
- Add: Add alias for `#fired_by`
|
|
126
|
+
- Change!: Change block usage of `ApplicationCommand::Handler#group`
|
|
127
|
+
|
|
128
|
+
```ruby
|
|
129
|
+
# before
|
|
130
|
+
client.slash_group do
|
|
131
|
+
slash "help", "Help" do |interaction|
|
|
132
|
+
# ...
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# after
|
|
137
|
+
client.slash_group do |group|
|
|
138
|
+
group.slash "help", "Help" do |interaction|
|
|
139
|
+
# ...
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## v0.6
|
|
146
|
+
|
|
147
|
+
### v0.6.1
|
|
148
|
+
|
|
149
|
+
- Change: Rename `Event#discriminator` to `Event#metadata`
|
|
150
|
+
- Add: Add `:override` to `Client#on`
|
|
151
|
+
|
|
152
|
+
### v0.6.0
|
|
153
|
+
|
|
154
|
+
- Fix: Fix issue with client with no guilds
|
|
155
|
+
- Add: Add rbs (experimental)
|
|
156
|
+
- Add: Add `-t`, `--token` option to `discorb run`
|
|
157
|
+
- Add: Add `-g`, `--guild` option to `discorb setup`
|
|
158
|
+
- Change: Use `Async::Task<R>` instead of `R` in return value
|
|
159
|
+
|
|
160
|
+
## v0.5
|
|
161
|
+
|
|
162
|
+
### v0.5.6
|
|
163
|
+
|
|
164
|
+
- Add: Raise error when intents are invalid
|
|
165
|
+
- Fix: Fix Emoji#==
|
|
166
|
+
|
|
167
|
+
### v0.5.5
|
|
168
|
+
|
|
169
|
+
- Fix: Fix some bugs
|
|
170
|
+
|
|
171
|
+
### v0.5.4
|
|
172
|
+
|
|
173
|
+
- Fix: Fix issue of receiving component events
|
|
174
|
+
|
|
175
|
+
### v0.5.3
|
|
176
|
+
|
|
177
|
+
- Add: Add way to handle raw events with `event_xxx`
|
|
178
|
+
- Add: Add `Client#session_id`
|
|
179
|
+
- Add: Add `Connectable`
|
|
180
|
+
- Fix: Fix error by sending DM
|
|
181
|
+
|
|
182
|
+
### v0.5.2
|
|
183
|
+
|
|
184
|
+
- Fix: Fix bug of registering commands
|
|
185
|
+
- Add: Add way to register commands in Extension
|
|
186
|
+
|
|
187
|
+
### v0.5.1
|
|
188
|
+
|
|
189
|
+
- Add: Can use block for defining group commands
|
|
190
|
+
- Fix: Fix bug in subcommands
|
|
191
|
+
- Fix: Fix bug in receiving commands
|
|
192
|
+
|
|
193
|
+
### v0.5.0
|
|
194
|
+
|
|
195
|
+
- Change: Use zlib stream instead
|
|
196
|
+
- Add: Add tutorials
|
|
197
|
+
- Add: Add ratelimit handler
|
|
198
|
+
- Change: Make `--git` option in `discorb init` false
|
|
199
|
+
|
|
200
|
+
## v0.4
|
|
201
|
+
|
|
202
|
+
### v0.4.2
|
|
203
|
+
|
|
204
|
+
- Fix: Fix error in `discorb run`
|
|
205
|
+
|
|
206
|
+
### v0.4.1
|
|
207
|
+
|
|
208
|
+
- Add: Add `-s` option to `discorb run`
|
|
209
|
+
|
|
210
|
+
### v0.4.0
|
|
211
|
+
|
|
212
|
+
- Add: Add `discorb setup`
|
|
213
|
+
- Add: Add `discorb run`
|
|
214
|
+
- Add: Add realtime documentation
|
|
215
|
+
|
|
216
|
+
## v0.3
|
|
217
|
+
|
|
218
|
+
### v0.3.1
|
|
219
|
+
|
|
220
|
+
- Add: Add `discorb show`
|
|
221
|
+
- Fix: Fix documenting
|
|
222
|
+
|
|
223
|
+
### v0.3.0
|
|
224
|
+
|
|
225
|
+
- Add: Improve CLI tools
|
|
226
|
+
- Add: Add `discorb init`
|
|
227
|
+
- Change: Change `discord-irb` to `discorb irb`
|
|
228
|
+
|
|
229
|
+
## v0.2
|
|
230
|
+
|
|
231
|
+
### v0.2.5
|
|
232
|
+
|
|
233
|
+
- Add: Add way to add event listener
|
|
234
|
+
- Change: Move document to https://discorb-lib.github.io/
|
|
235
|
+
|
|
236
|
+
### v0.2.4
|
|
237
|
+
|
|
238
|
+
- Fix: Fix error in `Embed#image=`, `Embed#thumbnail=`
|
|
239
|
+
|
|
240
|
+
### v0.2.3
|
|
241
|
+
|
|
242
|
+
- Fix: Fix critical error
|
|
243
|
+
|
|
244
|
+
### v0.2.2 (yanked)
|
|
245
|
+
|
|
246
|
+
- Add: Add `Snowflake#to_str`
|
|
247
|
+
|
|
248
|
+
### v0.2.1
|
|
249
|
+
|
|
250
|
+
- Fix: Fix NoMethodError in reaction event
|
|
251
|
+
- Add: Add Changelog.md to document
|
|
252
|
+
|
|
253
|
+
### v0.2.0
|
|
254
|
+
|
|
255
|
+
- Fix: Fix unused dependency
|
|
256
|
+
- Add: Add `Client#close!`
|
|
257
|
+
- Add: Add discord-irb
|
|
258
|
+
|
|
259
|
+
## v0.1
|
|
260
|
+
|
|
261
|
+
### v0.1.0
|
|
262
|
+
|
|
263
|
+
- Add: Add `User#created_at`
|
|
264
|
+
- Add: Add `Member#to_s_user`
|
|
265
|
+
- Add: Add `DefaultAvatar`
|
|
266
|
+
- Add: Support application commands
|
|
267
|
+
- Add: Add `Client#ping`
|
|
268
|
+
- Add: Allow `String` for `Embed#initialize`
|
|
269
|
+
- Change: Change log format
|
|
270
|
+
|
|
271
|
+
## v0.0
|
|
272
|
+
|
|
273
|
+
### v0.0.8
|
|
274
|
+
|
|
275
|
+
- Delete: Delete task parameter
|
|
276
|
+
|
|
277
|
+
### v0.0.7
|
|
278
|
+
|
|
279
|
+
- Fix: Fix `member_xxx` event
|
|
280
|
+
|
|
281
|
+
### v0.0.6
|
|
282
|
+
|
|
283
|
+
- Fix: Fix error in client without members intent
|
|
284
|
+
- Add: Add ThreadChannel::News
|
|
285
|
+
- Add: Add official discord link
|
|
286
|
+
|
|
287
|
+
### v0.0.5
|
|
288
|
+
|
|
289
|
+
- Fix: Fix GitHub link
|
|
290
|
+
- Change: Internet to HTTP
|
|
291
|
+
|
|
292
|
+
### v0.0.4
|
|
293
|
+
|
|
294
|
+
- Fix: Fix NoMethodError by webhook message
|
|
295
|
+
- Add: Add `#author` to webhook message
|
|
296
|
+
- Fix: Add `#bot?` to webhook author
|
|
297
|
+
|
|
298
|
+
### v0.0.3
|
|
299
|
+
|
|
300
|
+
- Fix: Fix no dependencies
|
|
301
|
+
|
|
302
|
+
### v0.0.2
|
|
303
|
+
|
|
304
|
+
- Fix: Fix rubygems description
|
|
305
|
+
|
|
306
|
+
### v0.0.1
|
|
307
|
+
|
|
308
|
+
- Initial release
|
|
309
|
+
|
data/docs/application_command.md
CHANGED
|
@@ -68,6 +68,7 @@ In `options`, hash should be like this:
|
|
|
68
68
|
| `:type` | `Object` | Type of the option. |
|
|
69
69
|
| `:choice` | `Hash{String => String, Integer, Float}` | Type of the option. |
|
|
70
70
|
| `:default` | `Object` | Default value of the option. |
|
|
71
|
+
| `:channel_types` | `Array<Class<Discorb::Channel>>` | Type of the channel option. |
|
|
71
72
|
|
|
72
73
|
`choices` should be unspecified if you don't want to use it.
|
|
73
74
|
`choices` is hash like this:
|
data/docs/cli/init.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# @title CLI: discorb
|
|
1
|
+
# @title CLI: discorb new
|
|
2
2
|
|
|
3
|
-
# discorb
|
|
3
|
+
# discorb new
|
|
4
4
|
|
|
5
5
|
This command will create a new project in the directory.
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
discorb
|
|
10
|
+
discorb new [options] [dir]
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Options
|
data/docs/cli/run.md
CHANGED
|
@@ -53,4 +53,8 @@ Whether to setup application commands.
|
|
|
53
53
|
|
|
54
54
|
#### `-e`, `--env`
|
|
55
55
|
|
|
56
|
-
The name of the environment variable to use for token, or just `-t` or `--token` for intractive prompt.
|
|
56
|
+
The name of the environment variable to use for token, or just `-t` or `--token` for intractive prompt.
|
|
57
|
+
|
|
58
|
+
#### `-b`, `--bundler`
|
|
59
|
+
|
|
60
|
+
Whether to use bundler to load the script.
|
data/docs/extension.md
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
# Extension
|
|
4
4
|
|
|
5
|
-
Extension allows you to
|
|
5
|
+
Extension allows you to seperate your code from the main application.
|
|
6
|
+
|
|
7
|
+
# @since
|
|
6
8
|
|
|
7
9
|
## Make a new extension
|
|
8
10
|
|
|
9
|
-
Make a new
|
|
11
|
+
Make a new class that extends Extension.
|
|
10
12
|
|
|
11
13
|
```ruby
|
|
12
|
-
|
|
13
|
-
extend Discorb::Extension
|
|
14
|
-
|
|
14
|
+
class MyExtension < Discorb::Extension
|
|
15
15
|
# ...
|
|
16
16
|
end
|
|
17
17
|
```
|
|
@@ -21,27 +21,25 @@ end
|
|
|
21
21
|
Use {Discorb::Extension.event} to register event, or {Discorb::Extension.once_event} to register event only once.
|
|
22
22
|
|
|
23
23
|
```ruby
|
|
24
|
-
|
|
25
|
-
extend Discorb::Extension
|
|
26
|
-
|
|
24
|
+
class MyExtension < Discorb::Extension
|
|
27
25
|
event :message do |message|
|
|
28
26
|
# ...
|
|
29
27
|
end
|
|
30
28
|
|
|
31
|
-
once_event :
|
|
29
|
+
once_event :standby do |message|
|
|
32
30
|
# ...
|
|
33
31
|
end
|
|
34
32
|
end
|
|
35
33
|
```
|
|
36
34
|
|
|
35
|
+
Note block will be binded to the extension instance.
|
|
36
|
+
|
|
37
37
|
## Register Command
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Use `Discorb::Extension.command` to register command, see {Discorb::ApplicationCommand::Handler} for more information.
|
|
40
40
|
|
|
41
41
|
```ruby
|
|
42
|
-
|
|
43
|
-
extend Discorb::Extension
|
|
44
|
-
|
|
42
|
+
class MyExtension < Discorb::Extension
|
|
45
43
|
slash("command", "Command") do |interaction|
|
|
46
44
|
# ...
|
|
47
45
|
end
|
|
@@ -63,18 +61,16 @@ end
|
|
|
63
61
|
|
|
64
62
|
## Load extension
|
|
65
63
|
|
|
66
|
-
Use {Discorb::Client#
|
|
64
|
+
Use {Discorb::Client#load_extension} to load extension.
|
|
67
65
|
|
|
68
66
|
```ruby
|
|
69
|
-
|
|
70
|
-
extend Discorb::Extension
|
|
71
|
-
|
|
67
|
+
class MyExtension < Discorb::Extension
|
|
72
68
|
event :message do |message|
|
|
73
69
|
# ...
|
|
74
70
|
end
|
|
75
71
|
end
|
|
76
72
|
|
|
77
|
-
client.
|
|
73
|
+
client.load_extension(MyExtension)
|
|
78
74
|
```
|
|
79
75
|
|
|
80
76
|
## Access Client from extension
|
|
@@ -82,10 +78,8 @@ client.extend MyExtension
|
|
|
82
78
|
You can access {Discorb::Client} from extension with `@client`.
|
|
83
79
|
|
|
84
80
|
```ruby
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
event :ready do |message|
|
|
81
|
+
class MyExtension < Discorb::Extension
|
|
82
|
+
event :standby do |message|
|
|
89
83
|
puts "Logged in as #{@client.user}"
|
|
90
84
|
end
|
|
91
85
|
end
|
data/docs/license.md
CHANGED
data/docs/tutorial.md
CHANGED
data/examples/extension/main.rb
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
require "discorb"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@message_regex = Regexp.new(
|
|
3
|
+
class MessageExpander < Discorb::Extension
|
|
4
|
+
@@message_regex = Regexp.new(
|
|
7
5
|
'(?!<)https://(?:ptb\.|canary\.)?discord(?:app)?\.com/channels/' \
|
|
8
6
|
"(?<guild>[0-9]{18})/(?<channel>[0-9]{18})/(?<message>[0-9]{18})(?!>)"
|
|
9
7
|
)
|
|
@@ -11,7 +9,7 @@ module MessageExpander
|
|
|
11
9
|
event :message do |message|
|
|
12
10
|
next if message.author.bot?
|
|
13
11
|
|
|
14
|
-
message.content.to_enum(:scan,
|
|
12
|
+
message.content.to_enum(:scan, @@message_regex).map { Regexp.last_match }.each do |match|
|
|
15
13
|
ch = @client.channels[match[:channel]]
|
|
16
14
|
next if ch.nil?
|
|
17
15
|
|
|
@@ -27,7 +25,7 @@ module MessageExpander
|
|
|
27
25
|
author: Discorb::Embed::Author.new(
|
|
28
26
|
url_message.author.name,
|
|
29
27
|
url: url_message.jump_url,
|
|
30
|
-
icon: url_message.author.
|
|
28
|
+
icon: url_message.author.avatar.url,
|
|
31
29
|
),
|
|
32
30
|
footer: Discorb::Embed::Footer.new(
|
|
33
31
|
"#{url_message.guild.name} / #{ch.name}",
|
data/lib/discorb/app_command.rb
CHANGED
|
@@ -25,6 +25,7 @@ module Discorb
|
|
|
25
25
|
# | `:type` | `Object` | Type of the option. |
|
|
26
26
|
# | `:choice` | `Hash{String => String, Integer, Float}` | Type of the option. |
|
|
27
27
|
# | `:default` | `Object` | Default value of the option. |
|
|
28
|
+
# | `:channel_types` | `Array<Class<Discorb::Channel>>` | Type of the channel option. |
|
|
28
29
|
#
|
|
29
30
|
# @param [Array<#to_s>, false, nil] guild_ids Guild IDs to set the command to. `false` to global command, `nil` to use default.
|
|
30
31
|
# @param [Proc] block Command block.
|
|
@@ -238,6 +239,9 @@ module Discorb
|
|
|
238
239
|
if value[:choices]
|
|
239
240
|
ret[:choices] = value[:choices].map { |t| { name: t[0], value: t[1] } }
|
|
240
241
|
end
|
|
242
|
+
if value[:channel_types]
|
|
243
|
+
ret[:channel_types] = value[:channel_types].map(&:channel_type)
|
|
244
|
+
end
|
|
241
245
|
ret
|
|
242
246
|
end
|
|
243
247
|
{
|
data/lib/discorb/client.rb
CHANGED
|
@@ -52,6 +52,8 @@ module Discorb
|
|
|
52
52
|
attr_reader :status
|
|
53
53
|
# @return [Integer] The session ID of connection.
|
|
54
54
|
attr_reader :session_id
|
|
55
|
+
# @return [Hash{String => Discorb::Extension}] The loaded extensions.
|
|
56
|
+
attr_reader :extensions
|
|
55
57
|
# @private
|
|
56
58
|
attr_reader :bottom_commands
|
|
57
59
|
|
|
@@ -97,6 +99,7 @@ module Discorb
|
|
|
97
99
|
@status = :initialized
|
|
98
100
|
@fetch_member = fetch_member
|
|
99
101
|
@title = title
|
|
102
|
+
@extensions = {}
|
|
100
103
|
set_default_events
|
|
101
104
|
end
|
|
102
105
|
|
|
@@ -369,31 +372,38 @@ module Discorb
|
|
|
369
372
|
#
|
|
370
373
|
# Load the extension.
|
|
371
374
|
#
|
|
372
|
-
# @param [
|
|
375
|
+
# @param [Class, Discorb::Extension] ext The extension to load.
|
|
376
|
+
# @param [Object] ... The arguments to pass to the `ext#initialize`.
|
|
373
377
|
#
|
|
374
|
-
def
|
|
375
|
-
if
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
@commands << cmd
|
|
378
|
+
def load_extension(ext, ...)
|
|
379
|
+
if ext.is_a?(Class)
|
|
380
|
+
raise ArgumentError, "#{ext} is not a extension" unless ext < Discorb::Extension
|
|
381
|
+
ins = ext.new(self, ...)
|
|
382
|
+
elsif ext.is_a?(Discorb::Extension)
|
|
383
|
+
ins = ext
|
|
384
|
+
else
|
|
385
|
+
raise ArgumentError, "#{ext} is not a extension"
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
@events.each_value do |event|
|
|
389
|
+
event.delete_if { |c| c.metadata[:extension] == ins.class.name }
|
|
390
|
+
end
|
|
391
|
+
ins.events.each do |name, events|
|
|
392
|
+
@events[name] ||= []
|
|
393
|
+
events.each do |event|
|
|
394
|
+
@events[name] << event
|
|
392
395
|
end
|
|
393
|
-
@bottom_commands += mod.bottom_commands
|
|
394
|
-
mod.client = self
|
|
395
396
|
end
|
|
396
|
-
|
|
397
|
+
@commands.delete_if do |cmd|
|
|
398
|
+
cmd.respond_to? :extension and cmd.extension == ins.name
|
|
399
|
+
end
|
|
400
|
+
ins.class.commands.each do |cmd|
|
|
401
|
+
cmd.define_singleton_method(:extension) { ins.name }
|
|
402
|
+
@commands << cmd
|
|
403
|
+
end
|
|
404
|
+
@bottom_commands += ins.class.bottom_commands
|
|
405
|
+
@extensions[ins.class.name] = ins
|
|
406
|
+
ins
|
|
397
407
|
end
|
|
398
408
|
|
|
399
409
|
include Discorb::Gateway::Handler
|
data/lib/discorb/common.rb
CHANGED
|
@@ -4,9 +4,9 @@ module Discorb
|
|
|
4
4
|
# @return [String] The API base URL.
|
|
5
5
|
API_BASE_URL = "https://discord.com/api/v9"
|
|
6
6
|
# @return [String] The version of discorb.
|
|
7
|
-
VERSION = "0.
|
|
7
|
+
VERSION = "0.10.2"
|
|
8
8
|
# @return [String] The user agent for the bot.
|
|
9
|
-
USER_AGENT = "DiscordBot (https://
|
|
9
|
+
USER_AGENT = "DiscordBot (https://discorb-lib.github.io #{VERSION}) Ruby/#{RUBY_VERSION}"
|
|
10
10
|
|
|
11
11
|
#
|
|
12
12
|
# @abstract
|
|
@@ -39,10 +39,11 @@ module Discorb
|
|
|
39
39
|
# Represents Snowflake of Discord.
|
|
40
40
|
#
|
|
41
41
|
# @see https://discord.com/developers/docs/reference#snowflakes Official Discord API docs
|
|
42
|
-
class Snowflake <
|
|
42
|
+
class Snowflake < String
|
|
43
43
|
# @private
|
|
44
44
|
def initialize(value)
|
|
45
45
|
@value = value.to_i
|
|
46
|
+
super(@value.to_s)
|
|
46
47
|
end
|
|
47
48
|
|
|
48
49
|
# @!attribute [r] timestamp
|
|
@@ -64,26 +65,6 @@ module Discorb
|
|
|
64
65
|
#
|
|
65
66
|
# @return [Integer] Increment of snowflake.
|
|
66
67
|
|
|
67
|
-
#
|
|
68
|
-
# Stringify snowflake.
|
|
69
|
-
#
|
|
70
|
-
# @return [String] Stringified snowflake.
|
|
71
|
-
#
|
|
72
|
-
def to_s
|
|
73
|
-
@value.to_s
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
alias to_str to_s
|
|
77
|
-
|
|
78
|
-
#
|
|
79
|
-
# Integerize snowflake.
|
|
80
|
-
#
|
|
81
|
-
# @return [Integer] Integerized snowflake.
|
|
82
|
-
#
|
|
83
|
-
def to_i
|
|
84
|
-
@value.to_i
|
|
85
|
-
end
|
|
86
|
-
|
|
87
68
|
#
|
|
88
69
|
# Compares snowflake with other object.
|
|
89
70
|
#
|
data/lib/discorb/components.rb
CHANGED
|
@@ -36,6 +36,34 @@ module Discorb
|
|
|
36
36
|
)
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
|
+
|
|
40
|
+
#
|
|
41
|
+
# Convert components to a hash.
|
|
42
|
+
#
|
|
43
|
+
# @param [Array<Discorb::Component>, Array<Array<Discorb::Component>>] components Components.
|
|
44
|
+
#
|
|
45
|
+
# @return [Array<Hash>] Hash data.
|
|
46
|
+
#
|
|
47
|
+
def to_payload(components)
|
|
48
|
+
tmp_components = []
|
|
49
|
+
tmp_row = []
|
|
50
|
+
components.each do |c|
|
|
51
|
+
case c
|
|
52
|
+
when Array
|
|
53
|
+
tmp_components << tmp_row
|
|
54
|
+
tmp_row = []
|
|
55
|
+
tmp_components << c
|
|
56
|
+
when SelectMenu
|
|
57
|
+
tmp_components << tmp_row
|
|
58
|
+
tmp_row = []
|
|
59
|
+
tmp_components << [c]
|
|
60
|
+
else
|
|
61
|
+
tmp_row << c
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
tmp_components << tmp_row
|
|
65
|
+
return tmp_components.filter { |c| c.length.positive? }.map { |c| { type: 1, components: c.map(&:to_hash) } }
|
|
66
|
+
end
|
|
39
67
|
end
|
|
40
68
|
end
|
|
41
69
|
|
|
@@ -152,7 +180,7 @@ module Discorb
|
|
|
152
180
|
# @return [Integer] The maximum number of values.
|
|
153
181
|
attr_accessor :max_values
|
|
154
182
|
# @return [Boolean] Whether the select menu is disabled.
|
|
155
|
-
|
|
183
|
+
attr_accessor :disabled
|
|
156
184
|
alias disabled? disabled
|
|
157
185
|
|
|
158
186
|
#
|
data/lib/discorb/exe/run.rb
CHANGED
|
@@ -22,6 +22,7 @@ options = {
|
|
|
22
22
|
log_color: nil,
|
|
23
23
|
setup: nil,
|
|
24
24
|
token: false,
|
|
25
|
+
bundler: :default,
|
|
25
26
|
}
|
|
26
27
|
opt.on("-l", "--log-level LEVEL", "Log level.") do |v|
|
|
27
28
|
unless LOG_LEVELS.include? v.downcase
|
|
@@ -36,6 +37,7 @@ opt.on("-c", "--[no-]log-color", "Whether to colorize log output.") { |v| option
|
|
|
36
37
|
opt.on("-s", "--setup", "Whether to setup application commands.") { |v| options[:setup] = v }
|
|
37
38
|
opt.on("-e", "--env [ENV]", "The name of the environment variable to use for token, or just `-e` or `--env` for intractive prompt.") { |v| options[:token] = v }
|
|
38
39
|
opt.on("-t", "--title TITLE", "The title of process.") { |v| options[:title] = v }
|
|
40
|
+
opt.on("-b", "--[no-]bundler", "Whether to use bundler. Default to true if Gemfile exists, otherwise false.") { |v| options[:bundler] = v }
|
|
39
41
|
opt.parse!(ARGV)
|
|
40
42
|
|
|
41
43
|
script = ARGV[0]
|
|
@@ -54,10 +56,25 @@ elsif options[:token].nil? || options[:token] == "-"
|
|
|
54
56
|
puts ""
|
|
55
57
|
end
|
|
56
58
|
|
|
59
|
+
if options[:bundler] == :default
|
|
60
|
+
dir = Dir.pwd.split("/")
|
|
61
|
+
options[:bundler] = false
|
|
62
|
+
dir.length.times.reverse_each do |i|
|
|
63
|
+
if File.exist? "#{dir[0..i].join("/")}/Gemfile"
|
|
64
|
+
options[:bundler] = true
|
|
65
|
+
break
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
57
70
|
ENV["DISCORB_CLI_TITLE"] = options[:title]
|
|
58
71
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
if File.exist? script
|
|
73
|
+
if options[:bundler]
|
|
74
|
+
system "bundle exec ruby #{script}"
|
|
75
|
+
else
|
|
76
|
+
system "ruby #{script}"
|
|
77
|
+
end
|
|
78
|
+
else
|
|
62
79
|
eputs "Could not load script: \e[31m#{script}\e[91m"
|
|
63
80
|
end
|
data/lib/discorb/extension.rb
CHANGED
|
@@ -2,65 +2,78 @@
|
|
|
2
2
|
|
|
3
3
|
module Discorb
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
5
|
+
# Abstract class to make extension.
|
|
6
|
+
# Inherit from this class to make your own extension.
|
|
7
7
|
# @see file:docs/extension.md
|
|
8
8
|
# @abstract
|
|
9
9
|
#
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
undef setup_commands
|
|
10
|
+
class Extension
|
|
11
|
+
extend Discorb::ApplicationCommand::Handler
|
|
13
12
|
|
|
14
13
|
@events = {}
|
|
15
|
-
@client = nil
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
#
|
|
20
|
-
# @param [Symbol] event_name The name of the event.
|
|
21
|
-
# @param [Symbol] id The id of the event. Used to delete the event.
|
|
22
|
-
# @param [Hash] metadata Other metadata.
|
|
23
|
-
# @param [Proc] block The block to execute when the event is triggered.
|
|
24
|
-
#
|
|
25
|
-
# @return [Discorb::Event] The event.
|
|
26
|
-
#
|
|
27
|
-
def event(event_name, id: nil, **metadata, &block)
|
|
28
|
-
raise ArgumentError, "Event name must be a symbol" unless event_name.is_a?(Symbol)
|
|
29
|
-
raise ArgumentError, "block must be a Proc" unless block.is_a?(Proc)
|
|
30
|
-
|
|
31
|
-
@events[event_name] ||= []
|
|
32
|
-
metadata[:extension] = self.name
|
|
33
|
-
@events[event_name] << Discorb::Event.new(block, id, metadata)
|
|
15
|
+
def initialize(client)
|
|
16
|
+
@client = client
|
|
34
17
|
end
|
|
35
18
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
#
|
|
46
|
-
def once_event(event_name, id: nil, **metadata, &block)
|
|
47
|
-
event(event_name, id: id, once: true, **metadata, &block)
|
|
19
|
+
def events
|
|
20
|
+
return @events if @events
|
|
21
|
+
ret = {}
|
|
22
|
+
self.class.events.each do |event, handlers|
|
|
23
|
+
ret[event] = handlers.map do |handler|
|
|
24
|
+
Discorb::Event.new(Proc.new { |*args, **kwargs| instance_exec(*args, **kwargs, &handler[2]) }, handler[0], handler[1])
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
@events = ret
|
|
48
28
|
end
|
|
49
29
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
30
|
+
class << self
|
|
31
|
+
undef setup_commands
|
|
32
|
+
|
|
33
|
+
#
|
|
34
|
+
# Define a new event.
|
|
35
|
+
#
|
|
36
|
+
# @param [Symbol] event_name The name of the event.
|
|
37
|
+
# @param [Symbol] id The id of the event. Used to delete the event.
|
|
38
|
+
# @param [Hash] metadata Other metadata.
|
|
39
|
+
#
|
|
40
|
+
# @return [Discorb::Event] The event.
|
|
41
|
+
#
|
|
42
|
+
def event(event_name, id: nil, **metadata, &block)
|
|
43
|
+
raise ArgumentError, "Event name must be a symbol" unless event_name.is_a?(Symbol)
|
|
44
|
+
raise ArgumentError, "block must be given" unless block_given?
|
|
45
|
+
|
|
46
|
+
@events[event_name] ||= []
|
|
47
|
+
metadata[:extension] = self.name
|
|
48
|
+
@events[event_name] << [id, metadata, block]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
#
|
|
52
|
+
# Define a new once event.
|
|
53
|
+
#
|
|
54
|
+
# @param [Symbol] event_name The name of the event.
|
|
55
|
+
# @param [Symbol] id The id of the event. Used to delete the event.
|
|
56
|
+
# @param [Hash] metadata Other metadata.
|
|
57
|
+
# @param [Proc] block The block to execute when the event is triggered.
|
|
58
|
+
#
|
|
59
|
+
# @return [Discorb::Event] The event.
|
|
60
|
+
#
|
|
61
|
+
def once_event(event_name, id: nil, **metadata, &block)
|
|
62
|
+
event(event_name, id: id, once: true, **metadata, &block)
|
|
63
|
+
end
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
# @return [Hash{Symbol => Array<Discorb::Event>}] The events of the extension.
|
|
66
|
+
attr_reader :events
|
|
67
|
+
# @return [Array<Discorb::ApplicationCommand::Command>] The commands of the extension.
|
|
68
|
+
attr_reader :commands
|
|
69
|
+
# @private
|
|
70
|
+
attr_reader :bottom_commands
|
|
59
71
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
def inherited(klass)
|
|
73
|
+
klass.instance_variable_set(:@commands, [])
|
|
74
|
+
klass.instance_variable_set(:@bottom_commands, [])
|
|
75
|
+
klass.instance_variable_set(:@events, {})
|
|
76
|
+
end
|
|
64
77
|
end
|
|
65
78
|
end
|
|
66
79
|
end
|
data/lib/discorb/interaction.rb
CHANGED
|
@@ -255,7 +255,7 @@ module Discorb
|
|
|
255
255
|
def defer_update(ephemeral: false)
|
|
256
256
|
Async do
|
|
257
257
|
@client.http.post("/interactions/#{@id}/#{@token}/callback", {
|
|
258
|
-
type:
|
|
258
|
+
type: 6,
|
|
259
259
|
data: {
|
|
260
260
|
flags: (ephemeral ? 1 << 6 : 0),
|
|
261
261
|
},
|
|
@@ -310,7 +310,7 @@ module Discorb
|
|
|
310
310
|
payload[:components] = tmp_components.filter { |c| c.length.positive? }.map { |c| { type: 1, components: c.map(&:to_hash) } }
|
|
311
311
|
end
|
|
312
312
|
payload[:flags] = (ephemeral ? 1 << 6 : 0)
|
|
313
|
-
@client.http.post("/interactions/#{@id}/#{@token}/callback", { type:
|
|
313
|
+
@client.http.post("/interactions/#{@id}/#{@token}/callback", { type: 7, data: payload }).wait
|
|
314
314
|
end
|
|
315
315
|
end
|
|
316
316
|
end
|
|
@@ -460,6 +460,8 @@ module Discorb
|
|
|
460
460
|
include Interaction::UpdateResponse
|
|
461
461
|
# @return [String] The content of the response.
|
|
462
462
|
attr_reader :custom_id
|
|
463
|
+
# @return [Discorb::Message] The target message.
|
|
464
|
+
attr_reader :message
|
|
463
465
|
|
|
464
466
|
@interaction_type = 3
|
|
465
467
|
@interaction_name = :message_component
|
data/lib/discorb/modules.rb
CHANGED
|
@@ -37,26 +37,7 @@ module Discorb
|
|
|
37
37
|
payload[:allowed_mentions] =
|
|
38
38
|
allowed_mentions ? allowed_mentions.to_hash(@client.allowed_mentions) : @client.allowed_mentions.to_hash
|
|
39
39
|
payload[:message_reference] = reference.to_reference if reference
|
|
40
|
-
if components
|
|
41
|
-
tmp_components = []
|
|
42
|
-
tmp_row = []
|
|
43
|
-
components.each do |c|
|
|
44
|
-
case c
|
|
45
|
-
when Array
|
|
46
|
-
tmp_components << tmp_row
|
|
47
|
-
tmp_row = []
|
|
48
|
-
tmp_components << c
|
|
49
|
-
when SelectMenu
|
|
50
|
-
tmp_components << tmp_row
|
|
51
|
-
tmp_row = []
|
|
52
|
-
tmp_components << [c]
|
|
53
|
-
else
|
|
54
|
-
tmp_row << c
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
tmp_components << tmp_row
|
|
58
|
-
payload[:components] = tmp_components.filter { |c| c.length.positive? }.map { |c| { type: 1, components: c.map(&:to_hash) } }
|
|
59
|
-
end
|
|
40
|
+
payload[:components] = Component.to_payload(components) if components
|
|
60
41
|
files = [file] if file
|
|
61
42
|
if files
|
|
62
43
|
seperator, payload = HTTP.multipart(payload, files)
|
|
@@ -69,6 +50,8 @@ module Discorb
|
|
|
69
50
|
end
|
|
70
51
|
end
|
|
71
52
|
|
|
53
|
+
alias send_message post
|
|
54
|
+
|
|
72
55
|
#
|
|
73
56
|
# Edit a message.
|
|
74
57
|
# @macro async
|
|
@@ -95,27 +78,8 @@ module Discorb
|
|
|
95
78
|
payload[:embeds] = tmp_embed.map(&:to_hash) if tmp_embed
|
|
96
79
|
payload[:allowed_mentions] =
|
|
97
80
|
allowed_mentions ? allowed_mentions.to_hash(@client.allowed_mentions) : @client.allowed_mentions.to_hash
|
|
98
|
-
if components
|
|
99
|
-
|
|
100
|
-
tmp_row = []
|
|
101
|
-
components.each do |c|
|
|
102
|
-
case c
|
|
103
|
-
when Array
|
|
104
|
-
tmp_components << tmp_row
|
|
105
|
-
tmp_row = []
|
|
106
|
-
tmp_components << c
|
|
107
|
-
when SelectMenu
|
|
108
|
-
tmp_components << tmp_row
|
|
109
|
-
tmp_row = []
|
|
110
|
-
tmp_components << [c]
|
|
111
|
-
else
|
|
112
|
-
tmp_row << c
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
tmp_components << tmp_row
|
|
116
|
-
payload[:flags] = (supress ? 1 << 2 : 0) unless supress.nil?
|
|
117
|
-
payload[:components] = tmp_components.filter { |c| c.length.positive? }.map { |c| { type: 1, components: c.map(&:to_hash) } }
|
|
118
|
-
end
|
|
81
|
+
payload[:components] = Component.to_payload(components) if components
|
|
82
|
+
payload[:flags] = (supress ? 1 << 2 : 0) unless supress.nil?
|
|
119
83
|
@client.http.patch("/channels/#{channel_id.wait}/messages/#{message_id}", payload).wait
|
|
120
84
|
end
|
|
121
85
|
end
|
|
@@ -4,21 +4,41 @@ def build_version_sidebar(dir, version)
|
|
|
4
4
|
raw.gsub!(template, "")
|
|
5
5
|
res = +""
|
|
6
6
|
i = 0
|
|
7
|
-
`git tag
|
|
7
|
+
`git tag`
|
|
8
|
+
.force_encoding("utf-8")
|
|
9
|
+
.split("\n")
|
|
10
|
+
.sort_by { |v| Gem::Version.new(v[1..]) }
|
|
11
|
+
.reverse
|
|
12
|
+
.each.with_index do |tag|
|
|
8
13
|
i += 1
|
|
9
14
|
sha = `git rev-parse #{tag}`.force_encoding("utf-8").strip
|
|
10
|
-
|
|
15
|
+
tag_version = tag.delete_prefix("v")
|
|
11
16
|
cls = i % 2 == 0 ? "even" : "odd"
|
|
12
|
-
if
|
|
17
|
+
if tag_version == version
|
|
13
18
|
cls += " current"
|
|
14
19
|
end
|
|
15
|
-
res += template
|
|
20
|
+
res += template
|
|
21
|
+
.gsub("!version!", tag_version)
|
|
22
|
+
.gsub("!path!", "/" + tag_version)
|
|
23
|
+
.gsub("!class!", cls)
|
|
24
|
+
.gsub("!sha!", sha)
|
|
16
25
|
end
|
|
17
26
|
i += 1
|
|
18
27
|
cls = i % 2 == 0 ? "even" : "odd"
|
|
19
28
|
if version == "main"
|
|
20
29
|
cls += " current"
|
|
21
30
|
end
|
|
22
|
-
res
|
|
31
|
+
res.insert 0, template
|
|
32
|
+
.gsub("!version!", "main")
|
|
33
|
+
.gsub("!path!", "/main")
|
|
34
|
+
.gsub("!class!", cls)
|
|
35
|
+
.gsub("!sha!", "Latest on GitHub")
|
|
36
|
+
i += 1
|
|
37
|
+
cls = i % 2 == 0 ? "even" : "odd"
|
|
38
|
+
res.insert 0, template
|
|
39
|
+
.gsub("!version!", "Latest")
|
|
40
|
+
.gsub("!path!", "")
|
|
41
|
+
.gsub("!class!", cls)
|
|
42
|
+
.gsub("!sha!", "Latest on RubyGems")
|
|
23
43
|
File.write(dir + "/version_list.html", raw.gsub("<!--replace-->", res))
|
|
24
44
|
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.10.2
|
|
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-10-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: async
|
|
@@ -142,8 +142,8 @@ files:
|
|
|
142
142
|
- lib/discorb/error.rb
|
|
143
143
|
- lib/discorb/event.rb
|
|
144
144
|
- lib/discorb/exe/about.rb
|
|
145
|
-
- lib/discorb/exe/init.rb
|
|
146
145
|
- lib/discorb/exe/irb.rb
|
|
146
|
+
- lib/discorb/exe/new.rb
|
|
147
147
|
- lib/discorb/exe/run.rb
|
|
148
148
|
- lib/discorb/exe/setup.rb
|
|
149
149
|
- lib/discorb/exe/show.rb
|