discorb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +56 -0
  3. data/.yardopts +6 -0
  4. data/Changelog.md +5 -0
  5. data/Gemfile +23 -0
  6. data/Gemfile.lock +70 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +53 -0
  9. data/Rakefile +46 -0
  10. data/bin/console +15 -0
  11. data/bin/setup +8 -0
  12. data/discorb.gemspec +37 -0
  13. data/docs/Examples.md +26 -0
  14. data/docs/events.md +480 -0
  15. data/docs/voice_events.md +283 -0
  16. data/examples/components/authorization_button.rb +43 -0
  17. data/examples/components/select_menu.rb +61 -0
  18. data/examples/extension/main.rb +12 -0
  19. data/examples/extension/message_expander.rb +41 -0
  20. data/examples/simple/eval.rb +32 -0
  21. data/examples/simple/ping_pong.rb +16 -0
  22. data/examples/simple/rolepanel.rb +65 -0
  23. data/examples/simple/wait_for_message.rb +30 -0
  24. data/lib/discorb/application.rb +157 -0
  25. data/lib/discorb/asset.rb +57 -0
  26. data/lib/discorb/audit_logs.rb +323 -0
  27. data/lib/discorb/channel.rb +1101 -0
  28. data/lib/discorb/client.rb +363 -0
  29. data/lib/discorb/color.rb +173 -0
  30. data/lib/discorb/common.rb +123 -0
  31. data/lib/discorb/components.rb +290 -0
  32. data/lib/discorb/dictionary.rb +119 -0
  33. data/lib/discorb/embed.rb +345 -0
  34. data/lib/discorb/emoji.rb +218 -0
  35. data/lib/discorb/emoji_table.rb +3799 -0
  36. data/lib/discorb/error.rb +98 -0
  37. data/lib/discorb/event.rb +35 -0
  38. data/lib/discorb/extend.rb +18 -0
  39. data/lib/discorb/extension.rb +54 -0
  40. data/lib/discorb/file.rb +69 -0
  41. data/lib/discorb/flag.rb +109 -0
  42. data/lib/discorb/gateway.rb +967 -0
  43. data/lib/discorb/gateway_requests.rb +47 -0
  44. data/lib/discorb/guild.rb +1244 -0
  45. data/lib/discorb/guild_template.rb +211 -0
  46. data/lib/discorb/image.rb +43 -0
  47. data/lib/discorb/integration.rb +111 -0
  48. data/lib/discorb/intents.rb +137 -0
  49. data/lib/discorb/interaction.rb +333 -0
  50. data/lib/discorb/internet.rb +285 -0
  51. data/lib/discorb/invite.rb +145 -0
  52. data/lib/discorb/log.rb +70 -0
  53. data/lib/discorb/member.rb +232 -0
  54. data/lib/discorb/message.rb +583 -0
  55. data/lib/discorb/modules.rb +138 -0
  56. data/lib/discorb/permission.rb +270 -0
  57. data/lib/discorb/presence.rb +308 -0
  58. data/lib/discorb/reaction.rb +48 -0
  59. data/lib/discorb/role.rb +189 -0
  60. data/lib/discorb/sticker.rb +157 -0
  61. data/lib/discorb/user.rb +163 -0
  62. data/lib/discorb/utils.rb +16 -0
  63. data/lib/discorb/voice_state.rb +251 -0
  64. data/lib/discorb/webhook.rb +420 -0
  65. data/lib/discorb.rb +51 -0
  66. metadata +120 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ae7ec3df7c6da178e1ce924879cbda686fa17b1a3ad3858419ef2bf6f4bc9ada
