discorb 0.15.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +1 -0
  3. data/.github/workflows/build_main.yml +2 -2
  4. data/.github/workflows/build_version.yml +1 -1
  5. data/.github/workflows/codeql-analysis.yml +1 -1
  6. data/.github/workflows/lint-push.yml +3 -5
  7. data/.github/workflows/lint.yml +1 -1
  8. data/.github/workflows/spec.yml +30 -0
  9. data/.lefthook/commit-msg/validator.rb +5 -0
  10. data/.rspec +2 -0
  11. data/.rspec_parallel +2 -0
  12. data/.rubocop.yml +49 -8
  13. data/Changelog.md +32 -1
  14. data/Gemfile +14 -8
  15. data/Rakefile +46 -25
  16. data/bin/console +3 -3
  17. data/docs/Examples.md +1 -1
  18. data/docs/application_command.md +138 -46
  19. data/docs/cli/irb.md +2 -2
  20. data/docs/cli/new.md +14 -9
  21. data/docs/cli/run.md +7 -11
  22. data/docs/cli.md +17 -10
  23. data/docs/events.md +257 -193
  24. data/docs/extension.md +1 -2
  25. data/docs/faq.md +0 -1
  26. data/docs/tutorial.md +12 -12
  27. data/docs/voice_events.md +106 -106
  28. data/examples/commands/message.rb +63 -0
  29. data/examples/commands/permission.rb +18 -0
  30. data/examples/commands/slash.rb +44 -0
  31. data/examples/commands/user.rb +51 -0
  32. data/examples/components/authorization_button.rb +2 -2
  33. data/examples/components/select_menu.rb +2 -2
  34. data/examples/extension/main.rb +1 -1
  35. data/examples/extension/message_expander.rb +5 -2
  36. data/examples/simple/eval.rb +2 -2
  37. data/examples/simple/ping_pong.rb +1 -1
  38. data/examples/simple/rolepanel.rb +2 -2
  39. data/examples/simple/shard.rb +17 -0
  40. data/examples/simple/wait_for_message.rb +1 -1
  41. data/exe/discorb +31 -16
  42. data/lefthook.yml +45 -0
  43. data/lib/discorb/allowed_mentions.rb +8 -0
  44. data/lib/discorb/app_command/command.rb +184 -60
  45. data/lib/discorb/app_command/common.rb +25 -0
  46. data/lib/discorb/app_command/handler.rb +116 -34
  47. data/lib/discorb/app_command.rb +2 -1
  48. data/lib/discorb/application.rb +17 -7
  49. data/lib/discorb/asset.rb +10 -2
  50. data/lib/discorb/attachment.rb +17 -2
  51. data/lib/discorb/audit_logs.rb +53 -12
  52. data/lib/discorb/channel/base.rb +108 -0
  53. data/lib/discorb/channel/category.rb +32 -0
  54. data/lib/discorb/channel/container.rb +44 -0
  55. data/lib/discorb/channel/dm.rb +28 -0
  56. data/lib/discorb/channel/guild.rb +245 -0
  57. data/lib/discorb/channel/stage.rb +140 -0
  58. data/lib/discorb/channel/text.rb +345 -0
  59. data/lib/discorb/channel/thread.rb +321 -0
  60. data/lib/discorb/channel/voice.rb +79 -0
  61. data/lib/discorb/channel.rb +2 -1126
  62. data/lib/discorb/client.rb +160 -64
  63. data/lib/discorb/common.rb +18 -3
  64. data/lib/discorb/components/button.rb +7 -7
  65. data/lib/discorb/components/select_menu.rb +6 -18
  66. data/lib/discorb/components/text_input.rb +12 -2
  67. data/lib/discorb/components.rb +1 -1
  68. data/lib/discorb/dictionary.rb +2 -0
  69. data/lib/discorb/embed.rb +55 -14
  70. data/lib/discorb/emoji.rb +59 -5
  71. data/lib/discorb/emoji_table.rb +4970 -4
  72. data/lib/discorb/error.rb +7 -1
  73. data/lib/discorb/event.rb +56 -21
  74. data/lib/discorb/exe/about.rb +1 -0
  75. data/lib/discorb/exe/irb.rb +2 -4
  76. data/lib/discorb/exe/new.rb +95 -28
  77. data/lib/discorb/exe/run.rb +9 -37
  78. data/lib/discorb/exe/setup.rb +25 -12
  79. data/lib/discorb/exe/show.rb +4 -3
  80. data/lib/discorb/extend.rb +1 -0
  81. data/lib/discorb/extension.rb +6 -3
  82. data/lib/discorb/flag.rb +11 -0
  83. data/lib/discorb/gateway.rb +312 -169
  84. data/lib/discorb/gateway_requests.rb +4 -7
  85. data/lib/discorb/guild.rb +255 -89
  86. data/lib/discorb/guild_template.rb +34 -7
  87. data/lib/discorb/http.rb +23 -11
  88. data/lib/discorb/integration.rb +27 -9
  89. data/lib/discorb/intents.rb +8 -8
  90. data/lib/discorb/interaction/autocomplete.rb +31 -19
  91. data/lib/discorb/interaction/command.rb +70 -17
  92. data/lib/discorb/interaction/components.rb +20 -4
  93. data/lib/discorb/interaction/modal.rb +0 -1
  94. data/lib/discorb/interaction/response.rb +73 -22
  95. data/lib/discorb/interaction/root.rb +29 -14
  96. data/lib/discorb/interaction.rb +1 -0
  97. data/lib/discorb/invite.rb +16 -9
  98. data/lib/discorb/member.rb +46 -5
  99. data/lib/discorb/message.rb +56 -15
  100. data/lib/discorb/message_meta.rb +39 -9
  101. data/lib/discorb/modules.rb +56 -14
  102. data/lib/discorb/permission.rb +14 -5
  103. data/lib/discorb/presence.rb +43 -10
  104. data/lib/discorb/rate_limit.rb +13 -3
  105. data/lib/discorb/reaction.rb +10 -4
  106. data/lib/discorb/role.rb +31 -4
  107. data/lib/discorb/shard.rb +74 -0
  108. data/lib/discorb/sticker.rb +30 -21
  109. data/lib/discorb/user.rb +13 -1
  110. data/lib/discorb/utils/colored_puts.rb +1 -0
  111. data/lib/discorb/voice_state.rb +30 -8
  112. data/lib/discorb/webhook.rb +88 -25
  113. data/lib/discorb.rb +10 -6
  114. data/po/yard.pot +9 -9
  115. data/sig/discorb.rbs +7232 -5837
  116. metadata +23 -6
  117. data/examples/commands/bookmarker.rb +0 -42
  118. data/examples/commands/hello.rb +0 -10
  119. data/examples/commands/inspect.rb +0 -25
  120. data/lib/discorb/log.rb +0 -81
