discorb 0.19.0 → 0.20.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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build_version.yml +2 -2
  3. data/.rubocop.yml +12 -75
  4. data/Changelog.md +10 -0
  5. data/Rakefile +482 -454
  6. data/lib/discorb/allowed_mentions.rb +68 -72
  7. data/lib/discorb/app_command/command.rb +466 -398
  8. data/lib/discorb/app_command/common.rb +65 -25
  9. data/lib/discorb/app_command/handler.rb +304 -266
  10. data/lib/discorb/app_command.rb +5 -5
  11. data/lib/discorb/application.rb +198 -197
  12. data/lib/discorb/asset.rb +101 -101
  13. data/lib/discorb/attachment.rb +134 -119
  14. data/lib/discorb/audit_logs.rb +412 -385
  15. data/lib/discorb/automod.rb +279 -269
  16. data/lib/discorb/channel/base.rb +107 -108
  17. data/lib/discorb/channel/category.rb +32 -32
  18. data/lib/discorb/channel/container.rb +44 -44
  19. data/lib/discorb/channel/dm.rb +26 -28
  20. data/lib/discorb/channel/guild.rb +311 -246
  21. data/lib/discorb/channel/stage.rb +156 -140
  22. data/lib/discorb/channel/text.rb +430 -336
  23. data/lib/discorb/channel/thread.rb +374 -325
  24. data/lib/discorb/channel/voice.rb +85 -79
  25. data/lib/discorb/channel.rb +5 -5
  26. data/lib/discorb/client.rb +635 -621
  27. data/lib/discorb/color.rb +178 -182
  28. data/lib/discorb/common.rb +168 -164
  29. data/lib/discorb/components/button.rb +107 -106
  30. data/lib/discorb/components/select_menu.rb +157 -145
  31. data/lib/discorb/components/text_input.rb +103 -106
  32. data/lib/discorb/components.rb +68 -66
  33. data/lib/discorb/dictionary.rb +135 -135
  34. data/lib/discorb/embed.rb +404 -398
  35. data/lib/discorb/emoji.rb +309 -302
  36. data/lib/discorb/emoji_table.rb +16099 -8857
  37. data/lib/discorb/error.rb +131 -131
  38. data/lib/discorb/event.rb +360 -314
  39. data/lib/discorb/event_handler.rb +39 -39
  40. data/lib/discorb/exe/about.rb +17 -17
  41. data/lib/discorb/exe/irb.rb +72 -67
  42. data/lib/discorb/exe/new.rb +323 -315
  43. data/lib/discorb/exe/run.rb +69 -68
  44. data/lib/discorb/exe/setup.rb +57 -55
  45. data/lib/discorb/exe/show.rb +12 -12
  46. data/lib/discorb/extend.rb +25 -45
  47. data/lib/discorb/extension.rb +89 -83
  48. data/lib/discorb/flag.rb +126 -128
  49. data/lib/discorb/gateway.rb +984 -804
  50. data/lib/discorb/gateway_events.rb +670 -638
  51. data/lib/discorb/gateway_requests.rb +45 -48
  52. data/lib/discorb/guild.rb +2115 -1626
  53. data/lib/discorb/guild_template.rb +280 -241
  54. data/lib/discorb/http.rb +247 -232
  55. data/lib/discorb/image.rb +42 -42
  56. data/lib/discorb/integration.rb +169 -161
  57. data/lib/discorb/intents.rb +161 -163
  58. data/lib/discorb/interaction/autocomplete.rb +76 -62
  59. data/lib/discorb/interaction/command.rb +279 -224
  60. data/lib/discorb/interaction/components.rb +114 -104
  61. data/lib/discorb/interaction/modal.rb +36 -32
  62. data/lib/discorb/interaction/response.rb +379 -336
  63. data/lib/discorb/interaction/root.rb +271 -257
  64. data/lib/discorb/interaction.rb +5 -5
  65. data/lib/discorb/invite.rb +154 -153
  66. data/lib/discorb/member.rb +344 -311
  67. data/lib/discorb/message.rb +615 -544
  68. data/lib/discorb/message_meta.rb +197 -186
  69. data/lib/discorb/modules.rb +371 -290
  70. data/lib/discorb/permission.rb +305 -291
  71. data/lib/discorb/presence.rb +352 -346
  72. data/lib/discorb/rate_limit.rb +81 -76
  73. data/lib/discorb/reaction.rb +55 -54
  74. data/lib/discorb/role.rb +272 -240
  75. data/lib/discorb/shard.rb +76 -74
  76. data/lib/discorb/sticker.rb +193 -171
  77. data/lib/discorb/user.rb +205 -188
  78. data/lib/discorb/utils/colored_puts.rb +16 -16
  79. data/lib/discorb/utils.rb +12 -16
  80. data/lib/discorb/voice_state.rb +305 -281
  81. data/lib/discorb/webhook.rb +537 -507
  82. data/lib/discorb.rb +62 -56
  83. data/sig/discorb/application.rbs +2 -0
  84. data/sig/discorb/automod.rbs +10 -1
  85. data/sig/discorb/guild.rbs +2 -0
  86. data/sig/discorb/message.rbs +2 -0
  87. data/sig/discorb/user.rbs +22 -20
  88. metadata +2 -2
