discorb 0.0.8 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b247a62629770b82d8326ac69507603a27bc8cf31bcf7c06a7aa9d546b7e80a
4
- data.tar.gz: ec2416663ce7d90e2023c648a115e6a2691f4557394770274dcf4a25489aad36
3
+ metadata.gz: 1381542f36d691bc8c16bbca477f7dbc034d18d4308c6e51689e02d766af9fac
4
+ data.tar.gz: 611e01c698fbb0c19f7a37cad66faddf5dfbba860b59dc2a140c3a3b7d85dd9e
5
5
  SHA512:
6
- metadata.gz: 511985823e749cec350e08f98cd9b7f05172d00fb02e63756b4c8dadd65657c9a68d775a1309190c14ec72c12ed955a6bfbd7bc23d55307fc90165b5a9d81c63
7
- data.tar.gz: ba547c5dc8a1558654ae860be8f426255bf633809acb82b853a14b72ffbbda9b58a6d0bc50c6e2b656233b08672ec78be07a4899436f5c90e162b3a06aa45c5f
6
+ metadata.gz: eab30f2c135c3a1dd63fc36cea26df4035f57da50e96fbc52e74d207248599dd0d50d7df9379bf20b906b128aa3e7abd47f637c7cd56662a991c7feb7cd7944e
7
+ data.tar.gz: e9b03bd76e066037ef98480c9952bbfe6a0d7d039199e5d2a804bac49e550d03b74c1596847e485f2ba13b935012c80fb39a356df21f0d154b981f705807a113
data/.yardopts CHANGED
@@ -3,4 +3,5 @@
3
3
  --markup markdown
4
4
  --tag flags:"Flags"
5
5
  -
