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,128 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
class AutoModRule < DiscordModel
|
|
3
|
+
type trigger_type = :keyword | :harmful_link | :spam | :keyword_preset
|
|
4
|
+
type preset_type = :profanity | :sexual_content | :slurs
|
|
5
|
+
|
|
6
|
+
# @return [Hash{Integer => Symbol}] The mapping of trigger types.
|
|
7
|
+
# @private
|
|
8
|
+
TRIGGER_TYPES: Hash[Integer, trigger_type]
|
|
9
|
+
|
|
10
|
+
# @return [Hash{Integer => Symbol}] The mapping of preset types.
|
|
11
|
+
# @private
|
|
12
|
+
PRESET_TYPES: Hash[Integer, preset_type]
|
|
13
|
+
|
|
14
|
+
# @return [Hash{Integer => Symbol}] The mapping of event types.
|
|
15
|
+
# @private
|
|
16
|
+
EVENT_TYPES: Hash[Integer, :message_send]
|
|
17
|
+
|
|
18
|
+
# @return [Discorb::Snowflake] The ID of the rule.
|
|
19
|
+
attr_reader id: Discorb::Snowflake
|
|
20
|
+
|
|
21
|
+
# @return [String] The name of the rule.
|
|
22
|
+
attr_reader name: String
|
|
23
|
+
|
|
24
|
+
# @return [Boolean] Whether the rule is enabled.
|
|
25
|
+
attr_reader enabled: bool
|
|
26
|
+
alias enabled? enabled
|
|
27
|
+
|
|
28
|
+
# @return [Array<Discorb::AutoModRule::Action>] The actions of the rule.
|
|
29
|
+
attr_reader actions: Array[Discorb::AutoModRule::Action]
|
|
30
|
+
|
|
31
|
+
# @return [Array<String>] The keywords that the rule is triggered by.
|
|
32
|
+
# @note This is only available if the trigger type is `:keyword`.
|
|
33
|
+
attr_reader keyword_filter: Array[String]?
|
|
34
|
+
|
|
35
|
+
# @return [Symbol] Returns the type of the preset.
|
|
36
|
+
# @note This is only available if the trigger type is `:keyword_preset`.
|
|
37
|
+
def preset_type: -> preset_type
|
|
38
|
+
|
|
39
|
+
# @return [Symbol] Returns the type of the trigger.
|
|
40
|
+
def trigger_type: -> trigger_type
|
|
41
|
+
|
|
42
|
+
# @return [Symbol] Returns the type of the event.
|
|
43
|
+
def event_type: -> :message_send
|
|
44
|
+
|
|
45
|
+
def creator: -> Discorb::Member
|
|
46
|
+
|
|
47
|
+
def guild: -> Discorb::Guild
|
|
48
|
+
|
|
49
|
+
def exempt_roles: -> Array[Discorb::Role]
|
|
50
|
+
|
|
51
|
+
def exempt_channels: -> Array[Discorb::Channel]
|
|
52
|
+
|
|
53
|
+
#
|
|
54
|
+
# Initialize a new auto mod.
|
|
55
|
+
# @private
|
|
56
|
+
#
|
|
57
|
+
# @param [Discorb::Client] client The client.
|
|
58
|
+
# @param [Hash] data The auto mod data.
|
|
59
|
+
def initialize: (Discorb::Client client, Discorb::json data) -> void
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
# Edit the rule.
|
|
63
|
+
# @async
|
|
64
|
+
# @edit
|
|
65
|
+
#
|
|
66
|
+
# @param [String] name The name of the rule.
|
|
67
|
+
# @param [Symbol] event_type The event type of the rule. See {Discorb::AutoModRule::EVENT_TYPES}.
|
|
68
|
+
# @param [Array<Discorb::AutoModRule::Action>] actions The actions of the rule.
|
|
69
|
+
# @param [Boolean] enabled Whether the rule is enabled or not.
|
|
70
|
+
# @param [Array<Discorb::Role>] exempt_roles The roles that are exempt from the rule.
|
|
71
|
+
# @param [Array<Discorb::Channel>] exempt_channels The channels that are exempt from the rule.
|
|
72
|
+
# @param [Array<String>] keyword_filter The keywords to filter.
|
|
73
|
+
# @param [Symbol] presets The preset of the rule. See {Discorb::AutoModRule::PRESET_TYPES}.
|
|
74
|
+
# @param [String] reason The reason for creating the rule.
|
|
75
|
+
#
|
|
76
|
+
# @return [Async::Task<void>] The task.
|
|
77
|
+
def edit: (
|
|
78
|
+
?name: String,
|
|
79
|
+
?event_type: :send_message,
|
|
80
|
+
?actions: Array[Discorb::AutoModRule::Action],
|
|
81
|
+
?enabled: bool,
|
|
82
|
+
?exempt_roles: Array[Discorb::Role],
|
|
83
|
+
?exempt_channels: Array[Discorb::Channel],
|
|
84
|
+
?keyword_filter: Array[String]?,
|
|
85
|
+
?presets: :profanity | :sexual_content | :slurs,
|
|
86
|
+
?reason: nil
|
|
87
|
+
) -> Async::Task[void]
|
|
88
|
+
|
|
89
|
+
#
|
|
90
|
+
# Delete the rule.
|
|
91
|
+
#
|
|
92
|
+
# @param [String] reason The reason for deleting the rule.
|
|
93
|
+
#
|
|
94
|
+
# @return [Async::Task<void>] The task.
|
|
95
|
+
def delete!: (?reason: nil) -> Async::Task[void]
|
|
96
|
+
|
|
97
|
+
class Action < Discorb::DiscordModel
|
|
98
|
+
# @return [Hash{Integer => Symbol}] The mapping of action types.
|
|
99
|
+
# @private
|
|
100
|
+
ACTION_TYPES: Hash[Integer, Symbol]
|
|
101
|
+
|
|
102
|
+
# @return [Symbol] Returns the type of the action.
|
|
103
|
+
attr_reader type: :ban | :kick | :mute | :warn
|
|
104
|
+
|
|
105
|
+
# @return [Integer] The duration of the timeout.
|
|
106
|
+
# @note This is only available if the action type is `:timeout`.
|
|
107
|
+
attr_reader duration_seconds: Integer?
|
|
108
|
+
|
|
109
|
+
#
|
|
110
|
+
# Initialize a new action.
|
|
111
|
+
#
|
|
112
|
+
# @param [Symbol] type The type of the action.
|
|
113
|
+
# @param [Integer] duration_seconds The duration of the timeout.
|
|
114
|
+
# This is only available if the action type is `:timeout`.
|
|
115
|
+
# @param [Discorb::Channel] channel The channel that the alert message is sent to.
|
|
116
|
+
# This is only available if the action type is `:send_alert_message`.
|
|
117
|
+
def initialize: (
|
|
118
|
+
Symbol `type`,
|
|
119
|
+
?duration_seconds: Integer?,
|
|
120
|
+
?channel: Discorb::Channel?
|
|
121
|
+
) -> void
|
|
122
|
+
|
|
123
|
+
# @return [Discorb::Channel] The channel that the alert message is sent to.
|
|
124
|
+
# @note This is only available if the action type is `:send_alert_message`.
|
|
125
|
+
def channel: -> Discorb::Channel?
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a default avatar.
|
|
4
|
+
class DefaultAvatar < Discorb::DiscordModel
|
|
5
|
+
#
|
|
6
|
+
# Initialize a new instance of the DefaultAvatar class.
|
|
7
|
+
# @private
|
|
8
|
+
def initialize: (untyped discriminator) -> void
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# Returns the URL of the avatar.
|
|
12
|
+
#
|
|
13
|
+
# @param [String] image_format The image format. This is compatible with {Asset#url}, will be ignored.
|
|
14
|
+
# @param [Integer] size The size of the image. This is compatible with {Asset#url}, will be ignored.
|
|
15
|
+
#
|
|
16
|
+
# @return [String] URL of the avatar.
|
|
17
|
+
#
|
|
18
|
+
# rubocop: disable Lint/UnusedMethodArgument
|
|
19
|
+
def url: (?image_format: String?, ?size: Integer) -> String
|
|
20
|
+
|
|
21
|
+
def inspect: -> String
|
|
22
|
+
|
|
23
|
+
# @return [false] For compatibility with {Asset}, always `false`.
|
|
24
|
+
attr_reader animated?: bool
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a channel of Discord.
|
|
4
|
+
# @abstract
|
|
5
|
+
class Channel < Discorb::DiscordModel
|
|
6
|
+
#
|
|
7
|
+
# Initializes a new instance of the Channel class.
|
|
8
|
+
# @private
|
|
9
|
+
def initialize: (untyped client, untyped data, ?no_cache: untyped) -> void
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# Checks if the channel is other channel.
|
|
13
|
+
#
|
|
14
|
+
# @param [Discorb::Channel] other The channel to check.
|
|
15
|
+
#
|
|
16
|
+
# @return [Boolean] True if the channel is other channel.
|
|
17
|
+
def ==: (Discorb::Channel other) -> bool
|
|
18
|
+
|
|
19
|
+
def inspect: -> String
|
|
20
|
+
|
|
21
|
+
#
|
|
22
|
+
# Returns the descendants of the Channel class.
|
|
23
|
+
# @private
|
|
24
|
+
def self.descendants: -> untyped
|
|
25
|
+
|
|
26
|
+
#
|
|
27
|
+
# Creates a new instance of the Channel class or instance of its descendants.
|
|
28
|
+
# @private
|
|
29
|
+
#
|
|
30
|
+
# @param [Discorb::Client] client The client that instantiated the object.
|
|
31
|
+
# @param [Hash] data The data of the object.
|
|
32
|
+
# @param [Boolean] no_cache Whether to disable cache the object.
|
|
33
|
+
def self.make_channel: (
|
|
34
|
+
Discorb::Client client,
|
|
35
|
+
Discorb::json data,
|
|
36
|
+
?no_cache: bool
|
|
37
|
+
) -> untyped
|
|
38
|
+
|
|
39
|
+
def `type`: -> String
|
|
40
|
+
|
|
41
|
+
#
|
|
42
|
+
# Returns the channel id to request.
|
|
43
|
+
# @private
|
|
44
|
+
#
|
|
45
|
+
# @return [Async::Task<Discorb::Snowflake>] A task that resolves to the channel id.
|
|
46
|
+
def channel_id: -> Async::Task[Discorb::Snowflake]
|
|
47
|
+
|
|
48
|
+
# @return [Discorb::Snowflake] The ID of the channel.
|
|
49
|
+
attr_reader id: Discorb::Snowflake
|
|
50
|
+
|
|
51
|
+
# @return [String] The name of the channel.
|
|
52
|
+
attr_reader name: String
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
#
|
|
56
|
+
# Represents a channel in guild.
|
|
57
|
+
# @abstract
|
|
58
|
+
class GuildChannel < Discorb::Channel
|
|
59
|
+
include Comparable
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
# Compares position of two channels.
|
|
63
|
+
#
|
|
64
|
+
# @param [Discorb::GuildChannel] other The channel to compare.
|
|
65
|
+
#
|
|
66
|
+
# @return [-1, 0, 1] -1 if the channel is at lower than the other, 1 if the channel is at highter than the other.
|
|
67
|
+
def <=>: (Discorb::GuildChannel other) -> Integer?
|
|
68
|
+
|
|
69
|
+
#
|
|
70
|
+
# Checks if the channel is same as another.
|
|
71
|
+
#
|
|
72
|
+
# @param [Discorb::GuildChannel] other The channel to check.
|
|
73
|
+
#
|
|
74
|
+
# @return [Boolean] `true` if the channel is same as another.
|
|
75
|
+
def ==: (Discorb::GuildChannel other) -> bool
|
|
76
|
+
|
|
77
|
+
#
|
|
78
|
+
# Stringifies the channel.
|
|
79
|
+
#
|
|
80
|
+
# @return [String] The name of the channel with `#`.
|
|
81
|
+
def to_s: -> String
|
|
82
|
+
|
|
83
|
+
def mention: -> String
|
|
84
|
+
|
|
85
|
+
def parent: -> Discorb::CategoryChannel?
|
|
86
|
+
|
|
87
|
+
def guild: -> Discorb::Guild
|
|
88
|
+
|
|
89
|
+
def inspect: -> String
|
|
90
|
+
|
|
91
|
+
#
|
|
92
|
+
# Deletes the channel.
|
|
93
|
+
# @async
|
|
94
|
+
#
|
|
95
|
+
# @param [String] reason The reason of deleting the channel.
|
|
96
|
+
#
|
|
97
|
+
# @return [Async::Task<self>] The deleted channel.
|
|
98
|
+
def delete!: (?reason: String?) -> Async::Task[self]
|
|
99
|
+
|
|
100
|
+
#
|
|
101
|
+
# Moves the channel to another position.
|
|
102
|
+
# @async
|
|
103
|
+
#
|
|
104
|
+
# @param [Integer] position The position to move the channel.
|
|
105
|
+
# @param [Boolean] lock_permissions Whether to lock the permissions of the channel.
|
|
106
|
+
# @param [Discorb::CategoryChannel] parent The parent of channel.
|
|
107
|
+
# @param [String] reason The reason of moving the channel.
|
|
108
|
+
#
|
|
109
|
+
# @return [Async::Task<self>] The moved channel.
|
|
110
|
+
def move: (
|
|
111
|
+
Integer position,
|
|
112
|
+
?lock_permissions: bool,
|
|
113
|
+
?parent: Discorb::CategoryChannel,
|
|
114
|
+
?reason: String?
|
|
115
|
+
) -> Async::Task[self]
|
|
116
|
+
|
|
117
|
+
#
|
|
118
|
+
# Set the channel's permission overwrite.
|
|
119
|
+
# @async
|
|
120
|
+
#
|
|
121
|
+
# @param [Discorb::Role, Discorb::Member] target The target of the overwrite.
|
|
122
|
+
# @param [String] reason The reason of setting the overwrite.
|
|
123
|
+
# @param [{Symbol => Boolean}] perms The permission overwrites to replace.
|
|
124
|
+
#
|
|
125
|
+
# @return [Async::Task<void>] The task.
|
|
126
|
+
def set_permissions: (
|
|
127
|
+
Discorb::Role | Discorb::Member target,
|
|
128
|
+
?reason: String?,
|
|
129
|
+
**bool perms
|
|
130
|
+
) -> Async::Task[void]
|
|
131
|
+
|
|
132
|
+
#
|
|
133
|
+
# Delete the channel's permission overwrite.
|
|
134
|
+
# @async
|
|
135
|
+
#
|
|
136
|
+
# @param [Discorb::Role, Discorb::Member] target The target of the overwrite.
|
|
137
|
+
# @param [String] reason The reason of deleting the overwrite.
|
|
138
|
+
#
|
|
139
|
+
# @return [Async::Task<void>] The task.
|
|
140
|
+
def delete_permissions: (
|
|
141
|
+
Discorb::Role | Discorb::Member target,
|
|
142
|
+
?reason: String?
|
|
143
|
+
) -> Async::Task[void]
|
|
144
|
+
|
|
145
|
+
#
|
|
146
|
+
# Fetch the channel's invites.
|
|
147
|
+
# @async
|
|
148
|
+
#
|
|
149
|
+
# @return [Async::Task<Array<Discorb::Invite>>] The invites in the channel.
|
|
150
|
+
def fetch_invites: -> Async::Task[::Array[Discorb::Invite]]
|
|
151
|
+
|
|
152
|
+
#
|
|
153
|
+
# Create an invite in the channel.
|
|
154
|
+
# @async
|
|
155
|
+
#
|
|
156
|
+
# @param [Integer] max_age The max age of the invite.
|
|
157
|
+
# @param [Integer] max_uses The max uses of the invite.
|
|
158
|
+
# @param [Boolean] temporary Whether the invite is temporary.
|
|
159
|
+
# @param [Boolean] unique Whether the invite is unique.
|
|
160
|
+
# @note if it's `false` it may return existing invite.
|
|
161
|
+
# @param [String] reason The reason of creating the invite.
|
|
162
|
+
#
|
|
163
|
+
# @return [Async::Task<Invite>] The created invite.
|
|
164
|
+
def create_invite: (
|
|
165
|
+
?max_age: Integer?,
|
|
166
|
+
?max_uses: Integer?,
|
|
167
|
+
?temporary: bool,
|
|
168
|
+
?unique: bool,
|
|
169
|
+
?reason: String?
|
|
170
|
+
) -> Async::Task[Invite]
|
|
171
|
+
|
|
172
|
+
# @return [Integer] The position of the channel as integer.
|
|
173
|
+
attr_reader position: Integer
|
|
174
|
+
|
|
175
|
+
# @return [Hash{Discorb::Role, Discorb::Member => PermissionOverwrite}] The permission overwrites of the channel.
|
|
176
|
+
attr_reader permission_overwrites: Hash[Discorb::Role
|
|
177
|
+
| Discorb::Member, Discorb::PermissionOverwrite]
|
|
178
|
+
end
|
|
179
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a category in a guild.
|
|
4
|
+
class CategoryChannel < Discorb::GuildChannel
|
|
5
|
+
include Discorb::ChannelContainer
|
|
6
|
+
|
|
7
|
+
def channels: -> Array[Discorb::GuildChannel]
|
|
8
|
+
|
|
9
|
+
def create_text_channel: (
|
|
10
|
+
String name,
|
|
11
|
+
?topic: String?,
|
|
12
|
+
?rate_limit_per_user: Integer?,
|
|
13
|
+
?slowmode: Integer?,
|
|
14
|
+
?position: Integer?,
|
|
15
|
+
?nsfw: bool?,
|
|
16
|
+
?permission_overwrites: Hash[(Discorb::Role
|
|
17
|
+
| Discorb::Member), Discorb::PermissionOverwrite]?,
|
|
18
|
+
?parent: Discorb::CategoryChannel?,
|
|
19
|
+
?reason: String?
|
|
20
|
+
) -> Async::Task[Discorb::TextChannel]
|
|
21
|
+
|
|
22
|
+
def create_voice_channel: (
|
|
23
|
+
String name,
|
|
24
|
+
?bitrate: Integer,
|
|
25
|
+
?user_limit: Integer?,
|
|
26
|
+
?position: Integer?,
|
|
27
|
+
?permission_overwrites: Hash[(Discorb::Role
|
|
28
|
+
| Discorb::Member), Discorb::PermissionOverwrite]?,
|
|
29
|
+
?parent: Discorb::CategoryChannel?,
|
|
30
|
+
?reason: String?
|
|
31
|
+
) -> Async::Task[Discorb::VoiceChannel]
|
|
32
|
+
|
|
33
|
+
def create_news_channel: (
|
|
34
|
+
String name,
|
|
35
|
+
?topic: String?,
|
|
36
|
+
?rate_limit_per_user: Integer?,
|
|
37
|
+
?slowmode: Integer?,
|
|
38
|
+
?position: Integer?,
|
|
39
|
+
?nsfw: bool?,
|
|
40
|
+
?permission_overwrites: Hash[(Discorb::Role
|
|
41
|
+
| Discorb::Member), Discorb::PermissionOverwrite]?,
|
|
42
|
+
?parent: Discorb::CategoryChannel?,
|
|
43
|
+
?reason: String?
|
|
44
|
+
) -> Async::Task[Discorb::NewsChannel]
|
|
45
|
+
|
|
46
|
+
def create_stage_channel: (
|
|
47
|
+
String name,
|
|
48
|
+
?bitrate: Integer,
|
|
49
|
+
?position: Integer?,
|
|
50
|
+
?permission_overwrites: Hash[(Discorb::Role
|
|
51
|
+
| Discorb::Member), Discorb::PermissionOverwrite]?,
|
|
52
|
+
?parent: Discorb::CategoryChannel?,
|
|
53
|
+
?reason: String?
|
|
54
|
+
) -> Async::Task[Discorb::StageChannel]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Module for container of channels.
|
|
4
|
+
module ChannelContainer
|
|
5
|
+
#
|
|
6
|
+
# Returns text channels.
|
|
7
|
+
#
|
|
8
|
+
# @return [Array<Discorb::TextChannel>] The text channels.
|
|
9
|
+
def text_channels: -> ::Array[Discorb::TextChannel]
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# Returns voice channels.
|
|
13
|
+
#
|
|
14
|
+
# @return [Array<Discorb::VoiceChannel>] The voice channels.
|
|
15
|
+
def voice_channels: -> ::Array[Discorb::VoiceChannel]
|
|
16
|
+
|
|
17
|
+
#
|
|
18
|
+
# Returns news channels.
|
|
19
|
+
#
|
|
20
|
+
# @return [Array<Discorb::NewsChannel>] The news channels.
|
|
21
|
+
def news_channels: -> ::Array[Discorb::NewsChannel]
|
|
22
|
+
|
|
23
|
+
#
|
|
24
|
+
# Returns stage channels.
|
|
25
|
+
#
|
|
26
|
+
# @return [Array<Discorb::StageChannel>] The stage channels.
|
|
27
|
+
def stage_channels: -> ::Array[Discorb::StageChannel]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a DM channel.
|
|
4
|
+
class DMChannel < Discorb::Channel
|
|
5
|
+
include Discorb::Messageable
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# Returns the channel id to request.
|
|
9
|
+
# @private
|
|
10
|
+
#
|
|
11
|
+
# @return [Async::Task<Discorb::Snowflake>] A task that resolves to the channel id.
|
|
12
|
+
def channel_id: -> Async::Task[Discorb::Snowflake]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a news channel (announcement channel).
|
|
4
|
+
class NewsChannel < Discorb::TextChannel
|
|
5
|
+
DEFAULT_AUTO_ARCHIVE_DURATION: untyped
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# Follow the existing announcement channel from self.
|
|
9
|
+
# @async
|
|
10
|
+
#
|
|
11
|
+
# @param [Discorb::TextChannel] target The channel to follow to.
|
|
12
|
+
# @param [String] reason The reason of following the channel.
|
|
13
|
+
#
|
|
14
|
+
# @return [Async::Task<void>] The task.
|
|
15
|
+
def follow_to: (
|
|
16
|
+
Discorb::TextChannel target,
|
|
17
|
+
?reason: String?
|
|
18
|
+
) -> Async::Task[void]
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a stage channel.
|
|
4
|
+
class StageChannel < Discorb::GuildChannel
|
|
5
|
+
include Discorb::Connectable
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# Initialize a new stage channel.
|
|
9
|
+
# @private
|
|
10
|
+
def initialize: -> void
|
|
11
|
+
|
|
12
|
+
def stage_instance: -> untyped
|
|
13
|
+
|
|
14
|
+
#
|
|
15
|
+
# Edit the stage channel.
|
|
16
|
+
# @async
|
|
17
|
+
# @macro edit
|
|
18
|
+
#
|
|
19
|
+
# @param [String] name The name of the stage channel.
|
|
20
|
+
# @param [Integer] position The position of the stage channel.
|
|
21
|
+
# @param [Integer] bitrate The bitrate of the stage channel.
|
|
22
|
+
# @param [Symbol] rtc_region The region of the stage channel.
|
|
23
|
+
# @param [String] reason The reason of editing the stage channel.
|
|
24
|
+
#
|
|
25
|
+
# @return [Async::Task<self>] The edited stage channel.
|
|
26
|
+
def edit: (
|
|
27
|
+
?name: String,
|
|
28
|
+
?position: Integer,
|
|
29
|
+
?bitrate: Integer,
|
|
30
|
+
?rtc_region: Symbol,
|
|
31
|
+
?reason: String?
|
|
32
|
+
) -> Async::Task[self]
|
|
33
|
+
|
|
34
|
+
#
|
|
35
|
+
# Start a stage instance.
|
|
36
|
+
# @async
|
|
37
|
+
#
|
|
38
|
+
# @param [String] topic The topic of the stage instance.
|
|
39
|
+
# @param [Boolean] public Whether the stage instance is public or not.
|
|
40
|
+
# @param [String] reason The reason of starting the stage instance.
|
|
41
|
+
#
|
|
42
|
+
# @return [Async::Task<Discorb::StageInstance>] The started stage instance.
|
|
43
|
+
def start: (
|
|
44
|
+
String topic,
|
|
45
|
+
?public: bool,
|
|
46
|
+
?reason: String?
|
|
47
|
+
) -> Async::Task[Discorb::StageInstance]
|
|
48
|
+
|
|
49
|
+
#
|
|
50
|
+
# Fetch a current stage instance.
|
|
51
|
+
# @async
|
|
52
|
+
#
|
|
53
|
+
# @return [Async::Task<StageInstance>] The current stage instance.
|
|
54
|
+
# @return [Async::Task<nil>] If there is no current stage instance.
|
|
55
|
+
def fetch_stage_instance: -> Async::Task[StageInstance]
|
|
56
|
+
|
|
57
|
+
def voice_states: -> Array[Discorb::VoiceState]
|
|
58
|
+
|
|
59
|
+
def members: -> Array[Discorb::Member]
|
|
60
|
+
|
|
61
|
+
def speakers: -> Array[Discorb::Member]
|
|
62
|
+
|
|
63
|
+
def audiences: -> Array[Discorb::Member]
|
|
64
|
+
|
|
65
|
+
# @return [Integer] The bitrate of the voice channel.
|
|
66
|
+
attr_reader bitrate: Integer
|
|
67
|
+
|
|
68
|
+
# @return [Integer] The user limit of the voice channel.
|
|
69
|
+
attr_reader user_limit: Integer
|
|
70
|
+
|
|
71
|
+
#
|
|
72
|
+
# @private
|
|
73
|
+
# @return [Discorb::Dictionary{Discorb::Snowflake => StageInstance}]
|
|
74
|
+
# The stage instances associated with the stage channel.
|
|
75
|
+
attr_reader stage_instances: Discorb::Dictionary[Discorb::Snowflake, StageInstance]
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a text channel.
|
|
4
|
+
class TextChannel < Discorb::GuildChannel
|
|
5
|
+
include Discorb::Messageable
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# Edits the channel.
|
|
9
|
+
# @async
|
|
10
|
+
# @macro edit
|
|
11
|
+
#
|
|
12
|
+
# @param [String] name The name of the channel.
|
|
13
|
+
# @param [Integer] position The position of the channel.
|
|
14
|
+
# @param [Discorb::CategoryChannel, nil] category The parent of channel. Specify `nil` to remove the parent.
|
|
15
|
+
# @param [Discorb::CategoryChannel, nil] parent Alias of `category`.
|
|
16
|
+
# @param [String] topic The topic of the channel.
|
|
17
|
+
# @param [Boolean] nsfw Whether the channel is nsfw.
|
|
18
|
+
# @param [Boolean] announce Whether the channel is announce channel.
|
|
19
|
+
# @param [Integer] rate_limit_per_user The rate limit per user (Slowmode) in the channel.
|
|
20
|
+
# @param [Integer] slowmode Alias of `rate_limit_per_user`.
|
|
21
|
+
# @param [Integer] default_auto_archive_duration The default auto archive duration of the channel.
|
|
22
|
+
# @param [Integer] archive_in Alias of `default_auto_archive_duration`.
|
|
23
|
+
# @param [String] reason The reason of editing the channel.
|
|
24
|
+
#
|
|
25
|
+
# @return [Async::Task<self>] The edited channel.
|
|
26
|
+
def edit: (
|
|
27
|
+
?name: String,
|
|
28
|
+
?position: Integer,
|
|
29
|
+
?category: Discorb::CategoryChannel?,
|
|
30
|
+
?parent: Discorb::CategoryChannel?,
|
|
31
|
+
?topic: String,
|
|
32
|
+
?nsfw: bool,
|
|
33
|
+
?announce: bool,
|
|
34
|
+
?rate_limit_per_user: Integer,
|
|
35
|
+
?slowmode: Integer,
|
|
36
|
+
?default_auto_archive_duration: 60 | 1440 | 4320 | 10080,
|
|
37
|
+
?archive_in: Integer,
|
|
38
|
+
?reason: String?
|
|
39
|
+
) -> Async::Task[self]
|
|
40
|
+
|
|
41
|
+
#
|
|
42
|
+
# Create webhook in the channel.
|
|
43
|
+
# @async
|
|
44
|
+
#
|
|
45
|
+
# @param [String] name The name of the webhook.
|
|
46
|
+
# @param [Discorb::Image] avatar The avatar of the webhook.
|
|
47
|
+
#
|
|
48
|
+
# @return [Async::Task<Discorb::Webhook::IncomingWebhook>] The created webhook.
|
|
49
|
+
def create_webhook: (
|
|
50
|
+
String name,
|
|
51
|
+
?avatar: Discorb::Image?
|
|
52
|
+
) -> Async::Task[Discorb::Webhook::IncomingWebhook]
|
|
53
|
+
|
|
54
|
+
#
|
|
55
|
+
# Fetch webhooks in the channel.
|
|
56
|
+
# @async
|
|
57
|
+
#
|
|
58
|
+
# @return [Async::Task<Array<Discorb::Webhook>>] The webhooks in the channel.
|
|
59
|
+
def fetch_webhooks: -> Async::Task[::Array[Discorb::Webhook]]
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
# Bulk delete messages in the channel.
|
|
63
|
+
# @async
|
|
64
|
+
#
|
|
65
|
+
# @param [Discorb::Message] messages The messages to delete.
|
|
66
|
+
# @param [Boolean] force Whether to ignore the validation for message (14 days limit).
|
|
67
|
+
#
|
|
68
|
+
# @return [Async::Task<void>] The task.
|
|
69
|
+
def delete_messages!:
|
|
70
|
+
(*Discorb::Message messages, ?force: bool) -> Async::Task[void]
|
|
71
|
+
| (*Array[Discorb::Message] messages, ?force: bool) -> Async::Task[void]
|
|
72
|
+
|
|
73
|
+
#
|
|
74
|
+
# Follow the existing announcement channel.
|
|
75
|
+
# @async
|
|
76
|
+
#
|
|
77
|
+
# @param [Discorb::NewsChannel] target The channel to follow.
|
|
78
|
+
# @param [String] reason The reason of following the channel.
|
|
79
|
+
#
|
|
80
|
+
# @return [Async::Task<void>] The task.
|
|
81
|
+
def follow_from: (
|
|
82
|
+
Discorb::NewsChannel target,
|
|
83
|
+
?reason: String?
|
|
84
|
+
) -> Async::Task[void]
|
|
85
|
+
|
|
86
|
+
#
|
|
87
|
+
# Start thread in the channel.
|
|
88
|
+
# @async
|
|
89
|
+
#
|
|
90
|
+
# @param [String] name The name of the thread.
|
|
91
|
+
# @param [Discorb::Message] message The message to start the thread.
|
|
92
|
+
# @param [:hour, :day, :three_days, :week] auto_archive_duration The duration of auto-archiving.
|
|
93
|
+
# @param [Boolean] public Whether the thread is public.
|
|
94
|
+
# @param [Integer] rate_limit_per_user The rate limit per user.
|
|
95
|
+
# @param [Integer] slowmode Alias of `rate_limit_per_user`.
|
|
96
|
+
# @param [String] reason The reason of starting the thread.
|
|
97
|
+
#
|
|
98
|
+
# @return [Async::Task<Discorb::ThreadChannel>] The started thread.
|
|
99
|
+
def start_thread: (
|
|
100
|
+
String name,
|
|
101
|
+
?message: Discorb::Message?,
|
|
102
|
+
?auto_archive_duration: Symbol?,
|
|
103
|
+
?public: bool,
|
|
104
|
+
?rate_limit_per_user: Integer?,
|
|
105
|
+
?slowmode: Integer?,
|
|
106
|
+
?reason: String?
|
|
107
|
+
) -> Async::Task[Discorb::ThreadChannel]
|
|
108
|
+
|
|
109
|
+
#
|
|
110
|
+
# Fetch archived threads in the channel.
|
|
111
|
+
# @async
|
|
112
|
+
#
|
|
113
|
+
# @return [Async::Task<Array<Discorb::ThreadChannel>>] The archived threads in the channel.
|
|
114
|
+
def fetch_archived_public_threads: -> Async::Task[::Array[Discorb::ThreadChannel]]
|
|
115
|
+
|
|
116
|
+
#
|
|
117
|
+
# Fetch archived private threads in the channel.
|
|
118
|
+
# @async
|
|
119
|
+
#
|
|
120
|
+
# @return [Async::Task<Array<Discorb::ThreadChannel>>] The archived private threads in the channel.
|
|
121
|
+
def fetch_archived_private_threads: -> Async::Task[::Array[Discorb::ThreadChannel]]
|
|
122
|
+
|
|
123
|
+
#
|
|
124
|
+
# Fetch joined archived private threads in the channel.
|
|
125
|
+
# @async
|
|
126
|
+
#
|
|
127
|
+
# @param [Integer] limit The limit of threads to fetch.
|
|
128
|
+
# @param [Time] before <description>
|
|
129
|
+
#
|
|
130
|
+
# @return [Async::Task<Array<Discorb::ThreadChannel>>] The joined archived private threads in the channel.
|
|
131
|
+
def fetch_joined_archived_private_threads: (
|
|
132
|
+
?limit: Integer?,
|
|
133
|
+
?before: Time?
|
|
134
|
+
) -> Async::Task[::Array[Discorb::ThreadChannel]]
|
|
135
|
+
|
|
136
|
+
# @return [String] The topic of the channel.
|
|
137
|
+
attr_reader topic: String
|
|
138
|
+
|
|
139
|
+
# @return [Boolean] Whether the channel is nsfw.
|
|
140
|
+
attr_reader nsfw: bool
|
|
141
|
+
|
|
142
|
+
# @return [Discorb::Snowflake] The id of the last message.
|
|
143
|
+
attr_reader last_message_id: Discorb::Snowflake
|
|
144
|
+
|
|
145
|
+
# @return [Integer] The rate limit per user (Slowmode) in the channel.
|
|
146
|
+
attr_reader rate_limit_per_user: Integer
|
|
147
|
+
|
|
148
|
+
# @return [Time] The time when the last pinned message was pinned.
|
|
149
|
+
attr_reader last_pin_timestamp: Time
|
|
150
|
+
|
|
151
|
+
# @return [Integer] The default value of duration of auto archive.
|
|
152
|
+
attr_reader default_auto_archive_duration: 60 | 1440 | 4320 | 10080
|
|
153
|
+
|
|
154
|
+
# @!attribute [r] threads
|
|
155
|
+
# @return [Array<Discorb::ThreadChannel>] The threads in the channel.
|
|
156
|
+
attr_reader threads: untyped
|
|
157
|
+
end
|
|
158
|
+
end
|