data/docs/extension.md CHANGED
@@ -64,7 +64,6 @@ class MyExtension
64
64
  end
65
65
  ```
66
66
 
67
-
68
67
  ## Load extension
69
68
 
70
69
  Use {Discorb::Client#load_extension} to load extension.
@@ -127,4 +126,4 @@ class MyExtension
127
126
  puts "This extension is loaded to #{client}"
128
127
  end
129
128
  end
130
- ```
129
+ ```
data/docs/faq.md CHANGED
@@ -36,7 +36,6 @@ message = channel.post("Hello world!").wait # => Message
36
36
  message.pin
37
37
  ```
38
38
 
39
-
40
39
  ### How can I send DM to a user?
41
40
 
42
41
  Use {Discorb::User#post} method, {Discorb::User} includes {Discorb::Messageable}.
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
- 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/)
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
- 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/)
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
  ![](./assets/07_hello_infinite.png)
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 | Description |
14
- | --- | --- | --- |
15
- | state | {Discorb::VoiceState} | The voice state of the user that joined. |
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 | Description |
22
- | --- | --- | --- |
23
- | state | {Discorb::VoiceState} | The voice state of the user that left. |
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 | 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. |
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 | Description |
39
- | --- | --- | --- |
40
- | before | {Discorb::VoiceState} | The voice state before the update. |
41
- | after | {Discorb::VoiceState} | The voice state after the update. |
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 | Description |
50
- | --- | --- | --- |
51
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
58
- | --- | --- | --- |
59
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
66
- | --- | --- | --- |
67
- | `before` | {Discorb::VoiceState} | The voice state before the update. |
68
- | `after` | {Discorb::VoiceState} | The voice state after the update. |
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 | Description |
75
- | --- | --- | --- |
76
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
83
- | --- | --- | --- |
84
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
91
- | --- | --- | --- |
92
- | `before` | {Discorb::VoiceState} | The voice state before the update. |
93
- | `after` | {Discorb::VoiceState} | The voice state after the update. |
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 | Description |
100
- | --- | --- | --- |
101
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
108
- | --- | --- | --- |
109
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
116
- | --- | --- | --- |
117
- | `before` | {Discorb::VoiceState} | The voice state before the update. |
118
- | `after` | {Discorb::VoiceState} | The voice state after the update. |
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 | Description |
127
- | --- | --- | --- |
128
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
135
- | --- | --- | --- |
136
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
143
- | --- | --- | --- |
144
- | `before` | {Discorb::VoiceState} | The voice state before the update. |
145
- | `after` | {Discorb::VoiceState} | The voice state after the update. |
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 | Description |
152
- | --- | --- | --- |
153
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
160
- | --- | --- | --- |
161
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
168
- | --- | --- | --- |
169
- | `before` | {Discorb::VoiceState} | The voice state before the update. |
170
- | `after` | {Discorb::VoiceState} | The voice state after the update. |
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 | Description |
177
- | --- | --- | --- |
178
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
185
- | --- | --- | --- |
186
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
191
- | --- | --- | --- |
192
- | `before` | {Discorb::VoiceState} | The voice state before the update. |
193
- | `after` | {Discorb::VoiceState} | The voice state after the update. |
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 | Description |
202
- | --- | --- | --- |
203
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
210
- | --- | --- | --- |
211
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
218
- | --- | --- | --- |
219
- | `before` | {Discorb::VoiceState} | The voice state before the update. |
220
- | `after` | {Discorb::VoiceState} | The voice state after the update. |
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 | Description |
229
- | --- | --- | --- |
230
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
237
- | --- | --- | --- |
238
- | `state` | {Discorb::VoiceState} | The voice 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 | Description |
245
- | --- | --- | --- |
246
- | `before` | {Discorb::VoiceState} | The voice state before the update. |
247
- | `after` | {Discorb::VoiceState} | The voice state after the update. |
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 | Type | Description |
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 | Type | Description |
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 | Description |
272
- | --- | --- | --- |
273
- | `before` | {Discorb::StageInstance} | The instance before the update. |
274
- | `after` | {Discorb::StageInstance} | The instance after the update. |
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 | Description |
283
- | --- | --- | --- |
284
- | before | {Discorb::VoiceState} | The voice state before the update. |
285
- | after | {Discorb::VoiceState} | The voice state after the update. |
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["DISCORD_BOT_TOKEN"])
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["DISCORD_BOT_TOKEN"])
62
+ client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
@@ -10,4 +10,4 @@ end
10
10
 
11
11
  client.load_extension(MessageExpander)
12
12
 
13
- client.run(ENV["DISCORD_BOT_TOKEN"])
13
+ client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))