discorb 0.16.0 → 0.18.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 +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
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a thread.
|
|
4
|
+
# @abstract
|
|
5
|
+
class ThreadChannel < Discorb::Channel
|
|
6
|
+
include Discorb::Messageable
|
|
7
|
+
|
|
8
|
+
#
|
|
9
|
+
# Initialize a new thread channel.
|
|
10
|
+
# @private
|
|
11
|
+
#
|
|
12
|
+
# @param [Discorb::Client] client The client.
|
|
13
|
+
# @param [Hash] data The data of the thread channel.
|
|
14
|
+
# @param [Boolean] no_cache Whether to disable the cache.
|
|
15
|
+
def initialize: (
|
|
16
|
+
Discorb::Client client,
|
|
17
|
+
Discorb::json data,
|
|
18
|
+
?no_cache: bool
|
|
19
|
+
) -> void
|
|
20
|
+
|
|
21
|
+
#
|
|
22
|
+
# Edit the thread.
|
|
23
|
+
# @async
|
|
24
|
+
# @macro edit
|
|
25
|
+
#
|
|
26
|
+
# @param [String] name The name of the thread.
|
|
27
|
+
# @param [Boolean] archived Whether the thread is archived or not.
|
|
28
|
+
# @param [Integer] auto_archive_duration The auto archive duration in seconds.
|
|
29
|
+
# @param [Integer] archive_in Alias of `auto_archive_duration`.
|
|
30
|
+
# @param [Boolean] locked Whether the thread is locked or not.
|
|
31
|
+
# @param [String] reason The reason of editing the thread.
|
|
32
|
+
#
|
|
33
|
+
# @return [Async::Task<self>] The edited thread.
|
|
34
|
+
#
|
|
35
|
+
# @see #archive
|
|
36
|
+
# @see #lock
|
|
37
|
+
# @see #unarchive
|
|
38
|
+
# @see #unlock
|
|
39
|
+
def edit: (
|
|
40
|
+
?name: String,
|
|
41
|
+
?archived: bool,
|
|
42
|
+
?auto_archive_duration: Integer,
|
|
43
|
+
?archive_in: Integer,
|
|
44
|
+
?locked: bool,
|
|
45
|
+
?reason: String?
|
|
46
|
+
) -> Async::Task[self]
|
|
47
|
+
|
|
48
|
+
#
|
|
49
|
+
# Helper method to archive the thread.
|
|
50
|
+
#
|
|
51
|
+
# @param [String] reason The reason of archiving the thread.
|
|
52
|
+
#
|
|
53
|
+
# @return [Async::Task<self>] The archived thread.
|
|
54
|
+
def archive: (?reason: String?) -> Async::Task[self]
|
|
55
|
+
|
|
56
|
+
#
|
|
57
|
+
# Helper method to lock the thread.
|
|
58
|
+
#
|
|
59
|
+
# @param [String] reason The reason of locking the thread.
|
|
60
|
+
#
|
|
61
|
+
# @return [Async::Task<self>] The locked thread.
|
|
62
|
+
def lock: (?reason: String?) -> Async::Task[self]
|
|
63
|
+
|
|
64
|
+
#
|
|
65
|
+
# Helper method to unarchive the thread.
|
|
66
|
+
#
|
|
67
|
+
# @param [String] reason The reason of unarchiving the thread.
|
|
68
|
+
#
|
|
69
|
+
# @return [Async::Task<self>] The unarchived thread.
|
|
70
|
+
def unarchive: (?reason: String?) -> Async::Task[self]
|
|
71
|
+
|
|
72
|
+
#
|
|
73
|
+
# Helper method to unlock the thread.
|
|
74
|
+
#
|
|
75
|
+
# @param [String] reason The reason of unlocking the thread.
|
|
76
|
+
#
|
|
77
|
+
# @return [Async::Task<self>] The unlocked thread.
|
|
78
|
+
#
|
|
79
|
+
# @note This method won't unarchive the thread. Use {#unarchive} instead.
|
|
80
|
+
def unlock: (?reason: String?) -> Async::Task[self]
|
|
81
|
+
|
|
82
|
+
def parent: -> untyped
|
|
83
|
+
|
|
84
|
+
def me: -> untyped
|
|
85
|
+
|
|
86
|
+
def joined?: -> bool
|
|
87
|
+
|
|
88
|
+
def guild: -> untyped
|
|
89
|
+
|
|
90
|
+
def owner: -> untyped
|
|
91
|
+
|
|
92
|
+
def inspect: -> String
|
|
93
|
+
|
|
94
|
+
#
|
|
95
|
+
# Add a member to the thread.
|
|
96
|
+
#
|
|
97
|
+
# @param [Discorb::Member, :me] member The member to add. If `:me` is given, the bot will be added.
|
|
98
|
+
#
|
|
99
|
+
# @return [Async::Task<void>] The task.
|
|
100
|
+
def add_member: (?Discorb::Member | Symbol member) -> Async::Task[void]
|
|
101
|
+
|
|
102
|
+
#
|
|
103
|
+
# Remove a member from the thread.
|
|
104
|
+
#
|
|
105
|
+
# @param [Discorb::Member, :me] member The member to remove. If `:me` is given, the bot will be removed.
|
|
106
|
+
#
|
|
107
|
+
# @return [Async::Task<void>] The task.
|
|
108
|
+
def remove_member: (?Discorb::Member | Symbol member) -> Async::Task[void]
|
|
109
|
+
|
|
110
|
+
#
|
|
111
|
+
# Fetch members in the thread.
|
|
112
|
+
#
|
|
113
|
+
# @return [Array<Discorb::ThreadChannel::Member>] The members in the thread.
|
|
114
|
+
def fetch_members: -> ::Array[Discorb::ThreadChannel::Member]
|
|
115
|
+
|
|
116
|
+
# @return [Discorb::Snowflake] The ID of the channel.
|
|
117
|
+
# @note This ID is same as the starter message's ID
|
|
118
|
+
attr_reader id: Discorb::Snowflake
|
|
119
|
+
|
|
120
|
+
# @return [String] The name of the thread.
|
|
121
|
+
attr_reader name: String
|
|
122
|
+
|
|
123
|
+
# @return [Integer] The number of messages in the thread.
|
|
124
|
+
# @note This will stop counting at 50.
|
|
125
|
+
attr_reader message_count: Integer
|
|
126
|
+
|
|
127
|
+
# @return [Integer] The number of recipients in the thread.
|
|
128
|
+
# @note This will stop counting at 50.
|
|
129
|
+
attr_reader member_count: Integer
|
|
130
|
+
|
|
131
|
+
# @return [Integer] The rate limit per user (slowmode) in the thread.
|
|
132
|
+
attr_reader rate_limit_per_user: Integer
|
|
133
|
+
|
|
134
|
+
# @return [Array<Discorb::ThreadChannel::Member>] The members of the thread.
|
|
135
|
+
attr_reader members: ::Array[Discorb::ThreadChannel::Member]
|
|
136
|
+
|
|
137
|
+
# @return [Time] The time the thread was archived.
|
|
138
|
+
# @return [nil] If the thread is not archived.
|
|
139
|
+
attr_reader archived_timestamp: Time?
|
|
140
|
+
|
|
141
|
+
# @return [Integer] Auto archive duration in seconds.
|
|
142
|
+
attr_reader auto_archive_duration: Integer
|
|
143
|
+
|
|
144
|
+
# @return [Boolean] Whether the thread is archived or not.
|
|
145
|
+
attr_reader archived: bool
|
|
146
|
+
|
|
147
|
+
#
|
|
148
|
+
# Represents a thread in news channel(aka announcement channel).
|
|
149
|
+
class News < Discorb::ThreadChannel
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
#
|
|
153
|
+
# Represents a public thread in text channel.
|
|
154
|
+
class Public < Discorb::ThreadChannel
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
#
|
|
158
|
+
# Represents a private thread in text channel.
|
|
159
|
+
class Private < Discorb::ThreadChannel
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
#
|
|
163
|
+
# Represents a member in a thread.
|
|
164
|
+
class Member < Discorb::DiscordModel
|
|
165
|
+
def initialize: (
|
|
166
|
+
Discorb::Client client,
|
|
167
|
+
Discorb::json data,
|
|
168
|
+
_ToS guild_id
|
|
169
|
+
) -> void
|
|
170
|
+
|
|
171
|
+
def thread: -> Discorb::ThreadChannel
|
|
172
|
+
|
|
173
|
+
def member: -> Discorb::Member
|
|
174
|
+
|
|
175
|
+
def id: -> Discorb::Snowflake
|
|
176
|
+
|
|
177
|
+
def user: -> Discorb::User
|
|
178
|
+
|
|
179
|
+
def inspect: -> String
|
|
180
|
+
|
|
181
|
+
# Returns the value of attribute joined_at.
|
|
182
|
+
attr_reader joined_at: Time
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a voice channel.
|
|
4
|
+
class VoiceChannel < Discorb::GuildChannel
|
|
5
|
+
include Discorb::Connectable
|
|
6
|
+
include Discorb::Messageable
|
|
7
|
+
|
|
8
|
+
#
|
|
9
|
+
# Edit the voice channel.
|
|
10
|
+
# @async
|
|
11
|
+
# @macro edit
|
|
12
|
+
#
|
|
13
|
+
# @param [String] name The name of the voice channel.
|
|
14
|
+
# @param [Integer] position The position of the voice channel.
|
|
15
|
+
# @param [Integer] bitrate The bitrate of the voice channel.
|
|
16
|
+
# @param [Integer] user_limit The user limit of the voice channel.
|
|
17
|
+
# @param [Symbol] rtc_region The region of the voice channel.
|
|
18
|
+
# @param [String] reason The reason of editing the voice channel.
|
|
19
|
+
#
|
|
20
|
+
# @return [Async::Task<self>] The edited voice channel.
|
|
21
|
+
def edit: (
|
|
22
|
+
?name: String,
|
|
23
|
+
?position: Integer,
|
|
24
|
+
?bitrate: Integer,
|
|
25
|
+
?user_limit: Integer,
|
|
26
|
+
?rtc_region: Symbol,
|
|
27
|
+
?reason: String?
|
|
28
|
+
) -> Async::Task[self]
|
|
29
|
+
|
|
30
|
+
def voice_states: -> Array[Discorb::VoiceState]
|
|
31
|
+
|
|
32
|
+
def members: -> Array[Discorb::Member]
|
|
33
|
+
|
|
34
|
+
# @return [Integer] The bitrate of the voice channel.
|
|
35
|
+
attr_reader bitrate: Integer
|
|
36
|
+
|
|
37
|
+
# @return [Integer] The user limit of the voice channel.
|
|
38
|
+
# @return [nil] If the user limit is not set.
|
|
39
|
+
attr_reader user_limit: Integer?
|
|
40
|
+
end
|
|
41
|
+
end
|