discorb 0.16.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) 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 +2 -4
  8. data/.github/workflows/spec.yml +33 -0
  9. data/.github/workflows/validate.yml +21 -0
  10. data/.gitignore +2 -0
  11. data/.lefthook/commit-msg/validator.rb +5 -0
  12. data/.rspec +2 -0
  13. data/.rspec_parallel +2 -0
  14. data/.rubocop.yml +43 -6
  15. data/Changelog.md +30 -1
  16. data/Gemfile +20 -8
  17. data/Rakefile +226 -98
  18. data/Steepfile +28 -0
  19. data/bin/console +3 -3
  20. data/docs/Examples.md +1 -1
  21. data/docs/application_command.md +156 -47
  22. data/docs/cli/irb.md +2 -2
  23. data/docs/cli/new.md +14 -9
  24. data/docs/cli/run.md +7 -11
  25. data/docs/cli.md +17 -10
  26. data/docs/events.md +247 -213
  27. data/docs/extension.md +1 -2
  28. data/docs/faq.md +0 -1
  29. data/docs/tutorial.md +18 -18
  30. data/docs/voice_events.md +106 -106
  31. data/examples/commands/message.rb +68 -0
  32. data/examples/commands/permission.rb +19 -0
  33. data/examples/commands/slash.rb +48 -0
  34. data/examples/commands/user.rb +54 -0
  35. data/examples/components/authorization_button.rb +4 -3
  36. data/examples/components/select_menu.rb +6 -3
  37. data/examples/extension/main.rb +2 -1
  38. data/examples/extension/message_expander.rb +6 -2
  39. data/examples/sig/commands/message.rbs +5 -0
  40. data/examples/simple/eval.rb +3 -2
  41. data/examples/simple/ping_pong.rb +2 -1
  42. data/examples/simple/rolepanel.rb +17 -6
  43. data/examples/simple/shard.rb +3 -2
  44. data/examples/simple/wait_for_message.rb +4 -1
  45. data/exe/discorb +33 -18
  46. data/lefthook.yml +45 -0
  47. data/lib/discorb/allowed_mentions.rb +2 -1
  48. data/lib/discorb/app_command/command.rb +130 -72
  49. data/lib/discorb/app_command/common.rb +25 -0
  50. data/lib/discorb/app_command/handler.rb +130 -33
  51. data/lib/discorb/app_command.rb +2 -1
  52. data/lib/discorb/application.rb +1 -0
  53. data/lib/discorb/asset.rb +1 -2
  54. data/lib/discorb/attachment.rb +1 -1
  55. data/lib/discorb/audit_logs.rb +19 -10
  56. data/lib/discorb/automod.rb +269 -0
  57. data/lib/discorb/channel/base.rb +108 -0
  58. data/lib/discorb/channel/category.rb +32 -0
  59. data/lib/discorb/channel/container.rb +44 -0
  60. data/lib/discorb/channel/dm.rb +28 -0
  61. data/lib/discorb/channel/guild.rb +246 -0
  62. data/lib/discorb/channel/stage.rb +140 -0
  63. data/lib/discorb/channel/text.rb +336 -0
  64. data/lib/discorb/channel/thread.rb +325 -0
  65. data/lib/discorb/channel/voice.rb +79 -0
  66. data/lib/discorb/channel.rb +2 -1165
  67. data/lib/discorb/client.rb +50 -36
  68. data/lib/discorb/color.rb +37 -60
  69. data/lib/discorb/common.rb +2 -1
  70. data/lib/discorb/components/button.rb +2 -1
  71. data/lib/discorb/components/select_menu.rb +4 -2
  72. data/lib/discorb/components/text_input.rb +12 -2
  73. data/lib/discorb/components.rb +1 -1
  74. data/lib/discorb/dictionary.rb +1 -1
  75. data/lib/discorb/embed.rb +26 -10
  76. data/lib/discorb/emoji.rb +31 -4
  77. data/lib/discorb/emoji_table.rb +4969 -3
  78. data/lib/discorb/event.rb +29 -4
  79. data/lib/discorb/exe/about.rb +2 -1
  80. data/lib/discorb/exe/irb.rb +2 -4
  81. data/lib/discorb/exe/new.rb +89 -26
  82. data/lib/discorb/exe/run.rb +8 -22
  83. data/lib/discorb/exe/setup.rb +25 -12
  84. data/lib/discorb/exe/show.rb +4 -3
  85. data/lib/discorb/extend.rb +1 -0
  86. data/lib/discorb/extension.rb +6 -7
  87. data/lib/discorb/flag.rb +13 -2
  88. data/lib/discorb/gateway.rb +79 -589
  89. data/lib/discorb/gateway_events.rb +638 -0
  90. data/lib/discorb/guild.rb +318 -67
  91. data/lib/discorb/guild_template.rb +11 -5
  92. data/lib/discorb/http.rb +53 -24
  93. data/lib/discorb/integration.rb +4 -1
  94. data/lib/discorb/intents.rb +28 -19
  95. data/lib/discorb/interaction/autocomplete.rb +28 -16
  96. data/lib/discorb/interaction/command.rb +42 -14
  97. data/lib/discorb/interaction/components.rb +5 -2
  98. data/lib/discorb/interaction/modal.rb +0 -1
  99. data/lib/discorb/interaction/response.rb +125 -26
  100. data/lib/discorb/interaction/root.rb +13 -13
  101. data/lib/discorb/interaction.rb +1 -0
  102. data/lib/discorb/invite.rb +5 -2
  103. data/lib/discorb/member.rb +28 -8
  104. data/lib/discorb/message.rb +60 -25
  105. data/lib/discorb/message_meta.rb +3 -3
  106. data/lib/discorb/modules.rb +59 -16
  107. data/lib/discorb/presence.rb +2 -0
  108. data/lib/discorb/rate_limit.rb +7 -2
  109. data/lib/discorb/reaction.rb +2 -2
  110. data/lib/discorb/role.rb +20 -5
  111. data/lib/discorb/shard.rb +1 -1
  112. data/lib/discorb/sticker.rb +9 -8
  113. data/lib/discorb/user.rb +4 -3
  114. data/lib/discorb/utils/colored_puts.rb +1 -0
  115. data/lib/discorb/voice_state.rb +6 -2
  116. data/lib/discorb/webhook.rb +64 -31
  117. data/lib/discorb.rb +7 -5
  118. data/po/yard.pot +20 -20
  119. data/rbs_collection.lock.yaml +88 -0
  120. data/rbs_collection.yaml +21 -0
  121. data/sig/async.rbs +11 -0
  122. data/sig/discorb/activity.rbs +23 -0
  123. data/sig/discorb/allowed_mentions.rbs +44 -0
  124. data/sig/discorb/app_command/base.rbs +282 -0
  125. data/sig/discorb/app_command/handler.rbs +171 -0
  126. data/sig/discorb/application.rbs +142 -0
  127. data/sig/discorb/asset.rbs +32 -0
  128. data/sig/discorb/attachment.rbs +91 -0
  129. data/sig/discorb/audit_log.rbs +231 -0
  130. data/sig/discorb/automod.rbs +128 -0
  131. data/sig/discorb/avatar.rbs +26 -0
  132. data/sig/discorb/channel/base.rbs +179 -0
  133. data/sig/discorb/channel/category.rbs +56 -0
  134. data/sig/discorb/channel/container.rbs +29 -0
  135. data/sig/discorb/channel/dm.rbs +14 -0
  136. data/sig/discorb/channel/news.rbs +20 -0
  137. data/sig/discorb/channel/stage.rbs +77 -0
  138. data/sig/discorb/channel/text.rbs +158 -0
  139. data/sig/discorb/channel/thread.rbs +185 -0
  140. data/sig/discorb/channel/voice.rbs +41 -0
  141. data/sig/discorb/client.rbs +2495 -0
  142. data/sig/discorb/color.rbs +142 -0
  143. data/sig/discorb/component/base.rbs +28 -0
  144. data/sig/discorb/component/button.rbs +65 -0
  145. data/sig/discorb/component/select_menu.rbs +107 -0
  146. data/sig/discorb/component/text_input.rbs +69 -0
  147. data/sig/discorb/connectable.rbs +8 -0
  148. data/sig/discorb/custom_emoji.rbs +90 -0
  149. data/sig/discorb/dictionary.rbs +85 -0
  150. data/sig/discorb/discord_model.rbs +15 -0
  151. data/sig/discorb/embed.rbs +279 -0
  152. data/sig/discorb/emoji.rbs +13 -0
  153. data/sig/discorb/error.rbs +73 -0
  154. data/sig/discorb/event_handler.rbs +27 -0
  155. data/sig/discorb/extension.rbs +1734 -0
  156. data/sig/discorb/flag.rbs +72 -0
  157. data/sig/discorb/gateway.rbs +481 -0
  158. data/sig/discorb/guild.rbs +870 -0
  159. data/sig/discorb/guild_template.rbs +174 -0
  160. data/sig/discorb/http.rbs +147 -0
  161. data/sig/discorb/image.rbs +20 -0
  162. data/sig/discorb/integration.rbs +118 -0
  163. data/sig/discorb/intents.rbs +97 -0
  164. data/sig/discorb/interaction/autocomplete.rbs +9 -0
  165. data/sig/discorb/interaction/base.rbs +66 -0
  166. data/sig/discorb/interaction/command.rbs +66 -0
  167. data/sig/discorb/interaction/message_component.rbs +140 -0
  168. data/sig/discorb/interaction/modal.rbs +50 -0
  169. data/sig/discorb/interaction/responder.rbs +157 -0
  170. data/sig/discorb/invite.rbs +86 -0
  171. data/sig/discorb/member.rbs +187 -0
  172. data/sig/discorb/message.rbs +469 -0
  173. data/sig/discorb/messageable.rbs +153 -0
  174. data/sig/discorb/partial_emoji.rbs +35 -0
  175. data/sig/discorb/permissions.rbs +149 -0
  176. data/sig/discorb/presence.rbs +237 -0
  177. data/sig/discorb/reaction.rbs +33 -0
  178. data/sig/discorb/role.rbs +145 -0
  179. data/sig/discorb/scheduled_event.rbs +148 -0
  180. data/sig/discorb/shard.rbs +62 -0
  181. data/sig/discorb/snowflake.rbs +56 -0
  182. data/sig/discorb/stage_instance.rbs +63 -0
  183. data/sig/discorb/sticker.rbs +116 -0
  184. data/sig/discorb/system_channel_flag.rbs +17 -0
  185. data/sig/discorb/unicode_emoji.rbs +49 -0
  186. data/sig/discorb/user.rbs +93 -0
  187. data/sig/discorb/utils.rbs +8 -0
  188. data/sig/discorb/voice_region.rbs +30 -0
  189. data/sig/discorb/voice_state.rbs +71 -0
  190. data/sig/discorb/webhook.rbs +327 -0
  191. data/sig/discorb/welcome_screen.rbs +78 -0
  192. data/sig/discorb.rbs +6 -7230
  193. data/sig/manifest.yaml +3 -0
  194. data/sig/override.rbs +19 -0
  195. data/template-replace/files/css/common.css +4 -0
  196. metadata +102 -6
  197. data/examples/commands/bookmarker.rb +0 -42
  198. data/examples/commands/hello.rb +0 -10
  199. data/examples/commands/inspect.rb +0 -25
