discorb 0.16.0 → 0.17.0
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/.gitattributes +1 -0
- data/.github/workflows/build_main.yml +2 -2
- data/.github/workflows/build_version.yml +1 -1
- data/.github/workflows/codeql-analysis.yml +1 -1
- data/.github/workflows/lint-push.yml +3 -5
- data/.github/workflows/lint.yml +1 -1
- data/.github/workflows/spec.yml +30 -0
- data/.lefthook/commit-msg/validator.rb +5 -0
- data/.rspec +2 -0
- data/.rspec_parallel +2 -0
- data/.rubocop.yml +43 -6
- data/Changelog.md +14 -1
- data/Gemfile +14 -8
- data/Rakefile +41 -26
- data/bin/console +3 -3
- data/docs/Examples.md +1 -1
- data/docs/application_command.md +138 -46
- data/docs/cli/irb.md +2 -2
- data/docs/cli/new.md +14 -9
- data/docs/cli/run.md +7 -11
- data/docs/cli.md +17 -10
- data/docs/events.md +209 -211
- data/docs/extension.md +1 -2
- data/docs/faq.md +0 -1
- data/docs/tutorial.md +12 -12
- data/docs/voice_events.md +106 -106
- data/examples/commands/message.rb +63 -0
- data/examples/commands/permission.rb +18 -0
- data/examples/commands/slash.rb +44 -0
- data/examples/commands/user.rb +51 -0
- data/examples/components/authorization_button.rb +2 -2
- data/examples/components/select_menu.rb +2 -2
- data/examples/extension/main.rb +1 -1
- data/examples/extension/message_expander.rb +5 -2
- data/examples/simple/eval.rb +2 -2
- data/examples/simple/ping_pong.rb +1 -1
- data/examples/simple/rolepanel.rb +1 -1
- data/examples/simple/shard.rb +1 -1
- data/examples/simple/wait_for_message.rb +1 -1
- data/exe/discorb +31 -16
- data/lefthook.yml +45 -0
- data/lib/discorb/allowed_mentions.rb +1 -0
- data/lib/discorb/app_command/command.rb +127 -65
- data/lib/discorb/app_command/common.rb +25 -0
- data/lib/discorb/app_command/handler.rb +115 -33
- data/lib/discorb/app_command.rb +2 -1
- data/lib/discorb/application.rb +1 -0
- data/lib/discorb/asset.rb +1 -2
- data/lib/discorb/attachment.rb +1 -1
- data/lib/discorb/audit_logs.rb +11 -8
- data/lib/discorb/channel/base.rb +108 -0
- data/lib/discorb/channel/category.rb +32 -0
- data/lib/discorb/channel/container.rb +44 -0
- data/lib/discorb/channel/dm.rb +28 -0
- data/lib/discorb/channel/guild.rb +245 -0
- data/lib/discorb/channel/stage.rb +140 -0
- data/lib/discorb/channel/text.rb +345 -0
- data/lib/discorb/channel/thread.rb +321 -0
- data/lib/discorb/channel/voice.rb +79 -0
- data/lib/discorb/channel.rb +2 -1165
- data/lib/discorb/client.rb +38 -26
- data/lib/discorb/common.rb +2 -1
- data/lib/discorb/components/button.rb +2 -1
- data/lib/discorb/components/select_menu.rb +4 -2
- data/lib/discorb/components/text_input.rb +12 -2
- data/lib/discorb/components.rb +1 -1
- data/lib/discorb/embed.rb +22 -7
- data/lib/discorb/emoji.rb +30 -3
- data/lib/discorb/emoji_table.rb +4969 -3
- data/lib/discorb/event.rb +29 -4
- data/lib/discorb/exe/about.rb +1 -0
- data/lib/discorb/exe/irb.rb +2 -4
- data/lib/discorb/exe/new.rb +90 -23
- data/lib/discorb/exe/run.rb +8 -22
- data/lib/discorb/exe/setup.rb +25 -12
- data/lib/discorb/exe/show.rb +4 -3
- data/lib/discorb/extend.rb +1 -0
- data/lib/discorb/extension.rb +6 -3
- data/lib/discorb/flag.rb +11 -0
- data/lib/discorb/gateway.rb +67 -19
- data/lib/discorb/guild.rb +188 -56
- data/lib/discorb/guild_template.rb +10 -4
- data/lib/discorb/http.rb +16 -9
- data/lib/discorb/integration.rb +4 -1
- data/lib/discorb/intents.rb +1 -1
- data/lib/discorb/interaction/autocomplete.rb +28 -16
- data/lib/discorb/interaction/command.rb +36 -12
- data/lib/discorb/interaction/components.rb +5 -2
- data/lib/discorb/interaction/modal.rb +0 -1
- data/lib/discorb/interaction/response.rb +61 -22
- data/lib/discorb/interaction/root.rb +13 -13
- data/lib/discorb/interaction.rb +1 -0
- data/lib/discorb/invite.rb +5 -2
- data/lib/discorb/member.rb +25 -5
- data/lib/discorb/message.rb +47 -14
- data/lib/discorb/message_meta.rb +1 -0
- data/lib/discorb/modules.rb +56 -14
- data/lib/discorb/presence.rb +2 -2
- data/lib/discorb/rate_limit.rb +7 -2
- data/lib/discorb/reaction.rb +4 -4
- data/lib/discorb/role.rb +19 -4
- data/lib/discorb/shard.rb +1 -1
- data/lib/discorb/sticker.rb +8 -7
- data/lib/discorb/user.rb +2 -1
- data/lib/discorb/utils/colored_puts.rb +1 -0
- data/lib/discorb/voice_state.rb +10 -6
- data/lib/discorb/webhook.rb +36 -24
- data/lib/discorb.rb +5 -3
- data/po/yard.pot +9 -9
- data/sig/discorb.rbs +7232 -7235
- metadata +21 -5
- data/examples/commands/bookmarker.rb +0 -42
- data/examples/commands/hello.rb +0 -10
- data/examples/commands/inspect.rb +0 -25
data/docs/extension.md
CHANGED
data/docs/faq.md
CHANGED
data/docs/tutorial.md
CHANGED
|
@@ -11,21 +11,21 @@ Let's get started!
|
|
|
11
11
|
|
|
12
12
|
- Ruby 3.0.0+
|
|
13
13
|
- Basic knowledge of ruby
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
These documents will help you:
|
|
15
|
+
- [Ruby in Twenty Minutes](https://www.ruby-lang.org/en/documentation/quickstart/)
|
|
16
|
+
- [Ruby from other languages](https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/)
|
|
17
|
+
- [Try ruby!](https://try.ruby-lang.org/)
|
|
18
18
|
|
|
19
19
|
### Recommended
|
|
20
20
|
|
|
21
21
|
- Good editor
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
They are recommended:
|
|
23
|
+
- [VSCode](https://code.visualstudio.com/)
|
|
24
|
+
- [Atom](https://atom.io/)
|
|
25
|
+
- [Sublime Text](https://www.sublimetext.com/)
|
|
26
|
+
- [Brackets](https://brackets.io/)
|
|
27
|
+
- [Notepad++](https://notepad-plus-plus.org/)
|
|
28
|
+
- [Vim](https://www.vim.org/)
|
|
29
29
|
- Git
|
|
30
30
|
- Bundler
|
|
31
31
|
|
|
@@ -160,7 +160,7 @@ end
|
|
|
160
160
|
|
|
161
161
|
Save your bot and restart it.
|
|
162
162
|
|
|
163
|
-
You can see your bot's response by typing `hello` in your server...
|
|
163
|
+
You can see your bot's response by typing `hello` in your server...
|
|
164
164
|
|
|
165
165
|

|
|
166
166
|
|
data/docs/voice_events.md
CHANGED
|
@@ -10,35 +10,35 @@
|
|
|
10
10
|
|
|
11
11
|
Fires when someone joins a voice channel.
|
|
12
12
|
|
|
13
|
-
| Parameter | Type
|
|
14
|
-
|
|
|
15
|
-
| state
|
|
13
|
+
| Parameter | Type | Description |
|
|
14
|
+
| --------- | --------------------- | ---------------------------------------- |
|
|
15
|
+
| state | {Discorb::VoiceState} | The voice state of the user that joined. |
|
|
16
16
|
|
|
17
17
|
#### `voice_channel_disconnect(state)`
|
|
18
18
|
|
|
19
19
|
Fires when someone leaves a voice channel.
|
|
20
20
|
|
|
21
|
-
| Parameter | Type
|
|
22
|
-
|
|
|
23
|
-
| state
|
|
21
|
+
| Parameter | Type | Description |
|
|
22
|
+
| --------- | --------------------- | -------------------------------------- |
|
|
23
|
+
| state | {Discorb::VoiceState} | The voice state of the user that left. |
|
|
24
24
|
|
|
25
25
|
#### `voice_channel_move(before, after)`
|
|
26
26
|
|
|
27
27
|
Fires when someone moves to a different voice channel.
|
|
28
28
|
|
|
29
|
-
| Parameter | Type
|
|
30
|
-
|
|
|
31
|
-
| before
|
|
32
|
-
| after
|
|
29
|
+
| Parameter | Type | Description |
|
|
30
|
+
| --------- | --------------------- | -------------------------------------------- |
|
|
31
|
+
| before | {Discorb::VoiceState} | The voice state of the user before the move. |
|
|
32
|
+
| after | {Discorb::VoiceState} | The voice state of the user after the move. |
|
|
33
33
|
|
|
34
34
|
#### `voice_channel_update(before, after)`
|
|
35
35
|
|
|
36
36
|
Fires when a voice channel is connected, disconnected, or updated.
|
|
37
37
|
|
|
38
|
-
| Parameter | Type
|
|
39
|
-
|
|
|
40
|
-
| before
|
|
41
|
-
| after
|
|
38
|
+
| Parameter | Type | Description |
|
|
39
|
+
| --------- | --------------------- | ---------------------------------- |
|
|
40
|
+
| before | {Discorb::VoiceState} | The voice state before the update. |
|
|
41
|
+
| after | {Discorb::VoiceState} | The voice state after the update. |
|
|
42
42
|
|
|
43
43
|
### Mute Events
|
|
44
44
|
|
|
@@ -46,76 +46,76 @@ Fires when a voice channel is connected, disconnected, or updated.
|
|
|
46
46
|
|
|
47
47
|
Fires when a user's voice mute is disabled.
|
|
48
48
|
|
|
49
|
-
| Parameter | Type
|
|
50
|
-
|
|
|
51
|
-
| `state`
|
|
49
|
+
| Parameter | Type | Description |
|
|
50
|
+
| --------- | --------------------- | ---------------- |
|
|
51
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
52
52
|
|
|
53
53
|
#### `voice_mute_enable(state)`
|
|
54
54
|
|
|
55
55
|
Fires when a user's voice mute is enabled.
|
|
56
56
|
|
|
57
|
-
| Parameter | Type
|
|
58
|
-
|
|
|
59
|
-
| `state`
|
|
57
|
+
| Parameter | Type | Description |
|
|
58
|
+
| --------- | --------------------- | ---------------- |
|
|
59
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
60
60
|
|
|
61
61
|
#### `voice_mute_update(before, after)`
|
|
62
62
|
|
|
63
63
|
Fires when a user's voice mute is enabled or disabled.
|
|
64
64
|
|
|
65
|
-
| Parameter | Type
|
|
66
|
-
|
|
|
67
|
-
| `before`
|
|
68
|
-
| `after`
|
|
65
|
+
| Parameter | Type | Description |
|
|
66
|
+
| --------- | --------------------- | ---------------------------------- |
|
|
67
|
+
| `before` | {Discorb::VoiceState} | The voice state before the update. |
|
|
68
|
+
| `after` | {Discorb::VoiceState} | The voice state after the update. |
|
|
69
69
|
|
|
70
70
|
#### `voice_server_mute_enable(state)`
|
|
71
71
|
|
|
72
72
|
Fires when a user's server voice mute is enabled.
|
|
73
73
|
|
|
74
|
-
| Parameter | Type
|
|
75
|
-
|
|
|
76
|
-
| `state`
|
|
74
|
+
| Parameter | Type | Description |
|
|
75
|
+
| --------- | --------------------- | ---------------- |
|
|
76
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
77
77
|
|
|
78
78
|
#### `voice_server_mute_disable(state)`
|
|
79
79
|
|
|
80
80
|
Fires when a user's server voice mute is disabled.
|
|
81
81
|
|
|
82
|
-
| Parameter | Type
|
|
83
|
-
|
|
|
84
|
-
| `state`
|
|
82
|
+
| Parameter | Type | Description |
|
|
83
|
+
| --------- | --------------------- | ---------------- |
|
|
84
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
85
85
|
|
|
86
86
|
#### `voice_server_mute_update(before, after)`
|
|
87
87
|
|
|
88
88
|
Fires when a user's server voice mute is enabled or disabled.
|
|
89
89
|
|
|
90
|
-
| Parameter | Type
|
|
91
|
-
|
|
|
92
|
-
| `before`
|
|
93
|
-
| `after`
|
|
90
|
+
| Parameter | Type | Description |
|
|
91
|
+
| --------- | --------------------- | ---------------------------------- |
|
|
92
|
+
| `before` | {Discorb::VoiceState} | The voice state before the update. |
|
|
93
|
+
| `after` | {Discorb::VoiceState} | The voice state after the update. |
|
|
94
94
|
|
|
95
95
|
#### `voice_self_mute_enable(state)`
|
|
96
96
|
|
|
97
97
|
Fires when a user's self voice mute is enabled.
|
|
98
98
|
|
|
99
|
-
| Parameter | Type
|
|
100
|
-
|
|
|
101
|
-
| `state`
|
|
99
|
+
| Parameter | Type | Description |
|
|
100
|
+
| --------- | --------------------- | ---------------- |
|
|
101
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
102
102
|
|
|
103
103
|
#### `voice_self_mute_disable(state)`
|
|
104
104
|
|
|
105
105
|
Fires when a user's self voice mute is disabled.
|
|
106
106
|
|
|
107
|
-
| Parameter | Type
|
|
108
|
-
|
|
|
109
|
-
| `state`
|
|
107
|
+
| Parameter | Type | Description |
|
|
108
|
+
| --------- | --------------------- | ---------------- |
|
|
109
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
110
110
|
|
|
111
111
|
#### `voice_self_mute_update(before, after)`
|
|
112
112
|
|
|
113
113
|
Fires when a user's self voice mute is enabled or disabled.
|
|
114
114
|
|
|
115
|
-
| Parameter | Type
|
|
116
|
-
|
|
|
117
|
-
| `before`
|
|
118
|
-
| `after`
|
|
115
|
+
| Parameter | Type | Description |
|
|
116
|
+
| --------- | --------------------- | ---------------------------------- |
|
|
117
|
+
| `before` | {Discorb::VoiceState} | The voice state before the update. |
|
|
118
|
+
| `after` | {Discorb::VoiceState} | The voice state after the update. |
|
|
119
119
|
|
|
120
120
|
### Deaf Events
|
|
121
121
|
|
|
@@ -123,74 +123,74 @@ Fires when a user's self voice mute is enabled or disabled.
|
|
|
123
123
|
|
|
124
124
|
Fires when a user's voice deaf is enabled.
|
|
125
125
|
|
|
126
|
-
| Parameter | Type
|
|
127
|
-
|
|
|
128
|
-
| `state`
|
|
126
|
+
| Parameter | Type | Description |
|
|
127
|
+
| --------- | --------------------- | ---------------- |
|
|
128
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
129
129
|
|
|
130
130
|
#### `voice_deaf_disable(state)`
|
|
131
131
|
|
|
132
132
|
Fires when a user's voice deaf is disabled.
|
|
133
133
|
|
|
134
|
-
| Parameter | Type
|
|
135
|
-
|
|
|
136
|
-
| `state`
|
|
134
|
+
| Parameter | Type | Description |
|
|
135
|
+
| --------- | --------------------- | ---------------- |
|
|
136
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
137
137
|
|
|
138
138
|
#### `voice_deaf_update(before, after)`
|
|
139
139
|
|
|
140
140
|
Fires when a user's voice deaf is enabled or disabled.
|
|
141
141
|
|
|
142
|
-
| Parameter | Type
|
|
143
|
-
|
|
|
144
|
-
| `before`
|
|
145
|
-
| `after`
|
|
142
|
+
| Parameter | Type | Description |
|
|
143
|
+
| --------- | --------------------- | ---------------------------------- |
|
|
144
|
+
| `before` | {Discorb::VoiceState} | The voice state before the update. |
|
|
145
|
+
| `after` | {Discorb::VoiceState} | The voice state after the update. |
|
|
146
146
|
|
|
147
147
|
#### `voice_server_deaf_enable(state)`
|
|
148
148
|
|
|
149
149
|
Fires when a user's server voice deaf is enabled.
|
|
150
150
|
|
|
151
|
-
| Parameter | Type
|
|
152
|
-
|
|
|
153
|
-
| `state`
|
|
151
|
+
| Parameter | Type | Description |
|
|
152
|
+
| --------- | --------------------- | ---------------- |
|
|
153
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
154
154
|
|
|
155
155
|
#### `voice_server_deaf_disable(state)`
|
|
156
156
|
|
|
157
157
|
Fires when a user's server voice deaf is disabled.
|
|
158
158
|
|
|
159
|
-
| Parameter | Type
|
|
160
|
-
|
|
|
161
|
-
| `state`
|
|
159
|
+
| Parameter | Type | Description |
|
|
160
|
+
| --------- | --------------------- | ---------------- |
|
|
161
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
162
162
|
|
|
163
163
|
#### `voice_server_deaf_update(before, after)`
|
|
164
164
|
|
|
165
165
|
Fires when a user's server voice deaf is enabled or disabled.
|
|
166
166
|
|
|
167
|
-
| Parameter | Type
|
|
168
|
-
|
|
|
169
|
-
| `before`
|
|
170
|
-
| `after`
|
|
167
|
+
| Parameter | Type | Description |
|
|
168
|
+
| --------- | --------------------- | ---------------------------------- |
|
|
169
|
+
| `before` | {Discorb::VoiceState} | The voice state before the update. |
|
|
170
|
+
| `after` | {Discorb::VoiceState} | The voice state after the update. |
|
|
171
171
|
|
|
172
172
|
#### `voice_self_deaf_enable(state)`
|
|
173
173
|
|
|
174
174
|
Fires when a user's self voice deaf is enabled.
|
|
175
175
|
|
|
176
|
-
| Parameter | Type
|
|
177
|
-
|
|
|
178
|
-
| `state`
|
|
176
|
+
| Parameter | Type | Description |
|
|
177
|
+
| --------- | --------------------- | ---------------- |
|
|
178
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
179
179
|
|
|
180
180
|
#### `voice_self_deaf_disable(state)`
|
|
181
181
|
|
|
182
182
|
Fires when a user's self voice deaf is disabled.
|
|
183
183
|
|
|
184
|
-
| Parameter | Type
|
|
185
|
-
|
|
|
186
|
-
| `state`
|
|
184
|
+
| Parameter | Type | Description |
|
|
185
|
+
| --------- | --------------------- | ---------------- |
|
|
186
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
187
187
|
|
|
188
188
|
#### `voice_self_deaf_update(before, after)`
|
|
189
189
|
|
|
190
|
-
| Parameter | Type
|
|
191
|
-
|
|
|
192
|
-
| `before`
|
|
193
|
-
| `after`
|
|
190
|
+
| Parameter | Type | Description |
|
|
191
|
+
| --------- | --------------------- | ---------------------------------- |
|
|
192
|
+
| `before` | {Discorb::VoiceState} | The voice state before the update. |
|
|
193
|
+
| `after` | {Discorb::VoiceState} | The voice state after the update. |
|
|
194
194
|
|
|
195
195
|
### Stream Events
|
|
196
196
|
|
|
@@ -198,26 +198,26 @@ Fires when a user's self voice deaf is disabled.
|
|
|
198
198
|
|
|
199
199
|
Fires when a stream is started.
|
|
200
200
|
|
|
201
|
-
| Parameter | Type
|
|
202
|
-
|
|
|
203
|
-
| `state`
|
|
201
|
+
| Parameter | Type | Description |
|
|
202
|
+
| --------- | --------------------- | ---------------- |
|
|
203
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
204
204
|
|
|
205
205
|
#### `voice_stream_end(state)`
|
|
206
206
|
|
|
207
207
|
Fires when a stream is ended.
|
|
208
208
|
|
|
209
|
-
| Parameter | Type
|
|
210
|
-
|
|
|
211
|
-
| `state`
|
|
209
|
+
| Parameter | Type | Description |
|
|
210
|
+
| --------- | --------------------- | ---------------- |
|
|
211
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
212
212
|
|
|
213
213
|
#### `voice_stream_update(before, after)`
|
|
214
214
|
|
|
215
215
|
Fires when a stream is started or ended.
|
|
216
216
|
|
|
217
|
-
| Parameter | Type
|
|
218
|
-
|
|
|
219
|
-
| `before`
|
|
220
|
-
| `after`
|
|
217
|
+
| Parameter | Type | Description |
|
|
218
|
+
| --------- | --------------------- | ---------------------------------- |
|
|
219
|
+
| `before` | {Discorb::VoiceState} | The voice state before the update. |
|
|
220
|
+
| `after` | {Discorb::VoiceState} | The voice state after the update. |
|
|
221
221
|
|
|
222
222
|
### Video Events
|
|
223
223
|
|
|
@@ -225,26 +225,26 @@ Fires when a stream is started or ended.
|
|
|
225
225
|
|
|
226
226
|
Fires when a video is started.
|
|
227
227
|
|
|
228
|
-
| Parameter | Type
|
|
229
|
-
|
|
|
230
|
-
| `state`
|
|
228
|
+
| Parameter | Type | Description |
|
|
229
|
+
| --------- | --------------------- | ---------------- |
|
|
230
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
231
231
|
|
|
232
232
|
#### `voice_video_end(state)`
|
|
233
233
|
|
|
234
234
|
Fires when a video is ended.
|
|
235
235
|
|
|
236
|
-
| Parameter | Type
|
|
237
|
-
|
|
|
238
|
-
| `state`
|
|
236
|
+
| Parameter | Type | Description |
|
|
237
|
+
| --------- | --------------------- | ---------------- |
|
|
238
|
+
| `state` | {Discorb::VoiceState} | The voice state. |
|
|
239
239
|
|
|
240
240
|
#### `voice_video_update(before, after)`
|
|
241
241
|
|
|
242
242
|
Fires when a video is started or ended.
|
|
243
243
|
|
|
244
|
-
| Parameter | Type
|
|
245
|
-
|
|
|
246
|
-
| `before`
|
|
247
|
-
| `after`
|
|
244
|
+
| Parameter | Type | Description |
|
|
245
|
+
| --------- | --------------------- | ---------------------------------- |
|
|
246
|
+
| `before` | {Discorb::VoiceState} | The voice state before the update. |
|
|
247
|
+
| `after` | {Discorb::VoiceState} | The voice state after the update. |
|
|
248
248
|
|
|
249
249
|
### Stage Instances Events
|
|
250
250
|
|
|
@@ -252,26 +252,26 @@ Fires when a video is started or ended.
|
|
|
252
252
|
|
|
253
253
|
Fires when a new stage instance is created.
|
|
254
254
|
|
|
255
|
-
| Parameter
|
|
256
|
-
|
|
|
255
|
+
| Parameter | Type | Description |
|
|
256
|
+
| ---------- | ------------------------ | --------------------- |
|
|
257
257
|
| `instance` | {Discorb::StageInstance} | The created instance. |
|
|
258
258
|
|
|
259
259
|
#### `stage_instance_delete(instance)`
|
|
260
260
|
|
|
261
261
|
Fires when a stage instance is deleted.
|
|
262
262
|
|
|
263
|
-
| Parameter
|
|
264
|
-
|
|
|
263
|
+
| Parameter | Type | Description |
|
|
264
|
+
| ---------- | ------------------------ | --------------------- |
|
|
265
265
|
| `instance` | {Discorb::StageInstance} | The deleted instance. |
|
|
266
266
|
|
|
267
267
|
#### `stage_instance_update(before, after)`
|
|
268
268
|
|
|
269
269
|
Fires when a stage instance is updated.
|
|
270
270
|
|
|
271
|
-
| Parameter | Type
|
|
272
|
-
|
|
|
273
|
-
| `before`
|
|
274
|
-
| `after`
|
|
271
|
+
| Parameter | Type | Description |
|
|
272
|
+
| --------- | ------------------------ | ------------------------------- |
|
|
273
|
+
| `before` | {Discorb::StageInstance} | The instance before the update. |
|
|
274
|
+
| `after` | {Discorb::StageInstance} | The instance after the update. |
|
|
275
275
|
|
|
276
276
|
### Misc Events
|
|
277
277
|
|
|
@@ -279,7 +279,7 @@ Fires when a stage instance is updated.
|
|
|
279
279
|
|
|
280
280
|
Fired when a user changes voice state.
|
|
281
281
|
|
|
282
|
-
| Parameter | Type
|
|
283
|
-
|
|
|
284
|
-
| before
|
|
285
|
-
| after
|
|
282
|
+
| Parameter | Type | Description |
|
|
283
|
+
| --------- | --------------------- | ---------------------------------- |
|
|
284
|
+
| before | {Discorb::VoiceState} | The voice state before the update. |
|
|
285
|
+
| after | {Discorb::VoiceState} | The voice state after the update. |
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "discorb"
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
localizations = {
|
|
6
|
+
context_command: {
|
|
7
|
+
not_found: {
|
|
8
|
+
en: "Bookmark channel not found. Please create one called `bookmarks`.",
|
|
9
|
+
ja: "ブックマークチャンネルが見付かりませんでした。`bookmarks`という名前のチャンネルを作成してください。",
|
|
10
|
+
},
|
|
11
|
+
done: {
|
|
12
|
+
en: "Bookmark added.",
|
|
13
|
+
ja: "ブックマークを追加しました。",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
client = Discorb::Client.new
|
|
19
|
+
|
|
20
|
+
client.once :standby do
|
|
21
|
+
puts "Logged in as #{client.user}"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def bookmark_channel(guild)
|
|
25
|
+
guild.channels.find { |c| c.is_a?(Discorb::TextChannel) && c.name == "bookmarks" }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def build_embed_from_message(message)
|
|
29
|
+
embed = Discorb::Embed.new
|
|
30
|
+
embed.description = message.content
|
|
31
|
+
embed.author = Discorb::Embed::Author.new(message.author.to_s_user, icon: message.author.avatar.url)
|
|
32
|
+
embed.timestamp = message.timestamp
|
|
33
|
+
embed.footer = Discorb::Embed::Footer.new("ID: #{message.id}")
|
|
34
|
+
embed
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
client.message_command({
|
|
38
|
+
default: "Bookmark",
|
|
39
|
+
ja: "ブックマーク",
|
|
40
|
+
}) do |interaction, message|
|
|
41
|
+
unless channel = bookmark_channel(interaction.guild)
|
|
42
|
+
interaction.post(
|
|
43
|
+
localizations[:context_command][:not_found][interaction.locale] || localizations[:context_command][:not_found][:en],
|
|
44
|
+
ephemeral: true,
|
|
45
|
+
)
|
|
46
|
+
next
|
|
47
|
+
end
|
|
48
|
+
channel.post(
|
|
49
|
+
message.jump_url,
|
|
50
|
+
embed: build_embed_from_message(message),
|
|
51
|
+
).wait
|
|
52
|
+
interaction.post(
|
|
53
|
+
localizations[:context_command][:done][interaction.locale] || localizations[:context_command][:done][:en], ephemeral: true,
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
client.change_presence(
|
|
58
|
+
Discorb::Activity.new(
|
|
59
|
+
"Open message context menu to bookmark"
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "discorb"
|
|
3
|
+
|
|
4
|
+
client = Discorb::Client.new
|
|
5
|
+
|
|
6
|
+
client.once :standby do
|
|
7
|
+
puts "Logged in as #{client.user}"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
client.slash(
|
|
11
|
+
"admin", "You can run this command if you have Administrator permission",
|
|
12
|
+
dm: false,
|
|
13
|
+
default_permission: Discorb::Permission.from_keys(:administrator),
|
|
14
|
+
) do |interaction, _name|
|
|
15
|
+
interaction.post("Hello, admin!")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "discorb"
|
|
3
|
+
|
|
4
|
+
client = Discorb::Client.new
|
|
5
|
+
|
|
6
|
+
localizations = {
|
|
7
|
+
localized: {
|
|
8
|
+
text: {
|
|
9
|
+
en: "Hello, %s!",
|
|
10
|
+
ja: "%sさん、こんにちは!",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
client.once :standby do
|
|
16
|
+
puts "Logged in as #{client.user}"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
client.slash({
|
|
20
|
+
default: "greet",
|
|
21
|
+
ja: "挨拶",
|
|
22
|
+
}, {
|
|
23
|
+
default: "Bot greets. Cute OwO",
|
|
24
|
+
ja: "Botが挨拶します。かわいいね",
|
|
25
|
+
}, {
|
|
26
|
+
"name" => {
|
|
27
|
+
name_localizations: {
|
|
28
|
+
ja: "名前",
|
|
29
|
+
},
|
|
30
|
+
description: {
|
|
31
|
+
default: "The name to greet.",
|
|
32
|
+
ja: "挨拶する人の名前。",
|
|
33
|
+
},
|
|
34
|
+
type: :string,
|
|
35
|
+
optional: true,
|
|
36
|
+
},
|
|
37
|
+
}) do |interaction, name|
|
|
38
|
+
interaction.post(
|
|
39
|
+
format((localizations[:localized][:text][interaction.locale] || localizations[:localized][:text][:en]), name || interaction.target.to_s_user),
|
|
40
|
+
ephemeral: true,
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "discorb"
|
|
3
|
+
|
|
4
|
+
localizations = {
|
|
5
|
+
info: {
|
|
6
|
+
title: {
|
|
7
|
+
en: "%s's info",
|
|
8
|
+
ja: "%sの詳細",
|
|
9
|
+
},
|
|
10
|
+
fields: {
|
|
11
|
+
en: ["Name", "ID", "Bot", "Joined at", "Account created at"],
|
|
12
|
+
ja: %w[名前 ID ボット 参加日時 アカウント作成日時],
|
|
13
|
+
},
|
|
14
|
+
yn: {
|
|
15
|
+
en: %w[Yes No],
|
|
16
|
+
ja: %w[はい いいえ],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
client = Discorb::Client.new
|
|
22
|
+
|
|
23
|
+
client.once :standby do
|
|
24
|
+
puts "Logged in as #{client.user}"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
client.user_command({
|
|
28
|
+
default: "info",
|
|
29
|
+
ja: "詳細",
|
|
30
|
+
}) do |interaction|
|
|
31
|
+
field_name = localizations[:info][:fields][interaction.locale] || localizations[:info][:fields][:en]
|
|
32
|
+
interaction.post(
|
|
33
|
+
embed: Discorb::Embed.new(
|
|
34
|
+
format((localizations[:info][:title][interaction.locale] || localizations[:info][:title][:en]), interaction.target.to_s_user),
|
|
35
|
+
fields: [
|
|
36
|
+
Discorb::Embed::Field.new(field_name[0], interaction.target.to_s_user),
|
|
37
|
+
Discorb::Embed::Field.new(field_name[1], interaction.target.id),
|
|
38
|
+
Discorb::Embed::Field.new(
|
|
39
|
+
field_name[2],
|
|
40
|
+
(localizations[:info][:yn][interaction.locale] || localizations[:info][:yn][:en])[interaction.target.bot? ? 0 : 1]
|
|
41
|
+
),
|
|
42
|
+
Discorb::Embed::Field.new(field_name[3], interaction.target.joined_at.to_df("F")),
|
|
43
|
+
Discorb::Embed::Field.new(field_name[4], interaction.target.created_at.to_df("F")),
|
|
44
|
+
],
|
|
45
|
+
thumbnail: interaction.target.avatar&.url,
|
|
46
|
+
|
|
47
|
+
), ephemeral: true,
|
|
48
|
+
)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
|
|
@@ -28,7 +28,7 @@ client.on :message do |message|
|
|
|
28
28
|
components: [
|
|
29
29
|
Discorb::Button.new(
|
|
30
30
|
"Get role", custom_id: "auth:#{role.id}",
|
|
31
|
-
)
|
|
31
|
+
),
|
|
32
32
|
],
|
|
33
33
|
)
|
|
34
34
|
end
|
|
@@ -41,4 +41,4 @@ client.on :button_click do |response|
|
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
client.run(ENV
|
|
44
|
+
client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
|
|
@@ -22,7 +22,7 @@ SECTIONS = [
|
|
|
22
22
|
> So I decided to make it.
|
|
23
23
|
Matsumoto describes the design of Ruby as being like a simple Lisp language at its core, with an object system like that of Smalltalk, blocks inspired by higher-order functions, and practical utility like that of Perl.
|
|
24
24
|
WIKI
|
|
25
|
-
["First publication", <<~WIKI]
|
|
25
|
+
["First publication", <<~WIKI],
|
|
26
26
|
The first public release of Ruby 0.95 was announced on Japanese domestic newsgroups on December 21, 1995.
|
|
27
27
|
Subsequently, three more versions of Ruby were released in two days.
|
|
28
28
|
The release coincided with the launch of the Japanese-language ruby-list mailing list, which was the first mailing list for the new language.
|
|
@@ -59,4 +59,4 @@ client.on :select_menu_select do |response|
|
|
|
59
59
|
)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
client.run(ENV
|
|
62
|
+
client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
|
data/examples/extension/main.rb
CHANGED