discorb 0.16.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +2 -4
- data/.github/workflows/spec.yml +33 -0
- data/.github/workflows/validate.yml +21 -0
- data/.gitignore +2 -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 +30 -1
- data/Gemfile +20 -8
- data/Rakefile +226 -98
- data/Steepfile +28 -0
- data/bin/console +3 -3
- data/docs/Examples.md +1 -1
- data/docs/application_command.md +156 -47
- 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 +247 -213
- data/docs/extension.md +1 -2
- data/docs/faq.md +0 -1
- data/docs/tutorial.md +18 -18
- data/docs/voice_events.md +106 -106
- data/examples/commands/message.rb +68 -0
- data/examples/commands/permission.rb +19 -0
- data/examples/commands/slash.rb +48 -0
- data/examples/commands/user.rb +54 -0
- data/examples/components/authorization_button.rb +4 -3
- data/examples/components/select_menu.rb +6 -3
- data/examples/extension/main.rb +2 -1
- data/examples/extension/message_expander.rb +6 -2
- data/examples/sig/commands/message.rbs +5 -0
- data/examples/simple/eval.rb +3 -2
- data/examples/simple/ping_pong.rb +2 -1
- data/examples/simple/rolepanel.rb +17 -6
- data/examples/simple/shard.rb +3 -2
- data/examples/simple/wait_for_message.rb +4 -1
- data/exe/discorb +33 -18
- data/lefthook.yml +45 -0
- data/lib/discorb/allowed_mentions.rb +2 -1
- data/lib/discorb/app_command/command.rb +130 -72
- data/lib/discorb/app_command/common.rb +25 -0
- data/lib/discorb/app_command/handler.rb +130 -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 +19 -10
- data/lib/discorb/automod.rb +269 -0
- 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 +246 -0
- data/lib/discorb/channel/stage.rb +140 -0
- data/lib/discorb/channel/text.rb +336 -0
- data/lib/discorb/channel/thread.rb +325 -0
- data/lib/discorb/channel/voice.rb +79 -0
- data/lib/discorb/channel.rb +2 -1165
- data/lib/discorb/client.rb +50 -36
- data/lib/discorb/color.rb +37 -60
- 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/dictionary.rb +1 -1
- data/lib/discorb/embed.rb +26 -10
- data/lib/discorb/emoji.rb +31 -4
- data/lib/discorb/emoji_table.rb +4969 -3
- data/lib/discorb/event.rb +29 -4
- data/lib/discorb/exe/about.rb +2 -1
- data/lib/discorb/exe/irb.rb +2 -4
- data/lib/discorb/exe/new.rb +89 -26
- 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 -7
- data/lib/discorb/flag.rb +13 -2
- data/lib/discorb/gateway.rb +79 -589
- data/lib/discorb/gateway_events.rb +638 -0
- data/lib/discorb/guild.rb +318 -67
- data/lib/discorb/guild_template.rb +11 -5
- data/lib/discorb/http.rb +53 -24
- data/lib/discorb/integration.rb +4 -1
- data/lib/discorb/intents.rb +28 -19
- data/lib/discorb/interaction/autocomplete.rb +28 -16
- data/lib/discorb/interaction/command.rb +42 -14
- data/lib/discorb/interaction/components.rb +5 -2
- data/lib/discorb/interaction/modal.rb +0 -1
- data/lib/discorb/interaction/response.rb +125 -26
- 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 +28 -8
- data/lib/discorb/message.rb +60 -25
- data/lib/discorb/message_meta.rb +3 -3
- data/lib/discorb/modules.rb +59 -16
- data/lib/discorb/presence.rb +2 -0
- data/lib/discorb/rate_limit.rb +7 -2
- data/lib/discorb/reaction.rb +2 -2
- data/lib/discorb/role.rb +20 -5
- data/lib/discorb/shard.rb +1 -1
- data/lib/discorb/sticker.rb +9 -8
- data/lib/discorb/user.rb +4 -3
- data/lib/discorb/utils/colored_puts.rb +1 -0
- data/lib/discorb/voice_state.rb +6 -2
- data/lib/discorb/webhook.rb +64 -31
- data/lib/discorb.rb +7 -5
- data/po/yard.pot +20 -20
- data/rbs_collection.lock.yaml +88 -0
- data/rbs_collection.yaml +21 -0
- data/sig/async.rbs +11 -0
- data/sig/discorb/activity.rbs +23 -0
- data/sig/discorb/allowed_mentions.rbs +44 -0
- data/sig/discorb/app_command/base.rbs +282 -0
- data/sig/discorb/app_command/handler.rbs +171 -0
- data/sig/discorb/application.rbs +142 -0
- data/sig/discorb/asset.rbs +32 -0
- data/sig/discorb/attachment.rbs +91 -0
- data/sig/discorb/audit_log.rbs +231 -0
- data/sig/discorb/automod.rbs +128 -0
- data/sig/discorb/avatar.rbs +26 -0
- data/sig/discorb/channel/base.rbs +179 -0
- data/sig/discorb/channel/category.rbs +56 -0
- data/sig/discorb/channel/container.rbs +29 -0
- data/sig/discorb/channel/dm.rbs +14 -0
- data/sig/discorb/channel/news.rbs +20 -0
- data/sig/discorb/channel/stage.rbs +77 -0
- data/sig/discorb/channel/text.rbs +158 -0
- data/sig/discorb/channel/thread.rbs +185 -0
- data/sig/discorb/channel/voice.rbs +41 -0
- data/sig/discorb/client.rbs +2495 -0
- data/sig/discorb/color.rbs +142 -0
- data/sig/discorb/component/base.rbs +28 -0
- data/sig/discorb/component/button.rbs +65 -0
- data/sig/discorb/component/select_menu.rbs +107 -0
- data/sig/discorb/component/text_input.rbs +69 -0
- data/sig/discorb/connectable.rbs +8 -0
- data/sig/discorb/custom_emoji.rbs +90 -0
- data/sig/discorb/dictionary.rbs +85 -0
- data/sig/discorb/discord_model.rbs +15 -0
- data/sig/discorb/embed.rbs +279 -0
- data/sig/discorb/emoji.rbs +13 -0
- data/sig/discorb/error.rbs +73 -0
- data/sig/discorb/event_handler.rbs +27 -0
- data/sig/discorb/extension.rbs +1734 -0
- data/sig/discorb/flag.rbs +72 -0
- data/sig/discorb/gateway.rbs +481 -0
- data/sig/discorb/guild.rbs +870 -0
- data/sig/discorb/guild_template.rbs +174 -0
- data/sig/discorb/http.rbs +147 -0
- data/sig/discorb/image.rbs +20 -0
- data/sig/discorb/integration.rbs +118 -0
- data/sig/discorb/intents.rbs +97 -0
- data/sig/discorb/interaction/autocomplete.rbs +9 -0
- data/sig/discorb/interaction/base.rbs +66 -0
- data/sig/discorb/interaction/command.rbs +66 -0
- data/sig/discorb/interaction/message_component.rbs +140 -0
- data/sig/discorb/interaction/modal.rbs +50 -0
- data/sig/discorb/interaction/responder.rbs +157 -0
- data/sig/discorb/invite.rbs +86 -0
- data/sig/discorb/member.rbs +187 -0
- data/sig/discorb/message.rbs +469 -0
- data/sig/discorb/messageable.rbs +153 -0
- data/sig/discorb/partial_emoji.rbs +35 -0
- data/sig/discorb/permissions.rbs +149 -0
- data/sig/discorb/presence.rbs +237 -0
- data/sig/discorb/reaction.rbs +33 -0
- data/sig/discorb/role.rbs +145 -0
- data/sig/discorb/scheduled_event.rbs +148 -0
- data/sig/discorb/shard.rbs +62 -0
- data/sig/discorb/snowflake.rbs +56 -0
- data/sig/discorb/stage_instance.rbs +63 -0
- data/sig/discorb/sticker.rbs +116 -0
- data/sig/discorb/system_channel_flag.rbs +17 -0
- data/sig/discorb/unicode_emoji.rbs +49 -0
- data/sig/discorb/user.rbs +93 -0
- data/sig/discorb/utils.rbs +8 -0
- data/sig/discorb/voice_region.rbs +30 -0
- data/sig/discorb/voice_state.rbs +71 -0
- data/sig/discorb/webhook.rbs +327 -0
- data/sig/discorb/welcome_screen.rbs +78 -0
- data/sig/discorb.rbs +6 -7230
- data/sig/manifest.yaml +3 -0
- data/sig/override.rbs +19 -0
- data/template-replace/files/css/common.css +4 -0
- metadata +102 -6
- 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
|
+
- [RubyMine](https://www.jetbrains.com/ruby/)
|
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
|
|
@@ -98,10 +98,10 @@ You will get other files if you specify `--git`.
|
|
98
98
|
Open `main.rb`, you will see the following code:
|
99
99
|
|
100
100
|
```ruby
|
101
|
-
|
102
|
-
require "dotenv"
|
101
|
+
# frozen_string_literal: true
|
103
102
|
|
104
|
-
|
103
|
+
require "discorb"
|
104
|
+
require "dotenv/load" # Load environment variables from .env file.
|
105
105
|
|
106
106
|
client = Discorb::Client.new # Create client for connecting to Discord
|
107
107
|
|
@@ -115,10 +115,10 @@ client.run ENV["TOKEN"] # Starts client
|
|
115
115
|
Open `.env`, you will see:
|
116
116
|
|
117
117
|
```
|
118
|
-
TOKEN=
|
118
|
+
TOKEN=
|
119
119
|
```
|
120
120
|
|
121
|
-
|
121
|
+
Put your token after `TOKEN=`.
|
122
122
|
Remember to keep this file secret!
|
123
123
|
|
124
124
|
Open terminal and type:
|
@@ -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
|
|
@@ -194,4 +194,4 @@ You did it! Your bot won't respond to bot's messages anymore.
|
|
194
194
|
This is the end of tutorial.
|
195
195
|
|
196
196
|
To learn more, check out the [documentation](https://discorb-lib.github.io/).
|
197
|
-
You can also check out [Examples](
|
197
|
+
You can also check out [Examples](https://github.com/discorb-lib/discorb/tree/main/examples).
|
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,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "discorb"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
localizations = {
|
7
|
+
context_command: {
|
8
|
+
not_found: {
|
9
|
+
en: "Bookmark channel not found. Please create one called `bookmarks`.",
|
10
|
+
ja: "ブックマークチャンネルが見付かりませんでした。`bookmarks`という名前のチャンネルを作成してください。",
|
11
|
+
},
|
12
|
+
done: {
|
13
|
+
en: "Bookmark added.",
|
14
|
+
ja: "ブックマークを追加しました。",
|
15
|
+
},
|
16
|
+
},
|
17
|
+
}
|
18
|
+
|
19
|
+
client = Discorb::Client.new
|
20
|
+
|
21
|
+
client.once :standby do
|
22
|
+
puts "Logged in as #{client.user}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def bookmark_channel(guild)
|
26
|
+
guild.text_channels.find { |c| c.name == "bookmarks" }
|
27
|
+
end
|
28
|
+
|
29
|
+
def build_embed_from_message(message)
|
30
|
+
embed = Discorb::Embed.new
|
31
|
+
embed.description = message.content
|
32
|
+
embed.author = Discorb::Embed::Author.new(message.author.to_s, icon: message.author.avatar.url)
|
33
|
+
embed.timestamp = message.timestamp
|
34
|
+
embed.footer = Discorb::Embed::Footer.new("ID: #{message.id}")
|
35
|
+
embed
|
36
|
+
end
|
37
|
+
|
38
|
+
client.message_command({
|
39
|
+
default: "Bookmark",
|
40
|
+
ja: "ブックマーク",
|
41
|
+
}) do |interaction, message|
|
42
|
+
next unless interaction.guild
|
43
|
+
|
44
|
+
unless channel = bookmark_channel(interaction.guild)
|
45
|
+
interaction.post(
|
46
|
+
localizations[:context_command][:not_found][interaction.locale] ||
|
47
|
+
localizations[:context_command][:not_found][:en],
|
48
|
+
ephemeral: true,
|
49
|
+
)
|
50
|
+
next
|
51
|
+
end
|
52
|
+
channel.post(
|
53
|
+
message.jump_url,
|
54
|
+
embed: build_embed_from_message(message),
|
55
|
+
).wait
|
56
|
+
interaction.post(
|
57
|
+
localizations[:context_command][:done][interaction.locale] || localizations[:context_command][:done][:en],
|
58
|
+
ephemeral: true,
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
client.change_presence(
|
63
|
+
Discorb::Activity.new(
|
64
|
+
"Open message context menu to bookmark"
|
65
|
+
)
|
66
|
+
)
|
67
|
+
|
68
|
+
client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "discorb"
|
4
|
+
|
5
|
+
client = Discorb::Client.new
|
6
|
+
|
7
|
+
client.once :standby do
|
8
|
+
puts "Logged in as #{client.user}"
|
9
|
+
end
|
10
|
+
|
11
|
+
client.slash(
|
12
|
+
"admin", "You can run this command if you have Administrator permission",
|
13
|
+
dm_permission: false,
|
14
|
+
default_permission: Discorb::Permission.from_keys(:administrator),
|
15
|
+
) do |interaction, _name|
|
16
|
+
interaction.post("Hello, admin!")
|
17
|
+
end
|
18
|
+
|
19
|
+
client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "discorb"
|
4
|
+
|
5
|
+
client = Discorb::Client.new
|
6
|
+
|
7
|
+
localizations = {
|
8
|
+
localized: {
|
9
|
+
text: {
|
10
|
+
en: "Hello, %s!",
|
11
|
+
ja: "%sさん、こんにちは!",
|
12
|
+
},
|
13
|
+
},
|
14
|
+
}
|
15
|
+
|
16
|
+
client.once :standby do
|
17
|
+
puts "Logged in as #{client.user}"
|
18
|
+
end
|
19
|
+
|
20
|
+
client.slash(
|
21
|
+
{
|
22
|
+
default: "greet",
|
23
|
+
ja: "挨拶",
|
24
|
+
}, {
|
25
|
+
default: "Bot greets. Cute OwO",
|
26
|
+
ja: "Botが挨拶します。かわいいね",
|
27
|
+
}, {
|
28
|
+
"name" => {
|
29
|
+
name_localizations: {
|
30
|
+
ja: "名前",
|
31
|
+
},
|
32
|
+
description: {
|
33
|
+
default: "The name to greet.",
|
34
|
+
ja: "挨拶する人の名前。",
|
35
|
+
},
|
36
|
+
type: :string,
|
37
|
+
optional: true,
|
38
|
+
},
|
39
|
+
}
|
40
|
+
) do |interaction, name|
|
41
|
+
interaction.post(
|
42
|
+
format((localizations[:localized][:text][interaction.locale] || localizations[:localized][:text][:en]),
|
43
|
+
name || interaction.user.to_s),
|
44
|
+
ephemeral: true,
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "discorb"
|
4
|
+
|
5
|
+
localizations = {
|
6
|
+
info: {
|
7
|
+
title: {
|
8
|
+
en: "%s's info",
|
9
|
+
ja: "%sの詳細",
|
10
|
+
},
|
11
|
+
fields: {
|
12
|
+
en: ["Name", "ID", "Bot", "Joined at", "Account created at"],
|
13
|
+
ja: %w[名前 ID ボット 参加日時 アカウント作成日時],
|
14
|
+
},
|
15
|
+
yn: {
|
16
|
+
en: %w[Yes No],
|
17
|
+
ja: %w[はい いいえ],
|
18
|
+
},
|
19
|
+
},
|
20
|
+
}
|
21
|
+
|
22
|
+
client = Discorb::Client.new
|
23
|
+
|
24
|
+
client.once :standby do
|
25
|
+
puts "Logged in as #{client.user}"
|
26
|
+
end
|
27
|
+
|
28
|
+
client.user_command(
|
29
|
+
{
|
30
|
+
default: "info",
|
31
|
+
ja: "詳細",
|
32
|
+
}
|
33
|
+
) do |interaction, user|
|
34
|
+
field_name = localizations[:info][:fields][interaction.locale] || localizations[:info][:fields][:en]
|
35
|
+
interaction.post(
|
36
|
+
embed: Discorb::Embed.new(
|
37
|
+
format((localizations[:info][:title][interaction.locale] || localizations[:info][:title][:en]),
|
38
|
+
user.to_s),
|
39
|
+
fields: [
|
40
|
+
Discorb::Embed::Field.new(field_name[0], user.to_s),
|
41
|
+
Discorb::Embed::Field.new(field_name[1], user.id),
|
42
|
+
Discorb::Embed::Field.new(
|
43
|
+
field_name[2],
|
44
|
+
(localizations[:info][:yn][locale] || localizations[:info][:yn][:en])[user.bot? ? 0 : 1]
|
45
|
+
),
|
46
|
+
Discorb::Embed::Field.new(field_name[3], user.joined_at.to_df("F")),
|
47
|
+
Discorb::Embed::Field.new(field_name[4], user.created_at.to_df("F")),
|
48
|
+
],
|
49
|
+
thumbnail: user.avatar&.url,
|
50
|
+
), ephemeral: true,
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
|