discorb 0.13.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +2 -0
  3. data/.github/workflows/build_version.yml +3 -3
  4. data/.github/workflows/codeql-analysis.yml +70 -0
  5. data/.github/workflows/lint-push.yml +18 -0
  6. data/.github/workflows/lint.yml +16 -0
  7. data/.rubocop.yml +70 -0
  8. data/CODE_OF_CONDUCT.md +128 -0
  9. data/Changelog.md +33 -0
  10. data/Gemfile +7 -3
  11. data/README.md +1 -1
  12. data/Rakefile +35 -35
  13. data/discorb.gemspec +13 -1
  14. data/examples/commands/bookmarker.rb +2 -1
  15. data/examples/commands/hello.rb +1 -0
  16. data/examples/commands/inspect.rb +3 -2
  17. data/examples/components/authorization_button.rb +2 -1
  18. data/examples/components/select_menu.rb +2 -1
  19. data/examples/extension/main.rb +1 -0
  20. data/examples/extension/message_expander.rb +1 -0
  21. data/examples/simple/eval.rb +3 -2
  22. data/examples/simple/ping_pong.rb +1 -0
  23. data/examples/simple/rolepanel.rb +1 -0
  24. data/examples/simple/wait_for_message.rb +4 -3
  25. data/exe/discorb +8 -7
  26. data/lib/discorb/allowed_mentions.rb +64 -0
  27. data/lib/discorb/app_command/command.rb +274 -0
  28. data/lib/discorb/app_command/handler.rb +168 -0
  29. data/lib/discorb/app_command.rb +2 -404
  30. data/lib/discorb/asset.rb +3 -1
  31. data/lib/discorb/audit_logs.rb +3 -3
  32. data/lib/discorb/channel.rb +89 -53
  33. data/lib/discorb/client.rb +36 -33
  34. data/lib/discorb/common.rb +28 -21
  35. data/lib/discorb/components/button.rb +106 -0
  36. data/lib/discorb/components/select_menu.rb +157 -0
  37. data/lib/discorb/components/text_input.rb +96 -0
  38. data/lib/discorb/components.rb +11 -276
  39. data/lib/discorb/dictionary.rb +13 -2
  40. data/lib/discorb/embed.rb +2 -2
  41. data/lib/discorb/emoji.rb +21 -5
  42. data/lib/discorb/emoji_table.rb +1 -1
  43. data/lib/discorb/error.rb +4 -6
  44. data/lib/discorb/event.rb +13 -11
  45. data/lib/discorb/exe/about.rb +1 -0
  46. data/lib/discorb/exe/irb.rb +4 -3
  47. data/lib/discorb/exe/new.rb +6 -7
  48. data/lib/discorb/exe/run.rb +2 -1
  49. data/lib/discorb/exe/setup.rb +8 -5
  50. data/lib/discorb/exe/show.rb +1 -0
  51. data/lib/discorb/extend.rb +19 -14
  52. data/lib/discorb/extension.rb +5 -1
  53. data/lib/discorb/gateway.rb +75 -27
  54. data/lib/discorb/guild.rb +58 -80
  55. data/lib/discorb/guild_template.rb +5 -5
  56. data/lib/discorb/http.rb +34 -169
  57. data/lib/discorb/integration.rb +32 -3
  58. data/lib/discorb/intents.rb +1 -1
  59. data/lib/discorb/interaction/autocomplete.rb +5 -4
  60. data/lib/discorb/interaction/command.rb +34 -9
  61. data/lib/discorb/interaction/components.rb +5 -2
  62. data/lib/discorb/interaction/modal.rb +33 -0
  63. data/lib/discorb/interaction/response.rb +41 -12
  64. data/lib/discorb/interaction/root.rb +1 -0
  65. data/lib/discorb/interaction.rb +2 -1
  66. data/lib/discorb/invite.rb +1 -1
  67. data/lib/discorb/log.rb +4 -3
  68. data/lib/discorb/member.rb +4 -6
  69. data/lib/discorb/message.rb +31 -282
  70. data/lib/discorb/message_meta.rb +205 -0
  71. data/lib/discorb/modules.rb +11 -11
  72. data/lib/discorb/permission.rb +2 -2
  73. data/lib/discorb/presence.rb +6 -3
  74. data/lib/discorb/rate_limit.rb +15 -21
  75. data/lib/discorb/role.rb +3 -3
  76. data/lib/discorb/sticker.rb +2 -2
  77. data/lib/discorb/user.rb +3 -3
  78. data/lib/discorb/utils/colored_puts.rb +1 -0
  79. data/lib/discorb/voice_state.rb +7 -2
  80. data/lib/discorb/webhook.rb +8 -5
  81. data/lib/discorb.rb +1 -0
  82. data/template-replace/scripts/arrow.rb +1 -0
  83. data/template-replace/scripts/favicon.rb +1 -0
  84. data/template-replace/scripts/index.rb +2 -1
  85. data/template-replace/scripts/locale_ja.rb +5 -4
  86. data/template-replace/scripts/sidebar.rb +1 -0
  87. data/template-replace/scripts/version.rb +7 -10
  88. data/template-replace/scripts/yard_replace.rb +5 -4
  89. metadata +29 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ab7661480ef3de4adbdd46bb59617cb37db17f991f88b263512abe3550e6982
