discorb 0.15.1 → 0.17.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) 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 +1 -1
  8. data/.github/workflows/spec.yml +33 -0
  9. data/.gitignore +2 -0
  10. data/.lefthook/commit-msg/validator.rb +5 -0
  11. data/.rspec +2 -0
  12. data/.rspec_parallel +2 -0
  13. data/.rubocop.yml +43 -6
  14. data/Changelog.md +29 -1
  15. data/Gemfile +14 -8
  16. data/Rakefile +44 -28
  17. data/bin/console +3 -3
  18. data/docs/Examples.md +1 -1
  19. data/docs/application_command.md +156 -47
  20. data/docs/cli/irb.md +2 -2
  21. data/docs/cli/new.md +14 -9
  22. data/docs/cli/run.md +7 -11
  23. data/docs/cli.md +17 -10
  24. data/docs/events.md +224 -210
  25. data/docs/extension.md +1 -2
  26. data/docs/faq.md +0 -1
  27. data/docs/tutorial.md +12 -12
  28. data/docs/voice_events.md +106 -106
  29. data/examples/commands/message.rb +63 -0
  30. data/examples/commands/permission.rb +18 -0
  31. data/examples/commands/slash.rb +44 -0
  32. data/examples/commands/user.rb +51 -0
  33. data/examples/components/authorization_button.rb +2 -2
  34. data/examples/components/select_menu.rb +2 -2
  35. data/examples/extension/main.rb +1 -1
  36. data/examples/extension/message_expander.rb +5 -2
  37. data/examples/simple/eval.rb +2 -2
  38. data/examples/simple/ping_pong.rb +1 -1
  39. data/examples/simple/rolepanel.rb +2 -2
  40. data/examples/simple/shard.rb +17 -0
  41. data/examples/simple/wait_for_message.rb +1 -1
  42. data/exe/discorb +31 -16
  43. data/lefthook.yml +45 -0
  44. data/lib/discorb/allowed_mentions.rb +1 -0
  45. data/lib/discorb/app_command/command.rb +124 -65
  46. data/lib/discorb/app_command/common.rb +25 -0
  47. data/lib/discorb/app_command/handler.rb +117 -34
  48. data/lib/discorb/app_command.rb +2 -1
  49. data/lib/discorb/application.rb +1 -0
  50. data/lib/discorb/asset.rb +1 -2
  51. data/lib/discorb/attachment.rb +1 -1
  52. data/lib/discorb/audit_logs.rb +14 -9
  53. data/lib/discorb/channel/base.rb +108 -0
  54. data/lib/discorb/channel/category.rb +32 -0
  55. data/lib/discorb/channel/container.rb +44 -0
  56. data/lib/discorb/channel/dm.rb +28 -0
  57. data/lib/discorb/channel/guild.rb +245 -0
  58. data/lib/discorb/channel/stage.rb +140 -0
  59. data/lib/discorb/channel/text.rb +345 -0
  60. data/lib/discorb/channel/thread.rb +321 -0
  61. data/lib/discorb/channel/voice.rb +79 -0
  62. data/lib/discorb/channel.rb +2 -1165
  63. data/lib/discorb/client.rb +158 -66
  64. data/lib/discorb/common.rb +2 -1
  65. data/lib/discorb/components/button.rb +2 -1
  66. data/lib/discorb/components/select_menu.rb +4 -2
  67. data/lib/discorb/components/text_input.rb +12 -2
  68. data/lib/discorb/components.rb +1 -1
  69. data/lib/discorb/embed.rb +22 -7
  70. data/lib/discorb/emoji.rb +30 -3
  71. data/lib/discorb/emoji_table.rb +4969 -3
  72. data/lib/discorb/event.rb +29 -4
  73. data/lib/discorb/exe/about.rb +1 -0
  74. data/lib/discorb/exe/irb.rb +2 -4
  75. data/lib/discorb/exe/new.rb +95 -28
  76. data/lib/discorb/exe/run.rb +9 -37
  77. data/lib/discorb/exe/setup.rb +25 -12
  78. data/lib/discorb/exe/show.rb +4 -3
  79. data/lib/discorb/extend.rb +1 -0
  80. data/lib/discorb/extension.rb +6 -3
  81. data/lib/discorb/flag.rb +11 -0
  82. data/lib/discorb/gateway.rb +237 -148
  83. data/lib/discorb/guild.rb +188 -56
  84. data/lib/discorb/guild_template.rb +10 -4
  85. data/lib/discorb/http.rb +17 -10
  86. data/lib/discorb/integration.rb +4 -1
  87. data/lib/discorb/intents.rb +1 -1
  88. data/lib/discorb/interaction/autocomplete.rb +29 -17
  89. data/lib/discorb/interaction/command.rb +38 -14
  90. data/lib/discorb/interaction/components.rb +6 -3
  91. data/lib/discorb/interaction/modal.rb +0 -1
  92. data/lib/discorb/interaction/response.rb +63 -24
  93. data/lib/discorb/interaction/root.rb +14 -14
  94. data/lib/discorb/interaction.rb +1 -0
  95. data/lib/discorb/invite.rb +5 -2
  96. data/lib/discorb/member.rb +25 -5
  97. data/lib/discorb/message.rb +47 -14
  98. data/lib/discorb/message_meta.rb +1 -0
  99. data/lib/discorb/modules.rb +56 -14
  100. data/lib/discorb/presence.rb +2 -2
  101. data/lib/discorb/rate_limit.rb +8 -3
  102. data/lib/discorb/role.rb +19 -4
  103. data/lib/discorb/shard.rb +74 -0
  104. data/lib/discorb/sticker.rb +8 -7
  105. data/lib/discorb/user.rb +2 -1
  106. data/lib/discorb/utils/colored_puts.rb +1 -0
  107. data/lib/discorb/voice_state.rb +10 -6
  108. data/lib/discorb/webhook.rb +51 -27
  109. data/lib/discorb.rb +7 -5
  110. data/po/yard.pot +20 -20
  111. data/rbs_collection.lock.yaml +96 -0
  112. data/rbs_collection.yaml +17 -0
  113. data/sig/async.rbs +5 -0
  114. data/sig/discorb.rbs +8667 -6851
  115. data/template-replace/files/css/common.css +4 -0
  116. metadata +26 -6
  117. data/examples/commands/bookmarker.rb +0 -42
  118. data/examples/commands/hello.rb +0 -10
  119. data/examples/commands/inspect.rb +0 -25
  120. data/lib/discorb/log.rb +0 -81