data/lib/discorb.rb CHANGED
@@ -1,56 +1,62 @@
1
- # frozen_string_literal: true
2
-
3
- # A new wrapper for the Discorb API.
4
- #
5
- # @author sevenc-nanashi
6
- module Discorb
7
- #
8
- # Method to define a macro for YARD.
9
- # @private
10
- #
11
- # @!macro [new] async
12
- # @note This is an asynchronous method, it will return a `Async::Task` object.
13
- # Use `Async::Task#wait` to get the result.
14
- #
15
- # @!macro [new] client_cache
16
- # @note This method returns an object from client cache. it will return `nil` if the object is not in cache.
17
- # @return [nil] The object wasn't cached.
18
- #
19
- # @!macro members_intent
20
- # @note You must enable `GUILD_MEMBERS` intent to use this method.
21
- #
22
- # @!macro edit
23
- # @note The arguments of this method are defaultly set to `Discorb::Unset`.
24
- # Specify value to set the value, if not don't specify or specify `Discorb::Unset`.
25
- #
26
- # @!macro http
27
- # @note This method calls HTTP request.
28
- # @raise [Discorb::HTTPError] HTTP request failed.
29
- #
30
- def macro
31
- puts "Wow, You found the easter egg!\n"
32
- red = "\e[31m"
33
- reset = "\e[m"
34
- puts <<~"EASTEREGG"
35
- . #{red} #{reset}
36
- | #{red} | #{reset}
37
- __| | __ __ _ #{red} _ |__ #{reset}
38
- / | | (__ / / \\ #{red}|/ | \\ #{reset}
39
- \\__| | __) \\__ \\_/ #{red}| |__/ #{reset}
40
-
41
- Thank you for using this library!
42
- EASTEREGG
43
- end
44
- end
45
-
46
- require_order = %w[common flag dictionary error rate_limit http intents emoji_table modules] +
47
- %w[channel/container message_meta allowed_mentions] +
48
- %w[user member guild emoji channel embed message] +
49
- %w[application audit_logs color components event event_handler automod] +
50
- %w[attachment guild_template image integration interaction invite permission] +
51
- %w[presence reaction role sticker utils voice_state webhook] +
52
- %w[gateway_requests gateway_events gateway app_command] +
53
- %w[asset extension shard client extend]
54
- require_order.each do |name|
55
- require_relative "discorb/#{name}.rb"
56
- end
1
+ # frozen_string_literal: true
2
+
3
+ # A new wrapper for the Discorb API.
4
+ #
5
+ # @author sevenc-nanashi
6
+ module Discorb
7
+ #
8
+ # Method to define a macro for YARD.
9
+ # @private
10
+ #
11
+ # @!macro [new] async
12
+ # @note This is an asynchronous method, it will return a `Async::Task` object.
13
+ # Use `Async::Task#wait` to get the result.
14
+ #
15
+ # @!macro [new] client_cache
16
+ # @note This method returns an object from client cache. it will return `nil` if the object is not in cache.
17
+ # @return [nil] The object wasn't cached.
18
+ #
19
+ # @!macro members_intent
20
+ # @note You must enable `GUILD_MEMBERS` intent to use this method.
21
+ #
22
+ # @!macro edit
23
+ # @note The arguments of this method are defaultly set to `Discorb::Unset`.
24
+ # Specify value to set the value, if not don't specify or specify `Discorb::Unset`.
25
+ #
26
+ # @!macro http
27
+ # @note This method calls HTTP request.
28
+ # @raise [Discorb::HTTPError] HTTP request failed.
29
+ #
30
+ def macro
31
+ puts "Wow, You found the easter egg!\n"
32
+ red = "\e[31m"
33
+ reset = "\e[m"
34
+ puts <<~"EASTEREGG"
35
+ . #{red} #{reset}
36
+ | #{red} | #{reset}
37
+ __| | __ __ _ #{red} _ |__ #{reset}
38
+ / | | (__ / / \\ #{red}|/ | \\ #{reset}
39
+ \\__| | __) \\__ \\_/ #{red}| |__/ #{reset}
40
+
41
+ Thank you for using this library!
42
+ EASTEREGG
43
+ end
44
+ end
45
+
46
+ require_order =
47
+ %w[common flag dictionary error rate_limit http intents emoji_table modules] +
48
+ %w[channel/container message_meta allowed_mentions] +
49
+ %w[user member guild emoji channel embed message] +
50
+ %w[application audit_logs color components event event_handler automod] +
51
+ %w[
52
+ attachment
53
+ guild_template
54
+ image
55
+ integration
56
+ interaction
57
+ invite
58
+ permission
59
+ ] + %w[presence reaction role sticker utils voice_state webhook] +
60
+ %w[gateway_requests gateway_events gateway app_command] +
61
+ %w[asset extension shard client extend]
62
+ require_order.each { |name| require_relative "discorb/#{name}.rb" }
@@ -60,6 +60,7 @@ module Discorb
60
60
  # | `1 << 17` | `:embedded` |