4
- data.tar.gz: c7e92a338b7a71c1b8163aa1a3f801c9256ba72f48a56f42fa481f0c75497793
3
+ metadata.gz: 810e9b14c77e49e9fca7afc4fe6b98389b26cb17dc1617213f38d7655b990a49
4
+ data.tar.gz: bbaa999265ac212f90ab60d57ec772fe7ade0e47f264a136130c679b85a46952
5
5
  SHA512:
6
- metadata.gz: 6b61672c6acc2048420b3f19688a6e72ee1069feb84b7938074cbc2fc39bc9409734d72895317a1b9af1095cc72c138ef0da61ff2b08bcbb05509f239133fd2f
7
- data.tar.gz: 66c1bc5804c7e4646fc9cd1ad9fe8e089e311f42a7251b4b4ff398217fcb25b6d7aa9f7166e35067b9bfecb94cd52b2e66585cede7a3d136cd38ef38232a793d
6
+ metadata.gz: 120828736edcf7eef9d78410914651edeb41ae85eadef012050b105b03c80f07f835d812105d3cfe954c7237e344b3bbc540af8840a7dde1a69f590b008a759e
7
+ data.tar.gz: f29b0399c65f180b05bf6c0c3d5f253689ff08c734f60ee7681b57c060d99e36dd85fc275f9652354933478b8139aa76c8ad854f6963fd1c074a8a260ffb6bde
data/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ template-replace/**/* linguist-documentation
2
+ sig/* linguist-generated
@@ -21,8 +21,8 @@ jobs:
21
21
  bundler-cache: true
22
22
  - name: Set up git settings
23
23
  run: |
24
- git config --global user.email "action@github.com"
25
- git config --global user.name "GitHub Action"
24
+ git config --global user.email "actions@github.com"
25
+ git config --global user.name "GitHub Actions"
26
26
  - name: Clone pages
27
27
  env:
28
28
  SSH_SECRET: ${{ secrets.SSH }}
@@ -33,7 +33,7 @@ jobs:
33
33
  git clone git@github.com:discorb-lib/discorb-lib.github.io /tmp/pages
34
34
  - name: Install dependencies
35
35
  run: |
36
- bundle config --local with 'docs'
36
+ bundle config --local with 'docs development'
37
37
  bundle install
38
38
  gem update uri
39
39
  - name: Generate document
@@ -0,0 +1,70 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ main ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ main ]
20
+ schedule:
21
+ - cron: '20 10 * * 3'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'ruby' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://git.io/codeql-language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v2
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v1
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
52
+
53
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54
+ # If this step fails, then you should remove it and run the build manually (see below)
55
+ - name: Autobuild
56
+ uses: github/codeql-action/autobuild@v1
57
+
58
+ # ℹ️ Command-line programs to run using the OS shell.
59
+ # 📚 https://git.io/JvXDl
60
+
61
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62
+ # and modify them (or add more) to build your code if your project
63
+ # uses a compiled language
64
+
65
+ #- run: |
66
+ # make bootstrap
67
+ # make release
68
+
69
+ - name: Perform CodeQL Analysis
70
+ uses: github/codeql-action/analyze@v1
@@ -0,0 +1,18 @@
1
+ name: Lint with RuboCop
2
+ on:
3
+ - push
4
+ jobs:
5
+ rubocop:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - name: Checkout repository
9
+ uses: actions/checkout@v2
10
+ - uses: ruby/setup-ruby@v1
11
+ with:
12
+ ruby-version: 3.0.0
13
+ - name: Install gems
14
+ run: |
15
+ gem install rubocop
16
+ - name: Run rubocop
17
+ run: |
18
+ rubocop lib
@@ -0,0 +1,16 @@
1
+ name: Lint with RuboCop
2
+ on:
3
+ - pull_request
4
+ jobs:
5
+ rubocop:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - name: Checkout repository
9
+ uses: actions/checkout@v2
10
+ - uses: ruby/setup-ruby@v1
11
+ with:
12
+ ruby-version: 3.0.0
13
+ - name: rubocop
14
+ uses: reviewdog/action-rubocop@v2
15
+ with:
16
+ rubocop_version: 1.25
data/.rubocop.yml ADDED
@@ -0,0 +1,70 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ TargetRubyVersion: 3.0
4
+ Exclude:
5
+ - examples/**/*.rb
6
+
7
+ Layout:
8
+ Enabled: false
9
+ Metrics:
10
+ Enabled: false
11
+
12
+ Style/TrailingCommaInHashLiteral: # Disabled for rufo
13
+ Enabled: false
14
+
15
+ Style/StringLiterals: # Disabled for rufo
16
+ Enabled: false
17
+
18
+ Style/TrailingCommaInArguments: # Disabled for rufo
19
+ Enabled: false
20
+
21
+ Style/StringLiteralsInInterpolation: # Disabled for rufo
22
+ Enabled: false
23
+
24
+ Style/StringConcatenation: # + looks better
25
+ Enabled: false
26
+
27
+ Lint/MissingSuper: # For abstract classes
28
+ Enabled: false
29
+
30
+ Lint/AssignmentInCondition: # Looks bad
31
+ Enabled: false
32
+
33
+ Style/PerlBackrefs: # It will be longer
34
+ Enabled: false
35
+
36
+ Style/RedundantSelf: # Looks local variable
37
+ Enabled: false
38
+
39
+ Naming/VariableNumber: # Discord API docs naming
40
+ Enabled: false
41
+
42
+ Style/ParallelAssignment: # It will be longer
43
+ Enabled: false
44
+
45
+ Style/RedundantInterpolation: # For make it extendable
46
+ Enabled: false
47
+
48
+ Style/Next: # For make it extendable
49
+ Enabled: false
50
+
51
+ Lint/ShadowedException: # False positive
52
+ Enabled: false
53
+
54
+ Lint/AmbiguousOperatorPrecedence: # Not needed
55
+ Enabled: false
56
+
57
+ Style/GlobalVars: # For /exe
58
+ Enabled: false
59
+
60
+ Lint/Debugger: # For /exe
61
+ Enabled: false
62
+
63
+ Style/GuardClause: # For make it extendable
64
+ Enabled: false
65
+
66
+ Layout/EndOfLine: # For git
67
+ EnforcedStyle: lf
68
+
69
+ Lint/ScriptPermission: # For GitHub Actions
70
+ Enabled: false
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ Official Discord.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
data/Changelog.md CHANGED
@@ -4,8 +4,41 @@
4
4
 