data/lib/discorb.rb CHANGED
@@ -9,7 +9,8 @@ module Discorb
9
9
  # @private
10
10
  #
11
11
  # @!macro [new] async
12
- # @note This is an asynchronous method, it will return a `Async::Task` object. Use `Async::Task#wait` to get the result.
12
+ # @note This is an asynchronous method, it will return a `Async::Task` object.
13
+ # Use `Async::Task#wait` to get the result.
13
14
  #
14
15
  # @!macro [new] client_cache
15
16
  # @note This method returns an object from client cache. it will return `nil` if the object is not in cache.
@@ -19,7 +20,8 @@ module Discorb
19
20
  # @note You must enable `GUILD_MEMBERS` intent to use this method.
20
21
  #
21
22
  # @!macro edit
22
- # @note The arguments of this method are defaultly set to `Discorb::Unset`. Specify value to set the value, if not don't specify or specify `Discorb::Unset`.
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`.
23
25
  #
24
26
  # @!macro http
25
27
  # @note This method calls HTTP request.
@@ -42,13 +44,13 @@ module Discorb
42
44
  end
43
45
 
44
46
  require_order = %w[common flag dictionary error rate_limit http intents emoji_table modules] +
45
- %w[message_meta allowed_mentions] +
47
+ %w[channel/container message_meta allowed_mentions] +
46
48
  %w[user member guild emoji channel embed message] +
47
49
  %w[application audit_logs color components event event_handler] +
48
- %w[attachment guild_template image integration interaction invite log permission] +
50
+ %w[attachment guild_template image integration interaction invite permission] +
49
51
  %w[presence reaction role sticker utils voice_state webhook] +
50
52
  %w[gateway_requests gateway app_command] +
51
- %w[asset extension client extend]
53
+ %w[asset extension shard client extend]
52
54
  require_order.each do |name|
53
55
  require_relative "discorb/#{name}.rb"
54
56
  end
data/po/yard.pot CHANGED
@@ -2907,23 +2907,23 @@ msgid "### How can I send files?"
2907
2907
  msgstr ""
2908
2908
 
2909
2909
  #: ../docs/faq.md:65
2910
- msgid "Use {Discorb::File} class."
2910
+ msgid "Use {Discorb::Attachment} class."
2911
2911
  msgstr ""
2912
2912
 
2913
2913
  #: ../docs/faq.md:67
2914
2914
  msgid "```ruby\n"