61
61
  # | `1 << 18` | `:gateway_message_content` |
62
62
  # | `1 << 19` | `:gateway_message_content_limited` |
63
+ # | `1 << 23` | `:application_command_badge` |
63
64
  class Flag < Discorb::Flag
64
65
  attr_accessor gateway_presence: bool
65
66
  attr_accessor gateway_presence_limited: bool
@@ -69,6 +70,7 @@ module Discorb
69
70
  attr_accessor embedded: bool
70
71
  attr_accessor gateway_message_content: bool
71
72
  attr_accessor gateway_message_content_limited: bool
73
+ attr_accessor application_command_badge: bool
72
74
  end
73
75
 
74
76
  #
@@ -1,6 +1,7 @@
1
1
  module Discorb
2
2
  class AutoModRule < DiscordModel
3
- type trigger_type = :keyword | :harmful_link | :spam | :keyword_preset
3
+ type trigger_type =
4
+ :keyword | :harmful_link | :spam | :keyword_preset | :mention_spam
4
5
  type preset_type = :profanity | :sexual_content | :slurs
5
6
 
6
7
  # @return [Hash{Integer => Symbol}] The mapping of trigger types.
@@ -28,10 +29,18 @@ module Discorb
28
29
  # @return [Array<Discorb::AutoModRule::Action>] The actions of the rule.
29
30
  attr_reader actions: Array[Discorb::AutoModRule::Action]
30
31
 
32
+ # @return [Array<String>] Substrings which will be exempt from triggering the preset trigger type.
33
+ # @note This is only available if the trigger type is `:keyword_preset`.
34
+ attr_reader allow_list: Array[String]?
35
+
31
36
  # @return [Array<String>] The keywords that the rule is triggered by.
32
37
  # @note This is only available if the trigger type is `:keyword`.
33
38
  attr_reader keyword_filter: Array[String]?
34
39
 
40
+ # @return [Integer] Total number of mentions allowed per message.
41
+ # @note This is only available if the trigger type is `:mention_spam`.
42
+ attr_reader mention_total_limit: Integer?
43
+
35
44
  # @return [Symbol] Returns the type of the preset.
36
45
  # @note This is only available if the trigger type is `:keyword_preset`.
37
46
  %a{pure}
@@ -595,6 +595,8 @@ module Discorb
595
595
  ?exempt_channels: Array[Discorb::Channel],
596
596
  ?keyword_filter: Array[String]?,
