discorb 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build_version.yml +53 -0
- data/Changelog.md +35 -1
- data/README.md +1 -1
- data/docs/cli/init.md +15 -1
- data/docs/events.md +8 -4
- data/docs/tutorial.md +1 -1
- data/examples/commands/bookmarker.rb +1 -1
- data/examples/commands/inspect.rb +1 -1
- data/examples/components/authorization_button.rb +1 -1
- data/examples/components/select_menu.rb +1 -1
- data/examples/extension/main.rb +1 -1
- data/examples/simple/eval.rb +1 -1
- data/examples/simple/ping_pong.rb +1 -1
- data/examples/simple/rolepanel.rb +1 -1
- data/examples/simple/wait_for_message.rb +1 -1
- data/lib/discorb/client.rb +4 -1
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/error.rb +3 -1
- data/lib/discorb/exe/init.rb +59 -2
- data/lib/discorb/exe/irb.rb +1 -1
- data/lib/discorb/flag.rb +1 -0
- data/lib/discorb/gateway.rb +70 -35
- data/lib/discorb/guild.rb +33 -1
- data/lib/discorb/http.rb +4 -3
- data/lib/discorb/integration.rb +1 -1
- data/lib/discorb/intents.rb +7 -3
- data/lib/discorb/member.rb +12 -1
- data/po/yard.pot +1 -1
- data/sig/discorb.rbs +7217 -7217
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb2e5dd94a2bda9644a1a5679fdab3006bbdb1b10c8bf3780764b7fc115aa002
|
4
|
+
data.tar.gz: 4bfd645c6e39a4f3bd48ed2b2afaaccc8c2cf5702eb6dc675cfb01b17667b09f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c18b4e0b809e66350c952a8d50cb2e4f899e2844cd33b43bfd6120cc4560c6889e2cc8015fe9729ecb84c1af26a434ac566f69baa1a58cfcc5b6e2232b41151
|
7
|
+
data.tar.gz: de89179dffd53f575e148c2240d278eb101dde91f8f2288c9cefcae403eb4ce2f04547a030bebb3912d33df639e8e516c92878d6eb1fe1650cde8dc4c6903d25
|
@@ -0,0 +1,53 @@
|
|
1
|
+
name: Build YARD by version
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
push:
|
6
|
+
tags:
|
7
|
+
- "v*"
|
8
|
+
jobs:
|
9
|
+
main:
|
10
|
+
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
with:
|
16
|
+
fetch-depth: 0
|
17
|
+
- name: Set up Ruby
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: 3.0.2
|
21
|
+
bundler-cache: true
|
22
|
+
- name: Set up git settings
|
23
|
+
run: |
|
24
|
+
git config --global user.email "action@github.com"
|
25
|
+
git config --global user.name "GitHub Action"
|
26
|
+
- name: Clone pages
|
27
|
+
env:
|
28
|
+
SSH_SECRET: ${{ secrets.SSH }}
|
29
|
+
GIT_SSH_COMMAND: ssh -i ~/ssh_secret
|
30
|
+
run: |
|
31
|
+
echo "$SSH_SECRET" > ~/ssh_secret
|
32
|
+
chmod 600 ~/ssh_secret
|
33
|
+
git clone git@github.com:discorb-lib/discorb-lib.github.io /tmp/pages
|
34
|
+
- name: Install dependencies
|
35
|
+
run: |
|
36
|
+
bundle config --local with 'docs'
|
37
|
+
bundle install
|
38
|
+
- name: Generate document
|
39
|
+
run: bundle exec rake document:build_all
|
40
|
+
- name: Push document
|
41
|
+
env:
|
42
|
+
SSH_SECRET: ${{ secrets.SSH }}
|
43
|
+
GIT_SSH_COMMAND: ssh -i ~/ssh_secret
|
44
|
+
run: |
|
45
|
+
echo "$SSH_SECRET" > ~/ssh_secret
|
46
|
+
chmod 600 ~/ssh_secret
|
47
|
+
cp -r ./doc/. /tmp/pages
|
48
|
+
cd /tmp/pages
|
49
|
+
git add -A
|
50
|
+
git commit -m "Update: Update document"
|
51
|
+
git update-ref -d refs/remotes/origin/user
|
52
|
+
git push origin main -f
|
53
|
+
continue-on-error: true
|
data/Changelog.md
CHANGED
@@ -177,4 +177,38 @@ end
|
|
177
177
|
|
178
178
|
## 0.7.1
|
179
179
|
|
180
|
-
- Fix: Fix error of responding to interaction
|
180
|
+
- Fix: Fix error of responding to interaction
|
181
|
+
|
182
|
+
## 0.7.2
|
183
|
+
|
184
|
+
- Add: Add `Member#owner?`
|
185
|
+
- Fix: Fix `Member#permissions`
|
186
|
+
- Add: Add `Member#guild_permissions` as alias of `Member#permissions`
|
187
|
+
- Add: Add default role to `Member#roles`
|
188
|
+
- Fix: Fix error in `Integration#_set_data`
|
189
|
+
- Change: Reverse `Member#roles`
|
190
|
+
|
191
|
+
## 0.7.3
|
192
|
+
|
193
|
+
- Add: Improve `discorb init`
|
194
|
+
|
195
|
+
## 0.7.4 (yanked)
|
196
|
+
|
197
|
+
- Fix: Fix disconnected client
|
198
|
+
|
199
|
+
## 0.7.5 (yanked)
|
200
|
+
|
201
|
+
- Fix: Fix critical error
|
202
|
+
|
203
|
+
## 0.7.6
|
204
|
+
|
205
|
+
- Fix: Fix heartbeating error
|
206
|
+
|
207
|
+
## 0.8.0
|
208
|
+
|
209
|
+
- Add: Add `Guild#fetch_members`
|
210
|
+
- Add: Add `Guild#fetch_member_list` as alias of `Guild#fetch_members`
|
211
|
+
- Add: Add `Intents#to_h`
|
212
|
+
- Add: Add `fetch_member` parameter to `Client#initialize`; Note you should set `false` if your bot doesn't have `GUILD_MEMBERS` intent
|
213
|
+
- Change: Change `ready` to `standby` event
|
214
|
+
- Change: `ready` will be fired when client receives `READY` event
|
data/README.md
CHANGED
data/docs/cli/init.md
CHANGED
@@ -32,6 +32,18 @@ If true, the command will initialize git and commit the initial files with commi
|
|
32
32
|
Use `git commit --amend -m "..."` to change the commit message.
|
33
33
|
Default to false.
|
34
34
|
|
35
|
+
### `--[no-]desc`
|
36
|
+
|
37
|
+
Whether to create a description file.
|
38
|
+
If true, the command will create a `.env.sample` and `README.md` file.
|
39
|
+
Default to false.
|
40
|
+
|
41
|
+
### `-n` `--name`
|
42
|
+
|
43
|
+
The name of the project.
|
44
|
+
It will be used in the `README.md` file.
|
45
|
+
Default to the directory name.
|
46
|
+
|
35
47
|
### `-t`, `--token`
|
36
48
|
|
37
49
|
The name of token environment variable.
|
@@ -49,7 +61,9 @@ The following files will be created:
|
|
49
61
|
| File | Description |
|
50
62
|
| ---- | ----------- |
|
51
63
|
| `.env` | Environment variables. |
|
64
|
+
| `main.rb` | Main script. |
|
52
65
|
| `.gitignore` | Git ignore file. Won't be created if `--git` is false. |
|
53
66
|
| `Gemfile` | Gemfile. Won't be created if `--bundle` is false. |
|
54
67
|
| `Gemfile.lock` | Gemfile lock file. Won't be created if `--bundle` is false. |
|
55
|
-
| `
|
68
|
+
| `README.md` | Readme file. Won't be created if `--desc` is false. |
|
69
|
+
| `.env.sample` | Sample environment variables. Won't be created if `--desc` is false. |
|
data/docs/events.md
CHANGED
@@ -22,7 +22,7 @@ Since v0.2.5, you can also register event handlers by adding a method to the cli
|
|
22
22
|
client = Discorb::Client.new
|
23
23
|
|
24
24
|
class << client
|
25
|
-
def
|
25
|
+
def on_standby
|
26
26
|
puts "Ready!"
|
27
27
|
end
|
28
28
|
end
|
@@ -43,7 +43,7 @@ end
|
|
43
43
|
```
|
44
44
|
|
45
45
|
This example will print `Override!`, but not `This event handler is overrideable!`.
|
46
|
-
This is useful for registering event handlers
|
46
|
+
This is useful for registering event handlers as default behaviour, such as error handlers.
|
47
47
|
|
48
48
|
```ruby
|
49
49
|
# In the library...
|
@@ -55,7 +55,7 @@ end
|
|
55
55
|
# In your code...
|
56
56
|
|
57
57
|
client.on :command_error do |event, error|
|
58
|
-
event.message.reply "An error occurred while executing
|
58
|
+
event.message.reply "An error occurred while executing the command!\n#{error.full_message}"
|
59
59
|
end
|
60
60
|
```
|
61
61
|
|
@@ -73,7 +73,11 @@ Fires when a event is received.
|
|
73
73
|
|
74
74
|
#### `ready()`
|
75
75
|
|
76
|
-
Fires when the client
|
76
|
+
Fires when the client receives the `READY` event.
|
77
|
+
|
78
|
+
#### `standby()`
|
79
|
+
|
80
|
+
Fires when the client is standby. (When the client connects to Discord, and has cached guilds and members.)
|
77
81
|
|
78
82
|
#### `resumed()`
|
79
83
|
|
data/docs/tutorial.md
CHANGED
@@ -101,7 +101,7 @@ Dotenv.load # Loads .env file
|
|
101
101
|
|
102
102
|
client = Discorb::Client.new # Create client for connecting to Discord
|
103
103
|
|
104
|
-
client.once :
|
104
|
+
client.once :standby do
|
105
105
|
puts "Logged in as #{client.user}" # Prints username of logged in user
|
106
106
|
end
|
107
107
|
|
data/examples/extension/main.rb
CHANGED
data/examples/simple/eval.rb
CHANGED
data/lib/discorb/client.rb
CHANGED
@@ -64,11 +64,13 @@ module Discorb
|
|
64
64
|
# @param [Boolean] colorize_log Whether to colorize the log.
|
65
65
|
# @param [:debug, :info, :warn, :error, :critical] log_level The log level.
|
66
66
|
# @param [Boolean] wait_until_ready Whether to delay event dispatch until ready.
|
67
|
+
# @param [Boolean] fetch_member Whether to fetch member on ready. This may slow down the client.
|
68
|
+
# Defaultly, it's `false` if {Discorb::Intents#members} is false. Otherwise, it's `true`.
|
67
69
|
#
|
68
70
|
def initialize(
|
69
71
|
allowed_mentions: nil, intents: nil, message_caches: 1000,
|
70
72
|
log: nil, colorize_log: false, log_level: :info,
|
71
|
-
wait_until_ready: true
|
73
|
+
wait_until_ready: true, fetch_member: nil
|
72
74
|
)
|
73
75
|
@allowed_mentions = allowed_mentions || AllowedMentions.new(everyone: true, roles: true, users: true)
|
74
76
|
@intents = (intents or Intents.default)
|
@@ -91,6 +93,7 @@ module Discorb
|
|
91
93
|
@commands = []
|
92
94
|
@bottom_commands = []
|
93
95
|
@status = :initialized
|
96
|
+
@fetch_member = fetch_member.nil? ? !(intents&.members) : fetch_member
|
94
97
|
set_default_events
|
95
98
|
end
|
96
99
|
|
data/lib/discorb/common.rb
CHANGED
@@ -4,7 +4,7 @@ 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.8.0"
|
8
8
|
# @return [String] The user agent for the bot.
|
9
9
|
USER_AGENT = "DiscordBot (https://github.com/discorb-lib/discorb #{VERSION}) Ruby/#{RUBY_VERSION}"
|
10
10
|
|
data/lib/discorb/error.rb
CHANGED
@@ -92,10 +92,12 @@ module Discorb
|
|
92
92
|
def initialize(resp, client)
|
93
93
|
@client = client
|
94
94
|
@client.close!
|
95
|
-
|
95
|
+
message = <<~MESSAGE
|
96
96
|
The client is banned from CloudFlare.
|
97
97
|
Hint: Try to decrease the number of requests per second, e.g. Use sleep in between requests.
|
98
98
|
MESSAGE
|
99
|
+
$stderr.puts message
|
100
|
+
DiscorbError.instance_method(:initialize).bind(self).call(message)
|
99
101
|
end
|
100
102
|
end
|
101
103
|
|
data/lib/discorb/exe/init.rb
CHANGED
@@ -16,7 +16,7 @@ FILES = {
|
|
16
16
|
|
17
17
|
client = Discorb::Client.new # Create client for connecting to Discord
|
18
18
|
|
19
|
-
client.once :
|
19
|
+
client.once :standby do
|
20
20
|
puts "Logged in as #{client.user}" # Prints username of logged in user
|
21
21
|
end
|
22
22
|
|
@@ -96,11 +96,46 @@ FILES = {
|
|
96
96
|
gem "discorb", "~> #{Discorb::VERSION}"
|
97
97
|
gem "dotenv", "~> 2.7"
|
98
98
|
RUBY
|
99
|
+
".env.sample" => <<~BASH,
|
100
|
+
%<token>s=
|
101
|
+
BASH
|
102
|
+
"README.md" => <<~MARKDOWN,
|
103
|
+
# %<name>s
|
104
|
+
|
105
|
+
Welcome to your bot: %<name>s!
|
106
|
+
|
107
|
+
TODO: Write your bot's description here.
|
108
|
+
|
109
|
+
## Usage
|
110
|
+
|
111
|
+
TODO: Write your bot's usage here.
|
112
|
+
|
113
|
+
## Features
|
114
|
+
|
115
|
+
TODO: Write your bot's features here.
|
116
|
+
|
117
|
+
## How to host
|
118
|
+
|
119
|
+
1. Clone the repository.
|
120
|
+
2. Run `bundle install`.
|
121
|
+
3. Get your bot's token from the Discord developer portal.
|
122
|
+
4. Copy `.env.sample` to `.env` and fill in the token.
|
123
|
+
5. Run `bundle exec discorb run`.
|
124
|
+
|
125
|
+
TODO: Write your own customizations here.
|
126
|
+
|
127
|
+
## License
|
128
|
+
|
129
|
+
TODO: Write your bot's license here.
|
130
|
+
See https://choosealicense.com/ for more information.
|
131
|
+
https://rubygems.org/gems/license-cli may be useful.
|
132
|
+
|
133
|
+
MARKDOWN
|
99
134
|
}
|
100
135
|
|
101
136
|
# @!visibility private
|
102
137
|
def create_file(name)
|
103
|
-
File.write($path + "/#{name}", format(FILES[name], token: $values[:token]), mode: "wb")
|
138
|
+
File.write($path + "/#{name}", format(FILES[name], token: $values[:token], name: $values[:name]), mode: "wb")
|
104
139
|
end
|
105
140
|
|
106
141
|
# @!visibility private
|
@@ -132,6 +167,14 @@ def git_init
|
|
132
167
|
" to change commit message of initial commit.\n"
|
133
168
|
end
|
134
169
|
|
170
|
+
# @!visibility private
|
171
|
+
def make_descs
|
172
|
+
iputs "Making descriptions..."
|
173
|
+
create_file(".env.sample")
|
174
|
+
create_file("README.md")
|
175
|
+
sputs "Made descriptions.\n"
|
176
|
+
end
|
177
|
+
|
135
178
|
opt = OptionParser.new <<~BANNER
|
136
179
|
A tool to make a new project.
|
137
180
|
|
@@ -145,6 +188,8 @@ $values = {
|
|
145
188
|
git: false,
|
146
189
|
force: false,
|
147
190
|
token: "TOKEN",
|
191
|
+
descs: false,
|
192
|
+
name: nil,
|
148
193
|
}
|
149
194
|
|
150
195
|
opt.on("--[no-]bundle", "Whether to use bundle. Default to true.") do |v|
|
@@ -155,10 +200,18 @@ opt.on("--[no-]git", "Whether to initialize git. Default to false.") do |v|
|
|
155
200
|
$values[:git] = v
|
156
201
|
end
|
157
202
|
|
203
|
+
opt.on("--[no-]descs", "Whether to put some file for description. Default to false.") do |v|
|
204
|
+
$values[:descs] = v
|
205
|
+
end
|
206
|
+
|
158
207
|
opt.on("-t NAME", "--token NAME", "The name of token environment variable. Default to TOKEN.") do |v|
|
159
208
|
$values[:token] = v
|
160
209
|
end
|
161
210
|
|
211
|
+
opt.on("-n NAME", "--name NAME", "The name of your project. Default to the directory name.") do |v|
|
212
|
+
$values[:name] = v
|
213
|
+
end
|
214
|
+
|
162
215
|
opt.on("-f", "--force", "Whether to force use directory. Default to false.") do |v|
|
163
216
|
$values[:force] = v
|
164
217
|
end
|
@@ -187,10 +240,14 @@ if (dir = ARGV[0])
|
|
187
240
|
Dir.chdir($path)
|
188
241
|
end
|
189
242
|
|
243
|
+
$values[:name] ||= Dir.pwd.split("/").last
|
244
|
+
|
190
245
|
bundle_init if $values[:bundle]
|
191
246
|
|
192
247
|
make_files
|
193
248
|
|
194
249
|
git_init if $values[:git]
|
195
250
|
|
251
|
+
make_descs if $values[:descs]
|
252
|
+
|
196
253
|
sputs "\nSuccessfully made a new project at \e[32m#{$path}\e[92m."
|
data/lib/discorb/exe/irb.rb
CHANGED
data/lib/discorb/flag.rb
CHANGED
data/lib/discorb/gateway.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require "async/http"
|
4
4
|
require "async/websocket"
|
5
|
+
require "async/barrier"
|
6
|
+
require "async/semaphore"
|
5
7
|
require "json"
|
6
8
|
require "zlib"
|
7
9
|
|
@@ -488,7 +490,7 @@ module Discorb
|
|
488
490
|
_, gateway_response = @http.get("/gateway").wait
|
489
491
|
gateway_url = gateway_response[:url]
|
490
492
|
endpoint = Async::HTTP::Endpoint.parse("#{gateway_url}?v=9&encoding=json&compress=zlib-stream",
|
491
|
-
|
493
|
+
alpn_protocols: Async::HTTP::Protocol::HTTP11.names)
|
492
494
|
begin
|
493
495
|
Async::WebSocket::Client.connect(endpoint, headers: [["User-Agent", Discorb::USER_AGENT]], handler: RawConnection) do |connection|
|
494
496
|
@connection = connection
|
@@ -510,7 +512,9 @@ module Discorb
|
|
510
512
|
raise ClientError.new("Authentication failed."), cause: nil
|
511
513
|
when "Discord WebSocket requesting client reconnect."
|
512
514
|
@log.info "Discord WebSocket requesting client reconnect"
|
513
|
-
|
515
|
+
connect_gateway(false)
|
516
|
+
else
|
517
|
+
@log.error "Discord WebSocket closed: #{e.message}"
|
514
518
|
connect_gateway(false)
|
515
519
|
end
|
516
520
|
rescue EOFError, Async::Wrapper::Cancelled
|
@@ -579,15 +583,18 @@ module Discorb
|
|
579
583
|
end
|
580
584
|
end
|
581
585
|
|
582
|
-
def handle_heartbeat
|
586
|
+
def handle_heartbeat
|
583
587
|
Async do |task|
|
588
|
+
interval = @heartbeat_interval
|
584
589
|
sleep((interval / 1000.0 - 1) * rand)
|
585
590
|
loop do
|
586
|
-
@
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
+
unless @connection.closed?
|
592
|
+
@heartbeat_before = Time.now.to_f
|
593
|
+
@connection.write({ op: 1, d: @last_s }.to_json)
|
594
|
+
@connection.flush
|
595
|
+
@log.debug "Sent opcode 1."
|
596
|
+
@log.debug "Waiting for heartbeat."
|
597
|
+
end
|
591
598
|
sleep(interval / 1000.0 - 1)
|
592
599
|
end
|
593
600
|
end
|
@@ -605,19 +612,17 @@ module Discorb
|
|
605
612
|
@user = ClientUser.new(self, data[:user])
|
606
613
|
@uncached_guilds = data[:guilds].map { |g| g[:id] }
|
607
614
|
if @uncached_guilds == [] or !@intents.guilds
|
608
|
-
|
609
|
-
dispatch(:ready)
|
610
|
-
@log.info("Successfully connected to Discord.")
|
615
|
+
ready
|
611
616
|
end
|
612
|
-
|
617
|
+
dispatch(:ready)
|
618
|
+
@tasks << handle_heartbeat
|
613
619
|
when "GUILD_CREATE"
|
614
620
|
if @uncached_guilds.include?(data[:id])
|
615
621
|
Guild.new(self, data, true)
|
616
622
|
@uncached_guilds.delete(data[:id])
|
617
623
|
if @uncached_guilds == []
|
618
|
-
@
|
619
|
-
|
620
|
-
@log.info("Successfully connected to Discord, and cached all guilds.")
|
624
|
+
@log.debug "All guilds cached"
|
625
|
+
ready
|
621
626
|
end
|
622
627
|
elsif @guilds.has?(data[:id])
|
623
628
|
@guilds[data[:id]].send(:_set_data, data)
|
@@ -839,12 +844,12 @@ module Discorb
|
|
839
844
|
dispatch(:voice_state_update, old, current)
|
840
845
|
if old&.channel != current&.channel
|
841
846
|
dispatch(:voice_channel_update, old, current)
|
842
|
-
case [old&.channel
|
843
|
-
|
847
|
+
case [old&.channel.nil?, current&.channel.nil?]
|
848
|
+
when [true, false]
|
844
849
|
dispatch(:voice_channel_connect, current)
|
845
|
-
|
850
|
+
when [false, true]
|
846
851
|
dispatch(:voice_channel_disconnect, old)
|
847
|
-
|
852
|
+
when [false, false]
|
848
853
|
dispatch(:voice_channel_move, old, current)
|
849
854
|
end
|
850
855
|
end
|
@@ -980,9 +985,9 @@ module Discorb
|
|
980
985
|
dispatch(:reaction_add, ReactionEvent.new(self, data))
|
981
986
|
when "MESSAGE_REACTION_REMOVE"
|
982
987
|
if (target_message = @messages[data[:message_id]]) &&
|
983
|
-
|
984
|
-
|
985
|
-
|
988
|
+
(target_reaction = target_message.reactions.find do |r|
|
989
|
+
data[:emoji][:id].nil? ? r.emoji.name == data[:emoji][:name] : r.emoji.id == data[:emoji][:id]
|
990
|
+
end)
|
986
991
|
target_reaction.instance_variable_set(:@count, target_reaction.count - 1)
|
987
992
|
target_message.reactions.delete(target_reaction) if target_reaction.count.zero?
|
988
993
|
end
|
@@ -994,7 +999,7 @@ module Discorb
|
|
994
999
|
dispatch(:reaction_remove_all, ReactionRemoveAllEvent.new(self, data))
|
995
1000
|
when "MESSAGE_REACTION_REMOVE_EMOJI"
|
996
1001
|
if (target_message = @messages[data[:message_id]]) &&
|
997
|
-
|
1002
|
+
(target_reaction = target_message.reactions.find { |r| data[:emoji][:id].nil? ? r.name == data[:emoji][:name] : r.id == data[:emoji][:id] })
|
998
1003
|
target_message.reactions.delete(target_reaction)
|
999
1004
|
end
|
1000
1005
|
dispatch(:reaction_remove_emoji, ReactionRemoveEmojiEvent.new(data))
|
@@ -1016,26 +1021,56 @@ module Discorb
|
|
1016
1021
|
end
|
1017
1022
|
end
|
1018
1023
|
end
|
1024
|
+
|
1025
|
+
def ready
|
1026
|
+
Async do
|
1027
|
+
if @fetch_member
|
1028
|
+
@log.debug "Fetching members"
|
1029
|
+
barrier = Async::Barrier.new
|
1030
|
+
semaphore = Async::Semaphore.new(@guilds.length)
|
1031
|
+
|
1032
|
+
@guilds.each do |guild|
|
1033
|
+
semaphore.async(parent: barrier) do
|
1034
|
+
guild.fetch_members
|
1035
|
+
end
|
1036
|
+
end
|
1037
|
+
semaphore.__send__(:wait)
|
1038
|
+
end
|
1039
|
+
@ready = true
|
1040
|
+
dispatch(:standby)
|
1041
|
+
@log.info("Client is ready!")
|
1042
|
+
end
|
1043
|
+
end
|
1019
1044
|
end
|
1020
|
-
|
1045
|
+
|
1021
1046
|
#
|
1022
1047
|
# A class for connecting websocket with raw bytes data.
|
1023
1048
|
# @private
|
1024
1049
|
#
|
1025
|
-
class RawConnection < Async::WebSocket::Connection
|
1026
|
-
def initialize(
|
1050
|
+
class RawConnection < Async::WebSocket::Connection
|
1051
|
+
def initialize(*, **)
|
1052
|
+
super
|
1053
|
+
@closed = false
|
1054
|
+
end
|
1055
|
+
|
1056
|
+
def closed?
|
1057
|
+
@closed
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
def close
|
1027
1061
|
super
|
1062
|
+
@closed = true
|
1028
1063
|
end
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1064
|
+
|
1065
|
+
def parse(buffer)
|
1066
|
+
# noop
|
1032
1067
|
buffer.to_s
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1068
|
+
end
|
1069
|
+
|
1070
|
+
def dump(object)
|
1071
|
+
# noop
|
1037
1072
|
object.to_s
|
1038
|
-
|
1073
|
+
end
|
1039
1074
|
end
|
1040
1075
|
end
|
1041
|
-
end
|
1076
|
+
end
|