@@ -0,0 +1,62 @@
1
+ module Discorb
2
+ #
3
+ # Represents a shard.
4
+ class Shard
5
+ #
6
+ # Initializes a new shard.
7
+ # @private
8
+ #
9
+ # @param [Discorb::Client] client The client.
10
+ # @param [Integer] id The ID of the shard.
11
+ # @param [Integer] count The number of shards.
12
+ # @param [Integer] index The index of the shard.
13
+ def initialize: (
14
+ Discorb::Client client,
15
+ Integer id,
16
+ Integer count,
17
+ Integer index
18
+ ) -> void
19
+
20
+ #
21
+ # Starts the shard.
22
+ #
23
+ # @return [void]
24
+ def start: -> void
25
+
26
+ #
27
+ # Stops the shard.
28
+ #
29
+ # @return [void]
30
+ def close!: -> void
31
+
32
+ def inspect: -> String
33
+
34
+ # @return [Integer] The ID of the shard.
35
+ attr_reader id: Integer
36
+
37
+ # @return [Thread] The thread of the shard.
38
+ attr_reader thread: Thread
39
+
40
+ # @return [Logger] The logger of the shard.
41
+ attr_reader logger: Logger
42
+
43
+ # @private
44
+ # @return [Integer] The internal index of the shard.
45
+ attr_reader index: Integer
46
+
47
+ # @private
48
+ attr_accessor status: untyped
49
+
50
+ # @private
51
+ attr_accessor connection: untyped
52
+
53
+ # @private
54
+ attr_accessor session_id: untyped
55
+
56
+ # @private
57
+ attr_accessor next_shard: untyped
58
+
59
+ # @private
60
+ attr_accessor main_task: untyped
61
+ end
62
+ end
@@ -0,0 +1,56 @@
1
+ module Discorb
2
+ #
3
+ # Represents Snowflake of Discord.
4
+ #
5
+ # @see https://discord.com/developers/docs/reference#snowflakes Official Discord API docs
6
+ class Snowflake < String
7
+ #
8
+ # Initialize new snowflake.
9
+ # @private
10
+ #
11
+ # @param [#to_s] value The value of the snowflake.
12
+ def initialize: (untyped value) -> void
13
+
14
+ #
15
+ # Compares snowflake with other object.
16
+ #
17
+ # @param [#to_s] other Object to compare with.
18
+ #
19
+ # @return [Boolean] True if snowflake is equal to other object.
20
+ def ==: (untyped other) -> bool
21
+
22
+ #
23
+ # Alias of {#==}.
24
+ def eql?: (untyped other) -> bool
25
+
26
+ # Return hash of snowflake.
27
+ def hash: -> untyped
28
+
29
+ def inspect: -> String
30
+
31
+ # Timestamp of snowflake.
32
+ #
33
+ # @return [Time] Timestamp of snowflake.
34
+ attr_reader timestamp: Time
35
+
36
+ # Worker ID of snowflake.
37
+ #
38
+ # @return [Integer] Worker ID of snowflake.
39
+ attr_reader worker_id: Integer
40
+
41
+ # Process ID of snowflake.
42
+ #
43
+ # @return [Integer] Process ID of snowflake.
44
+ attr_reader process_id: Integer
45
+
46
+ # Increment of snowflake.
47
+ #
48
+ # @return [Integer] Increment of snowflake.
49
+ attr_reader increment: Integer
50
+
51
+ # Alias of to_s.
52
+ #
53
+ # @return [String] The snowflake.
54
+ attr_reader id: String
55
+ end
56
+ end
@@ -0,0 +1,63 @@
1
+ module Discorb
2
+ #
3
+ # Represents a stage instance of a voice state.
4
+ class StageInstance < Discorb::DiscordModel
5
+ #
6
+ # Initialize a new instance of the StageInstance class.
7
+ # @private
8
+ #
9
+ # @param [Discorb::Client] client The client.
10
+ # @param [Hash] data The data of the stage instance.
11
+ # @param [Boolean] no_cache Whether to disable caching.
12
+ def initialize: (
13
+ Discorb::Client client,
14
+ Discorb::json data,
15
+ ?no_cache: bool
16
+ ) -> void
17
+
18
+ def guild: -> untyped
19
+
20
+ def channel: -> untyped
21
+
22
+ def discoverable?: -> bool
23
+
24
+ def public?: -> bool
25
+
26
+ def guild_only?: -> bool
27
+
28
+ def inspect: -> String
29
+
30
+ #
31
+ # Edits the stage instance.
32
+ # @async
33
+ # @macro edit
34
+ #
35
+ # @param [String] topic The new topic of the stage instance.
36
+ # @param [:public, :guild_only] privacy_level The new privacy level of the stage instance.
37
+ # @param [String] reason The reason for editing the stage instance.
38
+ #
39
+ # @return [Async::Task<void>] The task.
40
+ def edit: (
41
+ ?topic: String,
42
+ ?privacy_level: Symbol,
43
+ ?reason: String?
44
+ ) -> Async::Task[void]
45
+
46
+ #
47
+ # Deletes the stage instance.
48
+ #
49
+ # @param [String] reason The reason for deleting the stage instance.
50
+ #
51
+ # @return [Async::Task<void>] The task.
52
+ def delete!: (?reason: String?) -> Async::Task[void]
53
+
54
+ # @return [Discorb::Snowflake] The ID of the guild this voice state is for.
55
+ attr_reader id: Discorb::Snowflake
56
+
57
+ # @return [String] The topic of the stage instance.
58
+ attr_reader topic: String
59
+
60
+ # @return [:public, :guild_only] The privacy level of the stage instance.
61
+ attr_reader privacy_level: Symbol
62
+ end
63
+ end
@@ -0,0 +1,116 @@
1
+ module Discorb
2
+ #
3
+ # Represents a sticker.
4
+ class Sticker < Discorb::DiscordModel
5
+ STICKER_TYPE: untyped
6
+ STICKER_FORMAT: untyped
7
+
8
+ #
9
+ # Initialize a new sticker.
10
+ # @private
11
+ #
12
+ # @param [Discorb::Client] client The client.
13
+ # @param [Hash] data The sticker data.
14
+ def initialize: (Discorb::Client client, Discorb::json data) -> void
15
+
16
+ # @return [Discorb::Snowflake] The ID of the sticker.
17
+ attr_reader id: Discorb::Snowflake
18
+
19
+ # @return [String] The name of the sticker.
20
+ attr_reader name: String
21
+
22
+ # @return [Array<String>] The tags of the sticker.
23
+ attr_reader tags: ::Array[String]
24
+
25
+ # @return [:official, :guild] The type of sticker.
26
+ attr_reader type: Symbol
27
+
28
+ # @return [:png, :apng, :lottie] The format of the sticker.
29
+ attr_reader format: Symbol
30
+
31
+ # @return [String] The URL of the sticker.
32
+ attr_reader description: String
33
+
34
+ # @return [Discorb::Snowflake] The ID of the sticker pack.
35
+ attr_reader pack_id: Discorb::Snowflake
36
+
37
+ # @return [Integer] The sort value of the sticker.
38
+ attr_reader sort_value: Integer
39
+
40
+ # @return [Discorb::Snowflake] The ID of the guild the sticker is in.
41
+ attr_reader guild_id: Discorb::Snowflake
42
+
43
+ # @return [Discorb::User] The user who created the sticker.
44
+ attr_reader user: Discorb::User
45
+
46
+ # @return [Boolean] Whether the sticker is available.
47
+ attr_reader available: bool
48
+
49
+ #
50
+ # Represents a sticker of guilds.
51
+ class GuildSticker < Discorb::Sticker
52
+ STICKER_TYPE: untyped
53
+ STICKER_FORMAT: untyped
54
+
55
+ #
56
+ # Edits the sticker.
57
+ # @async
58
+ # @macro edit
59
+ #
60
+ # @param [String] name The new name of the sticker.
61
+ # @param [String] description The new description of the sticker.
62
+ # @param [Discorb::emoji] tag The new tags of the sticker.
63
+ # @param [String] reason The reason for the edit.
64
+ #
65
+ # @return [Async::Task<void>] The task.
66
+ def edit: (
67
+ ?name: String,
68
+ ?description: String,
69
+ ?tag: Discorb::emoji,
70
+ ?reason: String
71
+ ) -> Async::Task[void]
72
+
73
+ #
74
+ # Deletes the sticker.
75
+ # @async
76
+ #
77
+ # @param [String] reason The reason for the deletion.
78
+ def delete!: (?reason: String?) -> untyped
79
+
80
+ # @!attribute [r] guild
81
+ # @macro client_cache
82
+ # @return [Discorb::Guild] The guild the sticker is in.
83
+ attr_reader guild: untyped
84
+ end
85
+
86
+ #
87
+ # Represents a sticker pack.
88
+ class Pack < Discorb::DiscordModel
89
+ #
90
+ # Initialize a new sticker pack.
91
+ # @private
92
+ #
93
+ # @param [Discorb::Client] client The client.
94
+ # @param [Hash] data The sticker pack data.
95
+ def initialize: (Discorb::Client client, Discorb::json data) -> void
96
+
97
+ # @return [Discorb::Snowflake] The ID of the sticker pack.
98
+ attr_reader id: Discorb::Snowflake
99
+
100
+ # @return [String] The name of the sticker pack.
101
+ attr_reader name: String
102
+
103
+ # @return [Discorb::Snowflake] The cover sticker of the pack.
104
+ attr_reader cover_sticker_id: Discorb::Snowflake
105
+
106
+ # @return [String] The description of the pack.
107
+ attr_reader description: String
108
+
109
+ # @return [Array<Discorb::Sticker>] The stickers in the pack.
110
+ attr_reader stickers: ::Array[Discorb::Sticker]
111
+
112
+ # @return [Discorb::Asset] The banner of the pack.
113
+ attr_reader banner: Discorb::Asset
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,17 @@
1
+ module Discorb
2
+ #
3
+ # Represents a system channel flag.
4
+ # ## Flag fields
5
+ # |Field|Value|
6
+ # |-|-|
7
+ # |`1 << 0`|`:member_join`|
8
+ # |`1 << 1`|`:server_boost`|
9
+ # |`1 << 2`|`:setup_tips`|
10
+ # |`1 << 3`|`:join_stickers`|
11
+ class SystemChannelFlag < Discorb::Flag
12
+ attr_accessor member_join: bool
13
+ attr_accessor server_boost: bool
14
+ attr_accessor setup_tips: bool
15
+ attr_accessor join_stickers: bool
16
+ end
17
+ end
@@ -0,0 +1,49 @@
1
+ module Discorb
2
+ #
3
+ # Represents a unicode emoji (default emoji) in discord.
4
+ class UnicodeEmoji < Discorb::Emoji
5
+ #
6
+ # Initialize a new unicode emoji.
7
+ #
8
+ # @param [String] name The name of the emoji.
9
+ # @param [Integer] tone The skin tone of the emoji.
10
+ def initialize: (String name, ?tone: Integer) -> void
11
+
12
+ # @return [String] The unicode string of the emoji.
13
+ def to_s: -> String
14
+
15
+ #
16
+ # Format the emoji for URI.
17
+ #
18
+ # @return [String] the formatted emoji.
19
+ def to_uri: -> String
20
+
21
+ def inspect: -> String
22
+
23
+ #
24
+ # Converts the object to a hash.
25
+ # @private
26
+ #
27
+ # @return [Hash] The hash represents the object.
28
+ def to_hash: -> Discorb::json
29
+
30
+ # @return [String] The name of the emoji. (e.g. :grinning:)
31
+ attr_reader name: String
32
+
33
+ # @return [String] The unicode value of the emoji. (e.g. U+1F600)
34
+ attr_reader value: String
35
+
36
+ # @return [Integer] The skin tone of the emoji.
37
+ attr_reader skin_tone: Integer
38
+
39
+ def self.[]: (String name, ?tone: Integer) -> UnicodeEmoji
40
+ end
41
+
42
+ #
43
+ # A table of emoji names and their unicode values.
44
+ module EmojiTable
45
+ DISCORD_TO_UNICODE: Hash[String, String]
46
+ UNICODE_TO_DISCORD: Hash[String, Array[String]]
47
+ SKIN_TONES: Array[String]
48
+ end
49
+ end
@@ -0,0 +1,93 @@
1
+ module Discorb
2
+ #
3
+ # Represents a user of discord.
4
+ class User < Discorb::DiscordModel
5
+ include Discorb::Messageable
6
+
7
+ #
8
+ # Initializes a new user.
9
+ # @private
10
+ #
11
+ # @param [Discorb::Client] client The client.
12
+ # @param [Hash] data The user data.
13
+ def initialize: (Discorb::Client client, json data) -> void
14
+
15
+ #
16
+ # Format the user as `Username#Discriminator` style.
17
+ #
18
+ # @return [String] The formatted username.
19
+ def to_s: -> String
20
+
21
+ def inspect: -> String
22
+
23
+ #
24
+ # Whether the user is a owner of the client.
25
+ # @async
26
+ #
27
+ # @param [Boolean] strict Whether don't allow if the user is a member of the team.
28
+ #
29
+ # @return [Async::Task<Boolean>] Whether the user is a owner of the client.
30
+ def bot_owner?: (?strict: bool) -> Async::Task[bool]
31
+
32
+ # @return [Boolean] Whether the user is verified.
33
+ attr_reader verified: bool
34
+
35
+ # @return [String] The user's username.
36
+ attr_reader username: String
37
+
38
+ # @return [Discorb::Snowflake] The user's ID.
39
+ attr_reader id: Discorb::Snowflake
40
+
41
+ # @return [Discorb::User::Flag] The user's flags.
42
+ attr_reader flag: Discorb::User::Flag
43
+
44
+ # @return [String] The user's discriminator.
45
+ attr_reader discriminator: String
46
+
47
+ # @return [Discorb::Asset, Discorb::DefaultAvatar] The user's avatar.
48
+ attr_reader avatar: Discorb::Asset | Discorb::DefaultAvatar
49
+
50
+ # @return [Boolean] Whether the user is a bot.
51
+ attr_reader bot: bool
52
+
53
+ alias bot? bot
54
+
55
+ # @return [Time] The time the user was created.
56
+ attr_reader created_at: Time
57
+
58
+ # @return [String] The user's mention.
59
+ attr_reader mention: String
60
+
61
+ #
62
+ # Represents the user's flags.
63
+ # ## Flag fields
64
+ # |`1 << 0`|`:discord_employee`|
65
+ # |`1 << 1`|`:partnered_server_owner`|
66
+ # |`1 << 2`|`:hypesquad_events`|
67
+ # |`1 << 3`|`:bug_hunter_level_1`|
68
+ # |`1 << 6`|`:house_bravery`|
69
+ # |`1 << 7`|`:house_brilliance`|
70
+ # |`1 << 8`|`:house_balance`|
71
+ # |`1 << 9`|`:early_supporter`|
72
+ # |`1 << 10`|`:team_user`|
73
+ # |`1 << 14`|`:bug_hunter_level_2`|
74
+ # |`1 << 16`|`:verified_bot`|
75
+ # |`1 << 17`|`:early_verified_bot_developer`|
76
+ # |`1 << 18`|`:discord_certified_moderator`|
77
+ class Flag < Discorb::Flag
78
+ attr_accessor discord_employee: bool
79
+ attr_accessor partnered_server_owner: bool
80
+ attr_accessor hypesquad_events: bool
81
+ attr_accessor bug_hunter_level_1: bool
82
+ attr_accessor house_bravery: bool
83
+ attr_accessor house_brilliance: bool
84
+ attr_accessor house_balance: bool
85
+ attr_accessor early_supporter: bool
86
+ attr_accessor team_user: bool
87
+ attr_accessor bug_hunter_level_2: bool
88
+ attr_accessor verified_bot: bool
89
+ attr_accessor early_verified_bot_developer: bool
90
+ attr_accessor discord_certified_moderato: bool
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,8 @@
1
+ module Discorb
2
+ # @private
3
+ module Utils
4
+ def try: (untyped object, untyped message) -> untyped
5
+
6
+ def self.try: (untyped object, untyped message) -> untyped
7
+ end
8
+ end
@@ -0,0 +1,30 @@
1
+ module Discorb
2
+ #
3
+ # Represents a voice region.
4
+ class VoiceRegion < Discorb::DiscordModel
5
+ #
6
+ # Initialize a new instance of the VoiceRegion class.
7
+ # @private
8
+ #
9
+ # @param [Hash] data The data of the voice region.
10
+ def initialize: (Discorb::json data) -> void
11
+
12
+ # @return [Discorb::Snowflake] The ID of the voice region.
13
+ attr_reader id: Discorb::Snowflake
14
+
15
+ # @return [String] The name of the voice region.
16
+ attr_reader name: String
17
+
18
+ # @return [Boolean] Whether the voice region is VIP.
19
+ attr_reader vip: bool
20
+
21
+ # @return [Boolean] Whether the voice region is optimal.
22
+ attr_reader optimal: bool
23
+
24
+ # @return [Boolean] Whether the voice region is deprecated.
25
+ attr_reader deprecated: bool
26
+
27
+ # @return [Boolean] Whether the voice region is custom.
28
+ attr_reader custom: bool
29
+ end
30
+ end
@@ -0,0 +1,71 @@
1
+ module Discorb
2
+ #
3
+ # Represents a state of user in voice channel.
4
+ class VoiceState < Discorb::DiscordModel
5
+ #
6
+ # Initialize a new voice state.
7
+ # @private
8
+ #
9
+ # @param [Discorb::Client] client The client this voice state belongs to.
10
+ # @param [Hash] data The data of the voice state.
11
+ def initialize: (Discorb::Client client, Discorb::json data) -> void
12
+
13
+ # @return [Discorb::Member] The member associated with this voice state.
14
+ attr_reader member: Discorb::Member
15
+
16
+ # @return [Discorb::Snowflake] The ID of the guild this voice state is for.
17
+ attr_reader session_id: Discorb::Snowflake
18
+
19
+ # @return [Time] The time at which the user requested to speak.
20
+ attr_reader request_to_speak_timestamp: Time
21
+
22
+ # @return [Boolean] Whether the user is deafened.
23
+ attr_reader self_deaf: bool
24
+
25
+ alias self_deaf? self_deaf
26
+
27
+ # @return [Boolean] Whether the user is muted.
28
+ attr_reader self_mute: bool
29
+
30
+ alias self_mute? self_mute
31
+
32
+ # @return [Boolean] Whether the user is streaming.
33
+ attr_reader self_stream: bool
34
+
35
+ alias self_stream? self_stream
36
+
37
+ # @return [Boolean] Whether the user is video-enabled.
38
+ attr_reader self_video: bool
39
+
40
+ alias self_video? self_video
41
+
42
+ # @return [Boolean] Whether the user is suppressed. (Is at audience)
43
+ attr_reader suppress: bool
44
+
45
+ alias suppress? suppress
46
+
47
+ # @return [Boolean] Whether the user is deafened.
48
+ attr_reader deaf?: bool
49
+
50
+ # @return [Boolean] Whether the user is muted.
51
+ attr_reader mute?: bool
52
+
53
+ # @return [Boolean] Whether the user is deafened on the server.
54
+ attr_reader server_deaf?: bool
55
+
56
+ # @return [Boolean] Whether the user is muted on the server.
57
+ attr_reader server_mute?: bool
58
+
59
+ # @macro client_cache
60
+ # @return [Discorb::Guild] The guild this voice state is for.
61
+ attr_reader guild: Discorb::Guild
62
+
63
+ # @macro client_cache
64
+ # @return [Discorb::Channel] The channel this voice state is for.
65
+ attr_reader channel: Discorb::Channel
66
+
67
+ # @macro client_cache
68
+ # @return [Discorb::User] The user this voice state is for.
69
+ attr_reader user: Discorb::User
70
+ end
71
+ end