5
5
  # Changelog
6
6
 
7
+ ## v0.14
8
+
9
+ ### v0.14.0
10
+
11
+ - Add: Support Modal interaction
12
+ - Add: Support attachment option type in slash command
13
+ - Fix: Connections will no longer stacked
14
+ - Fix: Fix Client#fetch_nitro_sticker_packs returning 404
15
+ - Fix: Fix `self` reference in subcommand of extension
16
+ - Refactor: Refactored many things
17
+ - Refactor: Add Rubocop
18
+
7
19
  ## v0.13
8
20
 
21
+ ### v0.13.4
22
+
23
+ - Add: Show command on `discorb setup`
24
+ - Fix: Fix issue when logging in to file(#6, thanks `deanpcmad`)
25
+ - Fix: Fix rate limit handing
26
+ - Fix: Fix `Client#users`, it was always empty
27
+ - Fix: Fix sorting dictionary
28
+
29
+ ### v0.13.3
30
+
31
+ - Fix: Fix INTEGRATION_xxx event
32
+ - Change: Change description
33
+
34
+ ### v0.13.2
35
+
36
+ - Fix: Fix MESSAGE_DELETE_BULK event
37
+ - Fix: Delete VoiceState from `Guild#voice_states` when member leaves
38
+ - Add: Add `VoiceChannel#members`, `VoiceChannel#voice_states`
39
+ - Add: Add `StageChannel#members`, `StageChannel#voice_states`, `StageChannel#audiences`, `StageChannel#speakers`
40
+ - Fix: Ignore errors on closing websocket
41
+
9
42
  ### v0.13.1
10
43
 
11
44
  - Add: `Discorb::Integration#locale`, `Discorb::Integration#guild_locale`
data/Gemfile CHANGED
@@ -13,9 +13,13 @@ group :development, optional: true do
13
13
  end
14
14
 
15
15
  group :docs, optional: true do
16
- gem "redcarpet"
17
- gem "yard", "~> 0.9.26"
18
- gem "gettext", "~> 3.4.1"
19
16
  gem "crowdin-api", "~> 1.0"
17
+ gem "gettext", "~> 3.4.1"
18
+ gem "redcarpet"
20
19
  gem "rubyzip", "~> 2.3"
20
+ gem "yard", "~> 0.9.26"
21
+ end
22
+
23
+ group :lint, optional: true do
24
+ gem "rubocop", "~> 1.25"
21
25
  end
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ----
11
11
 
12
- discorb is a Discord API wrapper written in Ruby.
12
+ discorb is a Discord API wrapper for Ruby, Using [socketry/async](https://github.com/socketry/async).
13
13
 
14
14
  ## Installation
15
15
 
data/Rakefile CHANGED
@@ -5,15 +5,14 @@ require_relative "lib/discorb/utils/colored_puts"
5
5
  task default: %i[]
6
6
 
7
7
  # @private
8
- def get_version
8
+ def current_version
9
9
  require_relative "lib/discorb/common"
10
10
  tag = `git tag --points-at HEAD`.force_encoding("utf-8").strip
11
11
  if tag.empty?
12
- version = "main"
12
+ "main"
13
13
  else
14
- version = Discorb::VERSION
14
+ Discorb::VERSION
15
15
  end
16
- version
17
16
  end
18
17
 
19
18
  desc "Build emoji_table.rb"
@@ -63,8 +62,7 @@ end
63
62
 
64
63
  desc "Generate document and replace"
65
64
  namespace :document do
66
- version = get_version
67
-
65
+ version = current_version
68
66
  desc "Just generate document"
69
67
  task :yard do
70
68
  sh "bundle exec yardoc -o doc/#{version} --locale #{ENV["rake_locale"] or "en"}"
@@ -86,12 +84,12 @@ namespace :document do
86
84
 
87
85
  desc "Replace HTML"
88
86
  task :html do
89
- require_relative "template-replace/scripts/sidebar.rb"
90
- require_relative "template-replace/scripts/version.rb"
91
- require_relative "template-replace/scripts/index.rb"
92
- require_relative "template-replace/scripts/yard_replace.rb"
93
- require_relative "template-replace/scripts/favicon.rb"
94
- require_relative "template-replace/scripts/arrow.rb"
87
+ require_relative "template-replace/scripts/sidebar"
88
+ require_relative "template-replace/scripts/version"
89
+ require_relative "template-replace/scripts/index"
90
+ require_relative "template-replace/scripts/yard_replace"
91
+ require_relative "template-replace/scripts/favicon"
92
+ require_relative "template-replace/scripts/arrow"
95
93
  iputs "Resetting changes"
96
94
  Dir.glob("doc/#{version}/**/*.html") do |f|
97
95
  next if (m = f.match(/[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?/)) && m[0] != version
@@ -143,37 +141,35 @@ namespace :document do
143
141
  replace_locale("doc/main")
144
142
  end
145
143
  end
146
- task :replace => %i[replace:css replace:html replace:eol]
144
+ task replace: %i[replace:css replace:html replace:eol]
147
145
 
148
146
  desc "Build all versions"
149
147
  task :build_all do
150
148
  require "fileutils"
151
149
 
152
- class Bundler::Definition
153
- def validate_platforms!
154
- # noop
155
- end
156
- end
157
-
158
150
  iputs "Building all versions"
159
- FileUtils.rm_rf("doc") rescue nil
151
+ begin
152
+ FileUtils.rm_rf("doc")
153
+ rescue StandardError
154
+ nil
155
+ end
160
156
  FileUtils.cp_r("./template-replace/.", "./tmp-template-replace")
161
- Rake::Task["document:yard"].invoke
162
- Rake::Task["document:replace:html"].invoke
163
- Rake::Task["document:replace:css"].invoke
164
- Rake::Task["document:replace:eol"].invoke
165
- Rake::Task["document:replace:locale"].invoke
157
+ Rake::Task["document:yard"].execute
158
+ Rake::Task["document:replace:html"].execute
159
+ Rake::Task["document:replace:css"].execute
160
+ Rake::Task["document:replace:eol"].execute
161
+ Rake::Task["document:replace:locale"].execute
166
162
  tags = `git tag`.force_encoding("utf-8").split("\n").sort_by { |t| t[1..].split(".").map(&:to_i) }
167
163
  tags.each do |tag|
168
164
  sh "git checkout #{tag} -f"
169
165
  iputs "Building #{tag}"
170
166
  FileUtils.cp_r("./tmp-template-replace/.", "./template-replace")
171
167
  version = tag.delete_prefix("v")
172
- Rake::Task["document:yard"].invoke
173
- Rake::Task["document:replace:html"].invoke
174
- Rake::Task["document:replace:css"].invoke
175
- Rake::Task["document:replace:eol"].invoke
176
- Rake::Task["document:replace:locale"].invoke
168
+ Rake::Task["document:yard"].execute
169
+ Rake::Task["document:replace:html"].execute
170
+ Rake::Task["document:replace:css"].execute
171
+ Rake::Task["document:replace:eol"].execute
172
+ Rake::Task["document:replace:locale"].execute
177
173
  FileUtils.cp_r("./doc/.", "./tmp-doc")
178
174
  FileUtils.rm_rf("doc")
179
175
  end
@@ -181,7 +177,7 @@ namespace :document do
181
177
  FileUtils.cp_r("./tmp-doc/.", "./doc")
182
178
  FileUtils.cp_r("./doc/#{tags.last.delete_prefix("v")}/.", "./doc")
183
179
  sputs "Successfully built all versions"
184
- rescue => e
180
+ rescue StandardError => e
185
181
  sh "git switch main -f"
186
182
  raise e
187
183
  end
@@ -216,12 +212,12 @@ namespace :document do
216
212
  end
217
213
  end
218
214
  ENV["rake_locale"] = "ja"
219
- Rake::Task["document:yard"].invoke
220
- Rake::Task["document:replace"].invoke
215
+ Rake::Task["document:yard"].execute
216
+ Rake::Task["document:replace"].execute
221
217
  end
222
218
 
223
219
  task :en do
224
- Rake::Task["document"].invoke("locale:en")
220
+ Rake::Task["document"].execute("locale:en")
225
221
  end
226
222
  end
227
223
  end
@@ -322,4 +318,8 @@ task :rbs do
322
318
  File.write("sig/discorb.rbs", base)
323
319
  end
324
320
 
325
- task :document => %i[document:yard document:replace]
321
+ task document: %i[document:yard document:replace]
322
+
323
+ task :lint do
324
+ sh "rubocop lib"
325
+ end
data/discorb.gemspec CHANGED
@@ -8,7 +8,18 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["sevenc-nanashi"]
9
9
  spec.email = ["sevenc-nanashi@sevenbot.jp"]
10
10
 
11
- spec.summary = "A discord API wrapper written in Ruby"
11
+ spec.summary = "A Discord API wrapper for Ruby, Using socketry/async."
12
+ spec.description = <<~RDOC
13
+ == discorb
14
+ discorb is a Discord API wrapper for Ruby, Using {socketry/async}[https://github.com/socketry/async].
15
+
16
+ === Contributing
17
+ Bug reports, feature requests, and pull requests are welcome on {the GitHub repository}[https://github.com/discorb-lib/discorb].
18
+
19
+ === License
20
+ This gem is licensed under the MIT License.
21
+
22
+ RDOC
12
23
  spec.homepage = "https://github.com/discorb-lib/discorb"
13
24
  spec.license = "MIT"
14
25
  spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
@@ -35,4 +46,5 @@ Gem::Specification.new do |spec|
35
46
  spec.add_dependency "mime-types", "~> 3.3"
36
47
  # For more information and examples about making a new gem, checkout our
37
48
  # guide at: https://bundler.io/guides/creating_gem.html
49
+ spec.metadata["rubygems_mfa_required"] = "true"
38
50
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "discorb"
2
3
  require "json"
3
4
 
@@ -20,7 +21,7 @@ def build_embed_from_message(message)
20
21
  embed
21
22
  end
22
23
 
23
- client.message_command("Bookmark", guild_ids: [857373681096327180]) do |interaction, message|
24
+ client.message_command("Bookmark", guild_ids: [857_373_681_096_327_180]) do |interaction, message|
24
25
  unless channel = bookmark_channel(interaction.guild)
25
26
  interaction.post("Bookmark channel not found. Please create one called `bookmarks`.", ephemeral: true)
26
27
  next
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "discorb"
2
3
 
3
4
  client = Discorb::Client.new
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "discorb"
2
3
 
3
4
  client = Discorb::Client.new
@@ -6,7 +7,7 @@ client.once :standby do
6
7
  puts "Logged in as #{client.user}"
7
8
  end
8
9
 
9
- client.user_command("Info", guild_ids: [857373681096327180]) do |interaction|
10
+ client.user_command("Info", guild_ids: [857_373_681_096_327_180]) do |interaction|
10
11
  interaction.post(embed: Discorb::Embed.new(
11
12
  "Information of #{interaction.target.to_s_user}",
12
13
  fields: [
@@ -14,7 +15,7 @@ client.user_command("Info", guild_ids: [857373681096327180]) do |interaction|
14
15
  Discorb::Embed::Field.new("ID", interaction.target.id),
15
16
  Discorb::Embed::Field.new("Bot", interaction.target.bot? ? "Yes" : "No"),
16
17
  Discorb::Embed::Field.new("Joined at", interaction.target.joined_at.to_df("F")),
17
- Discorb::Embed::Field.new("Created at", interaction.target.created_at.to_df("F")),
18
+ Discorb::Embed::Field.new("Created at", interaction.target.created_at.to_df("F"))
18
19
  ],
19
20
  thumbnail: interaction.target.avatar&.url,
20
21
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "discorb"
2
3
 
3
4
  client = Discorb::Client.new
@@ -27,7 +28,7 @@ client.on :message do |message|
27
28
  components: [
28
29
  Discorb::Button.new(
29
30
  "Get role", custom_id: "auth:#{role.id}",
30
- ),
31
+ )
31
32
  ],
32
33
  )
33
34
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "discorb"
2
3
 
3
4
  client = Discorb::Client.new
@@ -21,7 +22,7 @@ SECTIONS = [
21
22
  > So I decided to make it.
22
23
  Matsumoto describes the design of Ruby as being like a simple Lisp language at its core, with an object system like that of Smalltalk, blocks inspired by higher-order functions, and practical utility like that of Perl.
23
24
  WIKI
24
- ["First publication", <<~WIKI],
25
+ ["First publication", <<~WIKI]
25
26
  The first public release of Ruby 0.95 was announced on Japanese domestic newsgroups on December 21, 1995.
26
27
  Subsequently, three more versions of Ruby were released in two days.
27
28
  The release coincided with the launch of the Japanese-language ruby-list mailing list, which was the first mailing list for the new language.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "discorb"
2
3
  require_relative "message_expander"
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "discorb"
2
3
 
3
4
  class MessageExpander
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "discorb"
2
3
 
3
4
  client = Discorb::Client.new
@@ -24,8 +25,8 @@ client.on :message do |message|
24
25
  res = res.wait if res.is_a? Async::Task
25
26
  message.channel.post("```rb\n#{res.inspect[...1990]}\n```")
26
27
  end
27
- rescue Exception => error
28
- message.reply embed: Discorb::Embed.new("Error!", "```rb\n#{error.full_message(highlight: false)[...1990]}\n```",
28
+ rescue Exception => e
29
+ message.reply embed: Discorb::Embed.new("Error!", "```rb\n#{e.full_message(highlight: false)[...1990]}\n```",
29
30
  color: Discorb::Color[:red])
30
31
  end
31
32