6
- docs/*.md
6
+ docs/*.md
7
+ Changelog.md
data/Changelog.md CHANGED
@@ -14,4 +14,54 @@
14
14
 
15
15
  ## v0.0.4
16
16
 
17
- - Fix: Fix NoMethodError by webhook message
17
+ - Fix: Fix NoMethodError by webhook message
18
+ - Add: Add `#author` to webhook message
19
+ - Fix: Add `#bot?` to webhook author
20
+
21
+ ## v0.0.5
22
+
23
+ - Fix: Fix GitHub link
24
+ - Change: Internet to HTTP
25
+
26
+ ## v0.0.6
27
+
28
+ - Fix: Fix error in client without members intent
29
+ - Add: Add ThreadChannel::News
30
+ - Add: Add official discord link
31
+
32
+ ## v0.0.7
33
+
34
+ - Fix: Fix `member_xxx` event
35
+
36
+ ## 0.0.8
37
+
38
+ - Delete: Delete task parameter
39
+
40
+ ## 0.1.0
41
+
42
+ - Add: Add `User#created_at`
43
+ - Add: Add `Member#to_s_user`
44
+ - Add: Add `DefaultAvatar`
45
+ - Add: Support application commands
46
+ - Add: Add `Client#ping`
47
+ - Add: Allow `String` for `Embed#initialize`
48
+ - Change: Change log format
49
+
50
+ ## 0.2.0
51
+
52
+ - Fix: Fix unused dependency
53
+ - Add: Add `Client#close!`
54
+ - Add: Add discord-irb
55
+
56
+ ## 0.2.1
57
+
58
+ - Fix: Fix NoMethodError in reaction event
59
+ - Add: Add Changelog.md to document
60
+
61
+ ## 0.2.2 (yanked)
62
+
63
+ - Add: Add `Snowflake#to_str`
64
+
65
+ ## 0.2.3
66
+
67
+ - Fix: Fix critical error
data/Gemfile CHANGED
@@ -7,12 +7,6 @@ gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
9
 
10
- gem "async"
11
- gem "async-http"
12
- gem "async-websocket"
13
-
14
- gem "mime-types", "~> 3.3"
15
-
16
10
  group :debug, optional: true do
17
11
  gem "rufo", "~> 0.13.0"
18
12
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- discorb (0.0.8)
4
+ discorb (0.2.3)
5
5
  async
6
6
  async-http
7
7
  async-websocket
@@ -10,7 +10,7 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- async (1.30.0)
13
+ async (1.30.1)
14
14
  console (~> 1.10)
15
15
  nio4r (~> 2.3)
16
16
  timers (~> 4.1)
@@ -56,11 +56,7 @@ PLATFORMS
56
56
  x86-mingw32
57
57
 
58
58
  DEPENDENCIES
59
- async
60
- async-http
61
- async-websocket
62
59
  discorb!
63
- mime-types (~> 3.3)
64
60
  rake (~> 13.0)
65
61
  redcarpet
66
62
  rufo (~> 0.13.0)
@@ -0,0 +1,251 @@
1
+ # @title Application Commands
2
+
3
+ # Application Commands
4
+
5
+ ## What is an application command?
6
+
7
+ > Application commands are commands that an application can register to Discord. They provide users a first-class way of interacting directly with your application that feels deeply integrated into Discord.
8
+
9
+ From: [Discord API docs](https://discord.com/developers/docs/interactions/application-commands#application-commands)
10
+
11
+ ## How do I register an application command?
12
+
13
+ Use {Discorb::Command::Handler#slash}, {Discorb::Command::Handler#group} for slash commands, {Discorb::Command::Handler#user_command} for user menu commands, and {Discorb::Command::Handler#message_command} for message menu commands.
14
+
15
+ ### Note
16
+
17
+ To register a global command, it will take 1 hour to be registered.
18
+ Guild commands will be registered immediately.
19
+
20
+ ### Register Slash Commands
21
+
22
+ This example registers a slash command that says "Hello, world!" when the user types `/hello`.
23
+
24
+ ```ruby
25
+ require "discorb"
26
+
27
+ client = Discorb::Client.new
28
+
29
+ client.slash("hello", "Greet for you") do |interaction|
30
+ interaction.post("Hello World!", ephemeral: true)
31
+ end
32
+
33
+ client.run(ENV["DISCORD_BOT_TOKEN"])
34
+ ```
35
+
36
+ {Discorb::Command::Handler#slash} takes 5 arguments:
37
+
38
+ | Argument | Description |
39
+ |---------|-------------|
40
+ | `command_name` | The name of the command. |
41
+ | `description` | The description of the command. |
42
+ | `options` | A hash of options. |
43
+ | `guild_ids` | The ID of the guild to register the command in. |
44
+ | `block` | A block that will be called when the command is invoked. |
45
+
46
+ In `options`, hash should be like this:
47
+
48
+ ```ruby
49
+ {
50
+ "Name" => {
51
+ type: :string,
52
+ required: true,
53
+ description: "The description of the command."
54
+ }
55
+ }
56
+ ```
57
+
58
+ | Key | Description |
59
+ | --- | --- |
60
+ | `type` | The type of the argument. |
61
+ | `required` | Whether the argument is required. |
62
+ | `description` | The description of the argument. |
63
+ | `choices` | The choices of the argument. |
64
+
65
+ `choices` should be unspecified if you don't want to use it.
66
+ `choices` is hash like this:
67
+
68
+ ```ruby
69
+ {
70
+ "vocaloid" => {
71
+ required: true,
72
+ description: "The vocaloid which you like."
73
+ type: :string,
74
+ choices: {
75
+ "Hatsune Miku" => "miku",
76
+ "Kagamine Rin" => "rin",
77
+ "Kagamine Len" => "len",
78
+ "Megurine Luka" => "luka",
79
+ "MEIKO" => "meiko",
80
+ "KAITO" => "kaito",
81
+ }
82
+ }
83
+ }
84
+
85
+ # Note: This aritcle is written in 8/31.
86
+ ```
87
+
88
+ The key will be displayed in the user menu, and the value will be used as the argument.
89
+
90
+ In `type`, You must use one of the following:
91
+
92
+ | Name | Description | Aliases|
93
+ | --- | --- | --- |
94
+ | `:string` | String argument. | `:str` |
95
+ | `:integer` | Integer argument. | `:int` |
96
+ | `:float` | Float argument. | None |
97
+ | `:boolean` | Boolean argument. | `:bool` |
98
+ | `:user` | User argument. | `:member` |
99
+ | `:channel` | Channel argument. | None |
100
+ | `:role` | Role argument. | None |
101
+
102
+ ### Group Slash Commands
103
+
104
+ To register a group of slash commands, use {Discorb::Command::Handler#slash_group}.
105
+
106
+ ```ruby
107
+ group = client.slash_group("settings", "Set settings of bot.")
108
+
109
+ group.slash("message_expand", "Whether bot should expand message.", {
110
+ "enabled" => {
111
+ type: :boolean,
112
+ description: "Whether bot should expand message."
113
+ }
114
+ }) do |interaction|
115
+ # ...
116
+ end
117
+
118
+ group.slash("bump_alert", "Whether bot should notify DISBOARD bump.", {
119
+ "enabled" => {
120
+ type: :boolean,
121
+ description: "Whether bot should notify DISBOARD bump."
122
+ }
123
+ }) do |interaction|
124
+ # ...
125
+ end
126
+ ```
127
+
128
+ You can make subcommand group by using {Discorb::Command::GroupCommand#group}.
129
+
130
+ ```ruby
131
+ group = client.slash_group("permission", "Set/Get command permissions.")
132
+
133
+ group_user = group.group("user", "Set/Get user's command permissions.")
134
+
135
+ group_user.slash("set", "Set user's command permissions.", {
136
+ "user_id" => {
137
+ type: :user,
138
+ description: "The user."
139
+ },
140
+ "value" => {
141
+ type: :boolean,
142
+ description: "Whether the user can use the command."
143
+ }
144
+ }) do |interaction, user|
145
+ # ...
146
+ end
147
+
148
+ group_user.slash("get", "Set user's command permissions.", {
149
+ "user_id" => {
150
+ type: :user,
151
+ description: "The user."
152
+ },
153
+ }) do |interaction, user|
154
+ # ...
155
+ end
156
+
157
+ group_user = group.group("user", "Set/Get user's command permissions.")
158
+
159
+ group_user.slash("set", "Set user's command permissions.", {
160
+ "user_id" => {
161
+ type: :user,
162
+ description: "The user."
163
+ },
164
+ "value" => {
165
+ type: :boolean,
166
+ description: "Whether the user can use the command."
167
+ }
168
+ }) do |interaction, user|
169
+ # ...
170
+ end
171
+
172
+ group_user.slash("get", "Set user's command permissions.", {
173
+ "user_id" => {
174
+ type: :user,
175
+ description: "The user."
176
+ },
177
+ }) do |interaction, user|
178
+ # ...
179
+ end
180
+
181
+ group_role = group.group("role", "Set/Get role's command permissions.")
182
+
183
+ group_role.slash("set", "Set role's command permissions.", {
184
+ "role_id" => {
185
+ type: :role,
186
+ description: "The role."
187
+ },
188
+ "value" => {
189
+ type: :boolean,
190
+ description: "Whether the role can use the command."
191
+ }
192
+ }) do |interaction, role|
193
+ # ...
194
+ end
195
+
196
+ group_role.slash("get", "Set role's command permissions.", {
197
+ "role_id" => {
198
+ type: :role,
199
+ description: "The role."
200
+ },
201
+ }) do |interaction, role|
202
+ # ...
203
+ end
204
+
205
+ ```
206
+
207
+ ### Register User Context Menu Command
208
+
209
+ ```ruby
210
+ client.user_command("hello") do |interaction, user|
211
+ interaction.post("Hello, #{user.name}!")
212
+ end
213
+ ```
214
+ {Discorb::Command::Handler#user_command} takes 3 arguments:
215
+
216
+ | Parameter | Description |
217
+ | --- | --- |
218
+ | `command_name` | The name of the command. |
219
+ | `guild_ids` | The ID of the guild to register the command in. |
220
+ | `block` | A block that will be called when the command is invoked. |
221
+
222
+ `block` will be called with two arguments:
223
+
224
+ | Parameter | Description |
225
+ | --- | --- |
226
+ | `interaction` | The interaction object. |
227
+ | `user` | The user object. |
228
+
229
+
230
+ ### Register Message Context Menu Command
231
+
232
+ ```ruby
233
+ client.message_command("Bookmark") do |interaction, message|
234
+ # ...
235
+ end
236
+ ```
237
+
238
+ {Discorb::Command::Handler#message_command} takes 3 arguments:
239
+
240
+ | Parameter | Description |
241
+ | --- | --- |
242
+ | `command_name` | The name of the command. |
243
+ | `guild_ids` | The ID of the guild to register the command in. |
244
+ | `block` | A block that will be called when the command is invoked. |
245
+
246
+ `block` will be called with two arguments:
247
+
248
+ | Parameter | Description |
249
+ | --- | --- |
250
+ | `interaction` | The interaction object. |
251
+ | `message` | The message object. |
@@ -0,0 +1,39 @@
1
+ # @title discord-irb
2
+
3
+ # discord-irb
4
+
5
+ discord-irb is a command line tool for interacting with the Discord API.
6
+
7
+
8
+ ## Usage
9
+
10
+ ```
11
+ $ bundle exec discord-irb
12
+ ```
13
+
14
+ To start.
15
+
16
+ ### Load a token
17
+
18
+ discord-irb will load a token from...
19
+ 1. the `DISCORD_BOT_TOKEN` environment variable
20
+ 2. the `DISCORD_TOKEN` environment variable
21
+ 3. `token` file in the current directory(customizable with `-f` option)
22
+ 4. your input
23
+
24
+ ### Arguments
25
+
26
+ #### `-i`, `--intents`
27
+
28
+ Intents to use.
29
+ Specify intents with integers.
30
+
31
+ #### `-t`, `--token-file`
32
+
33
+ Token file to load.
34
+
35
+ ### Variables
36
+
37
+ #### `message`
38
+
39
+ Last message received.
data/docs/events.md CHANGED
@@ -28,11 +28,11 @@ Fires when a event is received.
28
28
  |`event_name`| Symbol | The name of the event. |
29
29
  |`data` | Hash | The data of the event. |
30
30
 
31
- #### `ready(task)`
31
+ #### `ready()`
32
32
 
33
33
  Fires when the client is ready.
34
34
 
35
- #### `resumed(task)`
35
+ #### `resumed()`
36
36
 
37
37
  Fires when the client is resumed connection.
38
38
 
@@ -239,7 +239,7 @@ Fires when a message is updated.
239
239
 
240
240
  | Parameter | Type | Description |
241
241
  | ---------- | ----- | ----------- |
242
- |`event` | {Discorb::GatewayHandler::MessageUpdateEvent}| The message after the update. |
242
+ |`event` | {Discorb::Gateway::MessageUpdateEvent}| The message after the update. |
243
243
 
244
244
  #### `message_delete(message, channel, guild)`
245
245
 
@@ -272,7 +272,7 @@ Fires when a bulk of messages are deleted.
272
272
 
273
273
  | Parameter | Type | Description |
274
274
  | ---------- | ----- | ----------- |
275
- |`messages` | Array<{Discorb::Message}, {Discorb::GatewayHandler::UnknownDeleteBulkMessage}> | The deleted messages. |
275
+ |`messages` | Array<{Discorb::Message}, {Discorb::Gateway::UnknownDeleteBulkMessage}> | The deleted messages. |
276
276
 
277
277
  #### `message_pin_update(event)`
278
278
 
@@ -280,7 +280,7 @@ Fires when a message is pinned or unpinned.
280
280
 
281
281
  | Parameter | Type | Description |
282
282
  | ---------- | ----- | ----------- |
283
- |`event` | {Discorb::GatewayHandler::MessagePinUpdateEvent}| The event object. |
283
+ |`event` | {Discorb::Gateway::MessagePinUpdateEvent}| The event object. |
284
284
 
285
285
  #### `typing_start(event)`
286
286
 
@@ -288,7 +288,7 @@ Fires when a user starts typing.
288
288
 
289
289
  | Parameter | Type | Description |
290
290
  | --------- | ----- | ----------- |
291
- |`event` | {Discorb::GatewayHandler::TypingStartEvent}| The event object. |
291
+ |`event` | {Discorb::Gateway::TypingStartEvent}| The event object. |
292
292
 
293
293
  ### Reaction events
294
294
 
@@ -298,7 +298,7 @@ Fires when a reaction is added to a message.
298
298
 
299
299
  | Parameter | Type | Description |
300
300
  | ---------- | ----- | ----------- |
301
- |`event` | {Discorb::GatewayHandler::ReactionEvent}| The event object. |
301
+ |`event` | {Discorb::Gateway::ReactionEvent}| The event object. |
302
302
 
303
303
  #### `reaction_remove(event)`
304
304
 
@@ -306,7 +306,7 @@ Fires when someone removes a reaction from a message.
306
306
 
307
307
  | Parameter | Type | Description |
308
308
  | ---------- | ----- | ----------- |
309
- |`event` | {Discorb::GatewayHandler::ReactionEvent}| The event object. |
309
+ |`event` | {Discorb::Gateway::ReactionEvent}| The event object. |
310
310
 
311
311
  #### `reaction_remove_all(event)`
312
312
 
@@ -314,7 +314,7 @@ Fires when all reactions are removed from a message.
314
314
 
315
315
  | Parameter | Type | Description |
316
316
  | ---------- | ----- | ----------- |
317
- |`event` | {Discorb::GatewayHandler::ReactionRemoveAllEvent}| The event object. |
317
+ |`event` | {Discorb::Gateway::ReactionRemoveAllEvent}| The event object. |
318
318
 
319
319
  #### `reaction_remove_emoji(event)`
320
320
 
@@ -322,7 +322,7 @@ Fires when a reaction is removed from a message.
322
322
 
323
323
  | Parameter | Type | Description |
324
324
  | ---------- | ----- | ----------- |
325
- |`event` | {Discorb::GatewayHandler::ReactionRemoveEmojiEvent}| The event object. |
325
+ |`event` | {Discorb::Gateway::ReactionRemoveEmojiEvent}| The event object. |
326
326
 
327
327
  ### Role events
328
328