2915
2915
  "# Send a file\n"
2916
- "message.channel.post file: Discorb::File.new(File.open(\"./README.md\"))"
2916
+ "message.channel.post file: Discorb::Attachment.new(File.open(\"./README.md\"))"
2917
2917
  msgstr ""
2918
2918
 
2919
2919
  #: ../docs/faq.md:71
2920
2920
  msgid "# Send some files with text\n"
2921
- "message.channel.post \"File!\", files: [Discorb::File.new(File.open(\"./README.md\")), Discorb::File.new(File.open(\"./License.txt\"))]"
2921
+ "message.channel.post \"File!\", files: [Discorb::Attachment.new(File.open(\"./README.md\")), Discorb::Attachment.new(File.open(\"./License.txt\"))]"
2922
2922
  msgstr ""
2923
2923
 
2924
2924
  #: ../docs/faq.md:74
2925
2925
  msgid "# Send a string as a file\n"
2926
- "message.channel.post file: Discorb::File.from_string(\"Hello world!\", \"hello.txt\")\n"
2926
+ "message.channel.post file: Discorb::Attachment.from_string(\"Hello world!\", \"hello.txt\")\n"
2927
2927
  "```"
2928
2928
  msgstr ""
2929
2929
 
@@ -4519,7 +4519,7 @@ msgid "Command block."
4519
4519
  msgstr ""
4520
4520
 
4521
4521
  # @return [Discorb::ApplicationCommand::Command::GroupCommand]
4522
- # @return [Discorb::ApplicationCommand::Command::SlashCommand]
4522
+ # @return [Discorb::ApplicationCommand::Command::ChatInputCommand]
4523
4523
  # @return [Discorb::ApplicationCommand::Command::SubcommandGroup]
4524
4524
  # @return [Discorb::ApplicationCommand::Command]
4525
4525
  #: ../lib/discorb/app_command.rb:40
@@ -4722,7 +4722,7 @@ msgstr ""
4722
4722
  msgid "a new instance of Command"
4723
4723
  msgstr ""
4724
4724
 
4725
- # Discorb::ApplicationCommand::Command::SlashCommand
4725
+ # Discorb::ApplicationCommand::Command::ChatInputCommand
4726
4726
  #: ../lib/discorb/app_command.rb:194
4727
4727
  msgid "Represents the slash command."
4728
4728
  msgstr ""
@@ -4738,12 +4738,12 @@ msgstr ""
4738
4738
  msgid "The options of the command."
4739
4739
  msgstr ""
4740
4740
 
4741
- # @return [SlashCommand]
4741
+ # @return [ChatInputCommand]
4742
4742
  #: ../lib/discorb/app_command.rb:203
4743
- msgid "a new instance of SlashCommand"
4743
+ msgid "a new instance of ChatInputCommand"
4744
4744
  msgstr ""
4745
4745
 
4746
- # Discorb::ApplicationCommand::Command::SlashCommand#to_s
4746
+ # Discorb::ApplicationCommand::Command::ChatInputCommand#to_s
4747
4747
  #: ../lib/discorb/app_command.rb:213
4748
4748
  msgid "Returns the commands name."
4749
4749
  msgstr ""
@@ -4753,8 +4753,8 @@ msgstr ""
4753
4753
  msgid "Represents the command with subcommands."
4754
4754
  msgstr ""
4755
4755
 
4756
- # @return [Array<Discorb::ApplicationCommand::Command::SlashCommand, Discorb::ApplicationCommand::Command::SubcommandGroup>]
4757
- # @return [Array<Discorb::ApplicationCommand::Command::SlashCommand>]
4756
+ # @return [Array<Discorb::ApplicationCommand::Command::ChatInputCommand, Discorb::ApplicationCommand::Command::SubcommandGroup>]
4757
+ # @return [Array<Discorb::ApplicationCommand::Command::ChatInputCommand>]
4758
4758
  #: ../lib/discorb/app_command.rb:275