597
597
  ?presets: Discorb::AutoModRule::preset_type?,
598
+ ?mention_total_limit: Integer?,
599
+ ?allow_list: Array[String]?,
598
600
  ?reason: nil
599
601
  ) -> Async::Task[void]
600
602
 
@@ -344,6 +344,7 @@ module Discorb
344
344
  # |`1 << 5`|`:has_thread`|
345
345
  # |`1 << 6`|`:ephemeral`|
346
346
  # |`1 << 7`|`:loading`|
347
+ # |`1 << 8`|`:failed_to_mention_some_roles_in_thread`|
347
348
  class Flag < Discorb::Flag
348
349
  attr_accessor crossposted: bool
349
350
  attr_accessor crosspost: bool
@@ -353,6 +354,7 @@ module Discorb
353
354
  attr_accessor has_thread: bool
354
355
  attr_accessor ephemeral: bool
355
356
  attr_accessor loading: bool
357
+ attr_accessor failed_to_mention_some_roles_in_thread: bool
356
358
  end
357
359
 
358
360
  #
data/sig/discorb/user.rbs CHANGED
@@ -63,33 +63,35 @@ module Discorb
63
63
  #
64
64
  # Represents the user's flags.
65
65
  # ## Flag fields
66
- # |`1 << 0`|`:discord_employee`|
67
- # |`1 << 1`|`:partnered_server_owner`|
68
- # |`1 << 2`|`:hypesquad_events`|
66
+ # |`1 << 0`|`:staff`|
67
+ # |`1 << 1`|`:partner`|
68
+ # |`1 << 2`|`:hypesquad`|
69
69
  # |`1 << 3`|`:bug_hunter_level_1`|
70
- # |`1 << 6`|`:house_bravery`|
71
- # |`1 << 7`|`:house_brilliance`|
72
- # |`1 << 8`|`:house_balance`|
73
- # |`1 << 9`|`:early_supporter`|
74
- # |`1 << 10`|`:team_user`|
70
+ # |`1 << 6`|`:hypesquad_online_house_1`|
71
+ # |`1 << 7`|`:hypesquad_online_house_2`|
72
+ # |`1 << 8`|`:hypesquad_online_house_3`|
73
+ # |`1 << 9`|`:premium_early_supporter`|
74
+ # |`1 << 10`|`:team_psuedo_user`|
75
75
  # |`1 << 14`|`:bug_hunter_level_2`|
76
76
  # |`1 << 16`|`:verified_bot`|
77
- # |`1 << 17`|`:early_verified_bot_developer`|
78
- # |`1 << 18`|`:discord_certified_moderator`|
77
+ # |`1 << 17`|`:verified_developer`|
78
+ # |`1 << 18`|`:certified_moderator`|
79
+ # |`1 << 19`|`:bot_http_interactions`|
79
80
  class Flag < Discorb::Flag
80
- attr_accessor discord_employee: bool
81
- attr_accessor partnered_server_owner: bool
82
- attr_accessor hypesquad_events: bool
81
+ attr_accessor staff: bool
82
+ attr_accessor partner: bool
83
+ attr_accessor hypesquad: bool
83
84
  attr_accessor bug_hunter_level_1: bool
84
- attr_accessor house_bravery: bool
85
- attr_accessor house_brilliance: bool
86
- attr_accessor house_balance: bool
87
- attr_accessor early_supporter: bool
88
- attr_accessor team_user: bool
85
+ attr_accessor hypesquad_online_house_1: bool
86
+ attr_accessor hypesquad_online_house_2: bool
87
+ attr_accessor hypesquad_online_house_3: bool
88
+ attr_accessor premium_early_supporter: bool
89
+ attr_accessor team_psuedo_user: bool
89
90
  attr_accessor bug_hunter_level_2: bool
90
91
  attr_accessor verified_bot: bool
91
- attr_accessor early_verified_bot_developer: bool
92
- attr_accessor discord_certified_moderato: bool
92
+ attr_accessor verified_developer: bool
93
+ attr_accessor certified_moderator: bool
94
+ attr_accessor bot_http_interactions: bool
93
95
  end
94
96
  end
95
97
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discorb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sevenc-nanashi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-05 00:00:00.000000000 Z
11
+ date: 2022-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async