4
+ data.tar.gz: f23eb8f8bc6acceacb33b555f38283297ff04140051c273a2ee26cf4c0fc50d4
5
+ SHA512:
6
+ metadata.gz: f43d25457a75adadc96f6d3d3304ea38956006888a03ef1159f6b1ce2e956167e283e540cf1e64dcb43c40774b6a8fcc63b0b1f76b2d2da1ebf574a16869153c
7
+ data.tar.gz: a6726842c6049171b02113947d430e96364021fbdcc5057d97feecb1d2a3f7866540c8327c2ad82e425a82cb8539ed7e2aa0a54ac4c1013593d2196630761fbb
data/.gitignore ADDED
@@ -0,0 +1,56 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ # Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
data/.yardopts ADDED
@@ -0,0 +1,6 @@
1
+ --protected
2
+ --no-private
3
+ --markup markdown
4
+ --tag flags:"Flags"
5
+ -
6
+ docs/*.md
data/Changelog.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## v0.0.1 - Initial release
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in discorb.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "async"
11
+ gem "async-http"
12
+ gem "async-websocket"
13
+
14
+ gem "mime-types", "~> 3.3"
15
+
16
+ group :debug, optional: true do
17
+ gem "rufo", "~> 0.13.0"
18
+ end
19
+
20
+ group :docs, optional: true do
21
+ gem "redcarpet"
22
+ gem "yard", "~> 0.9.26"
23
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,70 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ discorb (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ async (1.30.0)
10
+ console (~> 1.10)
11
+ nio4r (~> 2.3)
12
+ timers (~> 4.1)
13
+ async-http (0.56.5)
14
+ async (>= 1.25)
15
+ async-io (>= 1.28)
16
+ async-pool (>= 0.2)
17
+ protocol-http (~> 0.22.0)
18
+ protocol-http1 (~> 0.14.0)
19
+ protocol-http2 (~> 0.14.0)
20
+ async-io (1.32.2)
21
+ async
22
+ async-pool (0.3.8)
23
+ async (>= 1.25)
24
+ async-websocket (0.19.0)
25
+ async-http (~> 0.54)
26
+ async-io (~> 1.23)
27
+ protocol-websocket (~> 0.7.0)
28
+ colorize (0.8.1)
29
+ console (1.13.1)
30
+ fiber-local
31
+ fiber-local (1.0.0)
32
+ mime-types (3.3.1)
33
+ mime-types-data (~> 3.2015)
34
+ mime-types-data (3.2021.0704)
35
+ nio4r (2.5.7)
36
+ protocol-hpack (1.4.2)
37
+ protocol-http (0.22.5)
38
+ protocol-http1 (0.14.1)
39
+ protocol-http (~> 0.22)
40
+ protocol-http2 (0.14.2)
41
+ protocol-hpack (~> 1.4)
42
+ protocol-http (~> 0.18)
43
+ protocol-websocket (0.7.5)
44
+ protocol-http (~> 0.2)
45
+ protocol-http1 (~> 0.2)
46
+ rake (13.0.6)
47
+ redcarpet (3.5.1)
48
+ ricecream (0.2.0)
49
+ rufo (0.13.0)
50
+ timers (4.3.3)
51
+ yard (0.9.26)
52
+
53
+ PLATFORMS
54
+ x86-mingw32
55
+
56
+ DEPENDENCIES
57
+ async
58
+ async-http
59
+ async-websocket
60
+ colorize (~> 0.8.1)
61
+ discorb!
62
+ mime-types (~> 3.3)
63
+ rake (~> 13.0)
64
+ redcarpet
65
+ ricecream (~> 0.2.0)
66
+ rufo (~> 0.13.0)
67
+ yard (~> 0.9.26)
68
+
69
+ BUNDLED WITH
70
+ 2.2.22
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 sevenc-nanashi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # discorb
2
+ [![rubydoc](https://img.shields.io/badge/Document-rubydoc.info-blue.svg)](https://rubydoc.info/gems/discorb)
3
+ [![Gem](https://img.shields.io/gem/dt/discorb?logo=rubygems&logoColor=fff)](https://rubygems.org/gems/discorb)
4
+ [![Gem](https://img.shields.io/gem/v/discorb?logo=rubygems&logoColor=fff)](https://rubygems.org/gems/discorb)
5
+
6
+ discorb is a Discord API wrapper for Ruby.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'discorb'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle install
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install discorb
23
+
24
+ ## Usage
25
+
26
+ ### Simple ping-pong
27
+
28
+ ```ruby
29
+ require "discorb"
30
+
31
+ client = Discorb::Client.new
32
+
33
+ client.once :ready do
34
+ puts "Logged in as #{client.user}"
35
+ end
36
+
37
+ client.on :message do |_task, message|
38
+ next if message.author.bot?
39
+ next unless message.content == "ping"
40
+
41
+ message.channel.post("Pong!")
42
+ end
43
+
44
+ client.run(ENV["DISCORD_BOT_TOKEN"])
45
+ ```
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sevenc-nanashi/discorb.
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
5
+
6
+ task :emoji_table do
7
+ require_relative "lib/discorb"
8
+
9
+ res = {}
10
+ Discorb::EmojiTable::DISCORD_TO_UNICODE.each do |discord, unicode|
11
+ res[unicode] ||= []
12
+ res[unicode] << discord
13
+ end
14
+
15
+ res_text = +""
16
+ res.each do |unicode, discord|
17
+ res_text << %(#{unicode.unpack("C*").pack("C*").inspect} => %w[#{discord.join(" ")}],\n)
18
+ end
19
+
20
+ table_script = File.read("lib/discorb/emoji_table.rb")
21
+
22
+ table_script.gsub!(/(?<=UNICODE_TO_DISCORD = {\n)[\s\S]+(?=}\.freeze)/, res_text)
23
+
24
+ File.open("lib/discorb/emoji_table.rb", "w") do |f|
25
+ f.print(table_script)
26
+ end
27
+ `rubocop -A lib/discorb/emoji_table.rb`
28
+ puts "Successfully made emoji_table.rb"
29
+ end
30
+
31
+ task :format do
32
+ Dir.glob("**/*.rb").each do |file|
33
+ next if file.start_with?("vendor")
34
+
35
+ puts "Formatting #{file}"
36
+ `rufo ./#{file}`
37
+ content = ""
38
+ File.open(file, "rb") do |f|
39
+ content = f.read
40
+ end
41
+ content.gsub!("\r\n", "\n")
42
+ File.open(file, "wb") do |f|
43
+ f.print(content)
44
+ end
45
+ end
46
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'discorb'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/discorb.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/discorb/common"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "discorb"
7
+ spec.version = Discorb::VERSION
8
+ spec.authors = ["sevenc-nanashi"]
9
+ spec.email = ["sevenc-nanashi@sevenbot.jp"]
10
+
11
+ spec.summary = "discorb is a Discord API wrapper for Ruby."
12
+ spec.description = File.read(File.join(__dir__, "README.md"))
13
+ spec.homepage = "https://github.com/sevenc-nanashi/discorb"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
16
+
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/sevenc-nanashi/discorb"
21
+ spec.metadata["changelog_uri"] = "https://github.com/sevenc-nanashi/discorb/blob/main/Changelog.md"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ # spec.add_dependency "example-gem", "~> 1.0"
34
+
35
+ # For more information and examples about making a new gem, checkout our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ end
data/docs/Examples.md ADDED
@@ -0,0 +1,26 @@
1
+ # @title Examples
2
+
3
+ # Examples
4
+
5
+ ## Simple ping pong
6
+
7
+ {include:file:examples/simple/ping_pong.rb}
8
+
9
+ ## Wait for a message
10
+
11
+ {include:file:examples/simple/wait_for_message.rb}
12
+
13
+ ## Use components
14
+
15
+ ### Authorization button
16
+
17
+ {include:file:examples/components/authorization_button.rb}
18
+
19
+ ### Pagination with select menu
20
+
21
+ {include:file:examples/components/select_menu.rb}
22
+
23
+ #### Note
24
+
25
+ This example is not shown correctly in the docs.
26
+ [Read this example on GitHub](https://github.com/discorb-lib/discorb/blob/main/examples/components/select_menu.rb).
data/docs/events.md ADDED
@@ -0,0 +1,480 @@
1
+ # @title Events
2
+
3
+ # Events
4
+
5
+ ## How to use events
6
+
7
+ discorb uses event driven programming.
8
+ You can register event handlers with {Client#on}.
9
+ Alternatively, you can use {Client#once} to register a one-time event handler.
10
+
11
+ ```ruby
12
+ client.on :message do |_task, event|
13
+ puts event.message.content
14
+ end
15
+ ```
16
+
17
+ This example will print the content of every message received.
18
+
19
+ ## Event reference
20
+
21
+ ### Note
22
+
23
+ `Async::Task` object will be passed to the event handler in the first argument: `task`.
24
+
25
+ ### Client events
26
+
27
+ #### `event_receive(task, event_name, data)`
28
+ Fires when a event is received.
29
+
30
+ | Parameter | Type | Description |
31
+ | ---------- | ----- | ----------- |
32
+ |`event_name`| Symbol | The name of the event. |
33
+ |`data` | Hash | The data of the event. |
34
+
35
+ #### `ready(task)`
36
+
37
+ Fires when the client is ready.
38
+
39
+ #### `resumed(task)`
40
+
41
+ Fires when the client is resumed connection.
42
+
43
+ ### Guild events
44
+
45
+ #### `guild_join(task, guild)`
46
+
47
+ Fires when client joins a guild.
48
+
49
+ | Parameter | Type | Description |
50
+ | ---------- | ----- | ----------- |
51
+ |`guild` | {Discorb::Guild} | The guild that was joined. |
52
+
53
+ #### `guild_available(task, guild)`
54
+
55
+ Fires when a guild becomes available.
56
+
57
+ | Parameter | Type | Description |
58
+ | ---------- | ----- | ----------- |
59
+ |`guild` | {Discorb::Guild} | The guild that became available. |
60
+
61
+ #### `guild_update(task, before, after)`
62
+
63
+ Fires when client updates a guild.
64
+
65
+ | Parameter | Type | Description |
66
+ | ---------- | ----- | ----------- |
67
+ |`before` | {Discorb::Guild} | The guild before the update. |
68
+ |`after` | {Discorb::Guild} | The guild after the update. |
69
+
70
+ #### `guild_leave(task, guild)`
71
+
72
+ Fires when client leaves a guild.
73
+
74
+ | Parameter | Type | Description |
75
+ | ---------- | ----- | ----------- |
76
+ |`guild` | {Discorb::Guild} | The guild that was left. |
77
+
78
+ #### `guild_destroy(task, guild)`
79
+
80
+ Fires when guild is destroyed.
81
+
82
+ | Parameter | Type | Description |
83
+ | ---------- | ----- | ----------- |
84
+ |`guild` | {Discorb::Guild} | The guild that was destroyed. |
85
+
86
+ #### `guild_integrations_update(task, guild)`
87
+
88
+ Fires when guild integrations are updated.
89
+
90
+ | Parameter | Type | Description |
91
+ | ---------- | ----- | ----------- |
92
+ |`guild` | {Discorb::Guild} | The guild that integrations were updated for. |
93
+
94
+ #### `guild_ban_add(task, guild, user)`
95
+
96
+ Fires when a user is banned from a guild.
97
+
98
+
99
+ | Parameter | Type | Description |
100
+ | ---------- | ----- | ----------- |
101
+ |`guild` | {Discorb::Guild} | The guild that the user was banned from. |
102
+ |`user` | {Discorb::User} | The user that was banned. |
103
+
104
+ #### `guild_ban_remove(task, guild, user)`
105
+
106
+ Fires when a user is unbanned from a guild.
107
+
108
+ | Parameter | Type | Description |
109
+ | ---------- | ----- | ----------- |
110
+ |`guild` | {Discorb::Guild} | The guild that the user was unbanned from. |
111
+ |`user` | {Discorb::User} | The user that was unbanned. |
112
+
113
+ ### Channel events
114
+
115
+ #### `channel_create(task, channel)`
116
+
117
+ Fires when a channel is created.
118
+
119
+ | Parameter | Type | Description |
120
+ | ---------- | ----- | ----------- |
121
+ |`channel` | {Discorb::Channel} | The channel that was created. |
122
+
123
+ #### `channel_update(task, before, after)`
124
+
125
+ Fires when a channel is updated.
126
+
127
+ | Parameter | Type | Description |
128
+ | ---------- | ----- | ----------- |
129
+ |`before` | {Discorb::Channel} | The channel before the update. |
130
+ |`after` | {Discorb::Channel} | The channel after the update. |
131
+
132
+ #### `channel_delete(task, channel)`
133
+
134
+ Fires when a channel is deleted.
135
+
136
+ | Parameter | Type | Description |
137
+ | ---------- | ----- | ----------- |
138
+ |`channel` | {Discorb::Channel} | The channel that was deleted. |
139
+
140
+ #### `webhooks_update(task, event)`
141
+
142
+ Fires when a webhook is updated.
143
+
144
+ | Parameter | Type | Description |
145
+ | ---------- | ----- | ----------- |
146
+ |`event` | {Discorb::WebhooksUpdateEvent} | The webhook update event. |
147
+
148
+ #### `thread_new(task, thread)`
149
+
150
+ Fires when a thread is created.
151
+
152
+ | Parameter | Type | Description |
153
+ | ---------- | ----- | ----------- |
154
+ |`thread` | {Discorb::ThreadChannel} | The thread that was created. |
155
+
156
+ #### `thread_join(task, thread)`
157
+
158
+ Fires when client joins a thread.
159
+
160
+ | Parameter | Type | Description |
161
+ | ---------- | ----- | ----------- |
162
+ |`thread` | {Discorb::ThreadChannel} | The thread that was joined. |
163
+
164
+
165
+ #### `thread_delete(task, thread)`
166
+
167
+ Fires when a thread is deleted.
168
+
169
+ | Parameter | Type | Description |
170
+ | ---------- | ----- | ----------- |
171
+ |`thread` | {Discorb::ThreadChannel} | The thread that was deleted. |
172
+
173
+ #### `thread_update(task, before, after)`
174
+
175
+ Fires when a thread is updated.
176
+
177
+ | Parameter | Type | Description |
178
+ | ---------- | ----- | ----------- |
179
+ |`before` | {Discorb::ThreadChannel} | The thread before the update. |
180
+ |`after` | {Discorb::ThreadChannel} | The thread after the update. |
181
+
182
+ #### `thread_members_update(task, thread, added, removed)`
183
+
184
+ Fires when a thread's members are updated.
185
+
186
+ | Parameter | Type | Description |
187
+ | ---------- | ----- | ----------- |
188
+ |`thread` | {Discorb::ThreadChannel} | The thread that the members were updated for. |
189
+ |`added` | Array<{ThreadChannel::Member}> | An array of {Discorb::ThreadChannel::Member} objects that were added to the thread. |
190
+ |`removed` | Array<{ThreadChannel::Member}> | An array of {Discorb::ThreadChannel::Member} objects that were removed from the thread. |
191
+
192
+ #### `thread_member_update(task, before, after)`
193
+
194
+ Fires when a thread member is updated.
195
+
196
+ | Parameter | Type | Description |
197
+ | --------- | ----- | ----------- |
198
+ |`thread` | {Discorb::ThreadChannel} | The thread that the member was updated for. |
199
+ |`before` | {Discorb::ThreadChannel::Member} | The thread member before the update. |
200
+ |`after` | {Discorb::ThreadChannel::Member} | The thread member after the update. |
201
+
202
+ ### Integration events
203
+
204
+ #### `integration_create(task, integration)`
205
+
206
+ Fires when a guild integration is created.
207
+
208
+ | Parameter | Type | Description |
209
+ | ---------- | ----- | ----------- |
210
+ |`integration`| {Discorb::Integration}| The created integration. |
211
+
212
+ #### `integration_update(task, before, after)`
213
+
214
+ Fires when a guild integration is updated.
215
+
216
+
217
+ | Parameter | Type | Description |
218
+ | ---------- | ----- | ----------- |
219
+ |`before` | {Discorb::Integration}| The integration before the update. |
220
+ |`after` | {Discorb::Integration}| The integration after the update. |
221
+
222
+ #### `integration_delete(task, integration)`
223
+
224
+ Fires when a guild integration is deleted.
225
+
226
+ | Parameter | Type | Description |
227
+ | ---------- | ----- | ----------- |
228
+ |`integration`| {Discorb::Integration}| The deleted integration. |
229
+
230
+ ### Message events
231
+
232
+ #### `message(task, message)`
233
+
234
+ Fires when a message is created.
235
+
236
+ | Parameter | Type | Description |
237
+ | ---------- | ----- | ----------- |
238
+ |`message` | {Discorb::Message}| The created message. |
239
+
240
+ #### `message_update(task, event)`
241
+
242
+ Fires when a message is updated.
243
+
244
+ | Parameter | Type | Description |
245
+ | ---------- | ----- | ----------- |
246
+ |`event` | {Discorb::GatewayHandler::MessageUpdateEvent}| The message after the update. |
247
+
248
+ #### `message_delete(task, message, channel, guild)`
249
+
250
+ Fires when a message is deleted.
251
+
252
+ | Parameter | Type | Description |
253
+ | ---------- | ----- | ----------- |
254
+ |`message` | {Discorb::Message}| The deleted message. |
255
+ |`channel` | {Discorb::Channel}| The channel the message was deleted from. |
256
+ |`guild` | ?{Discorb::Guild} | The guild the message was deleted from. |
257
+
258
+ ##### Note
259
+
260
+ This will fire when cached messages are deleted.
261
+
262
+ #### `message_delete_id(task, message_id, channel, guild)`
263
+
264
+ Fires when a message is deleted.
265
+ Not like {#message_delete} this will fire even message is not cached.
266
+
267
+ | Parameter | Type | Description |
268
+ | ---------- | ----- | ----------- |
269
+ |`message_id`| {Discorb::Snowflake} | The deleted message ID. |
270
+ |`channel` | {Discorb::Channel}| The channel the message was deleted from. |
271
+ |`guild` | ?{Discorb::Guild} | The guild the message was deleted from. |
272
+
273
+ #### `message_delete_bulk(task, messages)`
274
+
275
+ Fires when a bulk of messages are deleted.
276
+
277
+ | Parameter | Type | Description |
278
+ | ---------- | ----- | ----------- |
279
+ |`messages` | Array<{Discorb::Message}, {Discorb::GatewayHandler::UnknownDeleteBulkMessage}> | The deleted messages. |
280
+
281
+ #### `message_pin_update(task, event)`
282
+
283
+ Fires when a message is pinned or unpinned.
284
+
285
+ | Parameter | Type | Description |
286
+ | ---------- | ----- | ----------- |
287
+ |`event` | {Discorb::GatewayHandler::MessagePinUpdateEvent}| The event object. |
288
+
289
+ #### `typing_start(task, event)`
290
+
291
+ Fires when a user starts typing.
292
+
293
+ | Parameter | Type | Description |
294
+ | --------- | ----- | ----------- |
295
+ |`event` | {Discorb::GatewayHandler::TypingStartEvent}| The event object. |
296
+
297
+ ### Reaction events
298
+
299
+ #### `reaction_add(task, event)`
300
+
301
+ Fires when a reaction is added to a message.
302
+
303
+ | Parameter | Type | Description |
304
+ | ---------- | ----- | ----------- |
305
+ |`event` | {Discorb::GatewayHandler::ReactionEvent}| The event object. |
306
+
307
+ #### `reaction_remove(task, event)`
308
+
309
+ Fires when someone removes a reaction from a message.
310
+
311
+ | Parameter | Type | Description |
312
+ | ---------- | ----- | ----------- |
313
+ |`event` | {Discorb::GatewayHandler::ReactionEvent}| The event object. |
314
+
315
+ #### `reaction_remove_all(task, event)`
316
+
317
+ Fires when all reactions are removed from a message.
318
+
319
+ | Parameter | Type | Description |
320
+ | ---------- | ----- | ----------- |
321
+ |`event` | {Discorb::GatewayHandler::ReactionRemoveAllEvent}| The event object. |
322
+
323
+ #### `reaction_remove_emoji(task, event)`
324
+
325
+ Fires when a reaction is removed from a message.
326
+
327
+ | Parameter | Type | Description |
328
+ | ---------- | ----- | ----------- |
329
+ |`event` | {Discorb::GatewayHandler::ReactionRemoveEmojiEvent}| The event object. |
330
+
331
+ ### Role events
332
+
333
+ #### `role_create(task, role)`
334
+
335
+ Fires when a role is created.
336
+
337
+ | Parameter | Type | Description |
338
+ | ---------- | ----- | ----------- |
339
+ |`role` | {Discorb::Role}| The created role. |
340
+
341
+ #### `role_update(task, before, after)`
342
+
343
+ Fires when a role is updated.
344
+
345
+ | Parameter | Type | Description |
346
+ | ---------- | ----- | ----------- |
347
+ |`before` | {Discorb::Role}| The role before the update. |
348
+ |`after` | {Discorb::Role}| The role after the update. |
349
+
350
+ #### `role_remove(task, role)`
351
+
352
+ Fires when a role is deleted.
353
+
354
+ | Parameter | Type | Description |
355
+ | ---------- | ----- | ----------- |
356
+ |`role` | {Discorb::Role}| The deleted role. |
357
+
358
+ ### Member events
359
+
360
+ #### Note
361
+
362
+ These events requires the `guild_members` intent.
363
+
364
+ #### `member_add(task, member)`
365
+
366
+ Fires when a member joins a guild.
367
+
368
+ | Parameter | Type | Description |
369
+ | ---------- | ----- | ----------- |
370
+ |`member` | {Discorb::Member}| The member that joined. |
371
+
372
+ #### `member_update(task, before, after)`
373
+
374
+ Fires when a member is updated.
375
+
376
+ | Parameter | Type | Description |
377
+ | ---------- | ----- | ----------- |
378
+ |`before` | {Discorb::Member}| The member before the update. |
379
+ |`after` | {Discorb::Member}| The member after the update. |
380
+
381
+ #### `member_remove(task, member)`
382
+
383
+ Fires when a member is removed from a guild.
384
+
385
+ | Parameter | Type | Description |
386
+ | ---------- | ----- | ----------- |
387
+ |`member` | {Discorb::Member}| The member that left. |
388
+
389
+ ### Role events
390
+
391
+ #### `role_create(task, role)`
392
+
393
+ Fires when a role is created.
394
+
395
+ | Parameter | Type | Description |
396
+ | ---------- | ----- | ----------- |
397
+ |`role` | {Discorb::Role}| The created role. |
398
+
399
+ #### `role_update(task, before, after)`
400
+
401
+ Fires when a role is updated.
402
+
403
+ | Parameter | Type | Description |
404
+ | ---------- | ----- | ----------- |
405
+ |`before` | {Discorb::Role}| The role before the update. |
406
+ |`after` | {Discorb::Role}| The role after the update. |
407
+
408
+ #### `role_remove(task, role)`
409
+
410
+ Fires when a role is deleted.
411
+
412
+ | Parameter | Type | Description |
413
+ | ---------- | ----- | ----------- |
414
+ |`role` | {Discorb::Role}| The deleted role. |
415
+
416
+ ### Invite events
417
+
418
+ #### `invite_create(task, invite)`
419
+
420
+ Fires when a invite is created.
421
+
422
+ | Parameter | Type | Description |
423
+ | ---------- | ----- | ----------- |
424
+ |`invite` | {Discorb::Invite}| The created invite. |
425
+
426
+ #### `invite_delete(task, invite)`
427
+
428
+ Fires when a invite is deleted.
429
+
430
+ | Parameter | Type | Description |
431
+ | ---------- | ----- | ----------- |
432
+ |`invite` | {Discorb::Invite}| The deleted invite. |
433
+
434
+ ### Interaction events
435
+
436
+ #### `button_click(task, interaction)`
437
+
438
+ Fires when a button is clicked.
439
+
440
+ | Parameter | Type | Description |
441
+ | ---------- | ----- | ----------- |
442
+ |`interaction`| {Discorb::MessageComponentInteraction::Button}| The interaction object. |
443
+
444
+ #### `select_menu_select(task, interaction)`
445
+
446
+ Fires when a select menu is selected.
447
+
448
+ | Parameter | Type | Description |
449
+ | ---------- | ----- | ----------- |
450
+ |`interaction`| {Discorb::MessageComponentInteraction::SelectMenu}| The interaction object. |
451
+
452
+ ### Voice events
453
+
454
+ It's too big, so they're documented in {file:docs/voice_events.md}
455
+
456
+ ### Low-level events
457
+
458
+ #### `guild_create(task, guild)`
459
+
460
+ Fires when `GUILD_CREATE` is received.
461
+
462
+ | Parameter | Type | Description |
463
+ | ---------- | ----- | ----------- |
464
+ |`guild` | {Discorb::Guild}| The guild of the event. |
465
+
466
+ #### `guild_delete(task, guild)`
467
+
468
+ Fires when `GUILD_DELETE` is received.
469
+
470
+ | Parameter | Type | Description |
471
+ | ---------- | ----- | ----------- |
472
+ |`guild` | {Discorb::Guild}| The guild of the event. |
473
+
474
+ #### `thread_create(task, thread)`
475
+
476
+ Fires when `THREAD_CREATE` is received.
477
+
478
+ | Parameter | Type | Description |
479
+ | ---------- | ----- | ----------- |
480
+ |`thread` | {Discorb::ThreadChannel}| The thread of the event. |