4759
4759
  #: ../lib/discorb/app_command.rb:372
4760
4760
  msgid "The subcommands of the command."
@@ -4772,7 +4772,7 @@ msgstr ""
4772
4772
  msgid "Add new subcommand."
4773
4773
  msgstr ""
4774
4774
 
4775
- # @return [Discorb::ApplicationCommand::Command::SlashCommand]
4775
+ # @return [Discorb::ApplicationCommand::Command::ChatInputCommand]
4776
4776
  #: ../lib/discorb/app_command.rb:294
4777
4777
  #: ../lib/discorb/app_command.rb:391
4778
4778
  msgid "The added subcommand."
@@ -9511,7 +9511,7 @@ msgstr ""
9511
9511
  msgid "a new instance of Attachment"
9512
9512
  msgstr ""
9513
9513
 
9514
- # Discorb::File
9514
+ # Discorb::Attachment
9515
9515
  #: ../lib/discorb/file.rb:53
9516
9516
  msgid "Represents a file to send as an attachment."
9517
9517
  msgstr ""
@@ -9537,7 +9537,7 @@ msgstr ""
9537
9537
  msgid "The content type of the file. If not set, it is guessed from the filename."
9538
9538
  msgstr ""
9539
9539
 
9540
- # Discorb::File#initialize
9540
+ # Discorb::Attachment#initialize
9541
9541
  #: ../lib/discorb/file.rb:64
9542
9542
  msgid "Creates a new file from IO."
9543
9543
  msgstr ""
@@ -9570,7 +9570,7 @@ msgstr ""
9570
9570
  msgid "tag|param|content_type"
9571
9571
  msgstr ""
9572
9572
 
9573
- # Discorb::File.from_string
9573
+ # Discorb::Attachment.from_string
9574
9574
  #: ../lib/discorb/file.rb:79
9575
9575
  msgid "Creates a new file from a string."
9576
9576
  msgstr ""
@@ -11738,7 +11738,7 @@ msgstr ""
11738
11738
  msgid "A helper method to send multipart/form-data requests for creating messages."
11739
11739
  msgstr ""
11740
11740
 
11741
- # @param [Array<Discorb::File>]
11741
+ # @param [Array<Discorb::Attachment>]
11742
11742
  #: ../lib/discorb/http.rb:154
11743
11743
  #: ../lib/discorb/interaction/response.rb:91
11744
11744
  #: ../lib/discorb/interaction/response.rb:115
@@ -11750,7 +11750,7 @@ msgstr ""
11750
11750
  msgid "tag|param|files"
11751
11751
  msgstr ""
11752
11752
 
11753
- # @param [Array<Discorb::File>] files
11753
+ # @param [Array<Discorb::Attachment>] files
11754
11754
  #: ../lib/discorb/http.rb:154
11755
11755
  #: ../lib/discorb/interaction/response.rb:91
11756
11756
  #: ../lib/discorb/interaction/response.rb:115
@@ -12122,7 +12122,7 @@ msgstr ""
12122
12122
  msgid "Represents a command interaction."
12123
12123
  msgstr ""
12124
12124
 
12125
- # Discorb::CommandInteraction::SlashCommand
12125
+ # Discorb::CommandInteraction::ChatInputCommand
12126
12126
  #: ../lib/discorb/interaction/command.rb:11
12127
12127
  msgid "Represents a slash command interaction."
12128
12128
  msgstr ""
@@ -12357,7 +12357,7 @@ msgstr ""
12357
12357
  msgid "tag|param|attachments"
12358
12358
  msgstr ""
12359
12359
 
12360
- # @param [Discorb::File]
12360
+ # @param [Discorb::Attachment]
12361
12361
  #: ../lib/discorb/interaction/response.rb:91
12362
12362
  #: ../lib/discorb/interaction/response.rb:115
12363
12363
  #: ../lib/discorb/modules.rb:25
@@ -12375,7 +12375,7 @@ msgstr ""
12375
12375
  msgid "The new embeds of the message."
12376
12376
  msgstr ""
12377
12377
 
12378
- # @param [Discorb::File] file
12378
+ # @param [Discorb::Attachment] file
12379
12379
  #: ../lib/discorb/interaction/response.rb:91
12380
12380
  #: ../lib/discorb/interaction/response.rb:115
12381
12381
  #: ../lib/discorb/modules.rb:25
@@ -0,0 +1,96 @@
1
+ ---
2
+ sources:
3
+ - name: ruby/gem_rbs_collection
4
+ remote: https://github.com/ruby/gem_rbs_collection.git
5
+ revision: main
6
+ repo_dir: gems
7
+ path: ".gem_rbs_collection"
8
+ gems:
9
+ - name: activesupport
10
+ version: '6.0'
11
+ source:
12
+ type: git
13
+ name: ruby/gem_rbs_collection
14
+ revision: 8e1f19e0c8768b6bac2815fe65a3310298ba400e
15
+ remote: https://github.com/ruby/gem_rbs_collection.git
16
+ repo_dir: gems
17
+ - name: ast
18
+ version: '2.4'
19
+ source:
20
+ type: git
21
+ name: ruby/gem_rbs_collection
22
+ revision: 8e1f19e0c8768b6bac2815fe65a3310298ba400e
23
+ remote: https://github.com/ruby/gem_rbs_collection.git
24
+ repo_dir: gems
25
+ - name: date
26
+ version: '0'
27
+ source:
28
+ type: stdlib
29
+ - name: forwardable
30
+ version: '0'
31
+ source:
32
+ type: stdlib
33
+ - name: i18n
34
+ version: '1.10'
35
+ source:
36
+ type: git
37
+ name: ruby/gem_rbs_collection
38
+ revision: 8e1f19e0c8768b6bac2815fe65a3310298ba400e
39
+ remote: https://github.com/ruby/gem_rbs_collection.git
40
+ repo_dir: gems
41
+ - name: listen
42
+ version: '3.2'
43
+ source:
44
+ type: git
45
+ name: ruby/gem_rbs_collection
46
+ revision: 8e1f19e0c8768b6bac2815fe65a3310298ba400e
47
+ remote: https://github.com/ruby/gem_rbs_collection.git
48
+ repo_dir: gems
49
+ - name: parallel
50
+ version: '1.20'
51
+ source:
52
+ type: git
53
+ name: ruby/gem_rbs_collection
54
+ revision: 8e1f19e0c8768b6bac2815fe65a3310298ba400e
55
+ remote: https://github.com/ruby/gem_rbs_collection.git
56
+ repo_dir: gems
57
+ - name: prime
58
+ version: '0'
59
+ source:
60
+ type: stdlib
61
+ - name: rainbow
62
+ version: '3.0'
63
+ source:
64
+ type: git
65
+ name: ruby/gem_rbs_collection
66
+ revision: 8e1f19e0c8768b6bac2815fe65a3310298ba400e
67
+ remote: https://github.com/ruby/gem_rbs_collection.git
68
+ repo_dir: gems
69
+ - name: singleton
70
+ version: '0'
71
+ source:
72
+ type: stdlib
73
+ - name: time
74
+ version: '0'
75
+ source:
76
+ type: stdlib
77
+ - name: uri
78
+ version: '0'
79
+ source:
80
+ type: stdlib
81
+ - name: monitor
82
+ version: '0'
83
+ source:
84
+ type: stdlib
85
+ - name: logger
86
+ version: '0'
87
+ source:
88
+ type: stdlib
89
+ - name: mutex_m
90
+ version: '0'
91
+ source:
92
+ type: stdlib
93
+ - name: pathname
94
+ version: '0'
95
+ source:
96
+ type: stdlib
@@ -0,0 +1,17 @@
1
+ # Download sources
2
+ sources:
3
+ - name: ruby/gem_rbs_collection
4
+ remote: https://github.com/ruby/gem_rbs_collection.git
5
+ revision: main
6
+ repo_dir: gems
7
+
8
+ # A directory to install the downloaded RBSs
9
+ path: .gem_rbs_collection
10
+
11
+ gems:
12
+ # Skip loading rbs gem's RBS.
13
+ # It's unnecessary if you don't use rbs as a library.
14
+ - name: rbs
15
+ ignore: true
16
+ - name: discorb
17
+ ignore: true
data/sig/async.rbs ADDED
@@ -0,0 +1,5 @@
1
+ module Async
2
+ class Task[T]
3
+ def wait: () -> T
4
+ end
5
+ end