discordrb 3.4.3 → 3.6.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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/Dockerfile +13 -0
  3. data/.devcontainer/devcontainer.json +29 -0
  4. data/.devcontainer/postcreate.sh +4 -0
  5. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -1
  6. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -1
  7. data/.github/workflows/ci.yml +78 -0
  8. data/.github/workflows/codeql.yml +65 -0
  9. data/.github/workflows/deploy.yml +54 -0
  10. data/.github/workflows/release.yml +45 -0
  11. data/.markdownlint.json +4 -0
  12. data/.rubocop.yml +58 -2
  13. data/CHANGELOG.md +485 -225
  14. data/LICENSE.txt +1 -1
  15. data/README.md +38 -26
  16. data/discordrb-webhooks.gemspec +4 -1
  17. data/discordrb.gemspec +18 -10
  18. data/lib/discordrb/api/application.rb +278 -0
  19. data/lib/discordrb/api/channel.rb +222 -18
  20. data/lib/discordrb/api/interaction.rb +63 -0
  21. data/lib/discordrb/api/invite.rb +2 -2
  22. data/lib/discordrb/api/server.rb +123 -66
  23. data/lib/discordrb/api/user.rb +20 -5
  24. data/lib/discordrb/api/webhook.rb +72 -0
  25. data/lib/discordrb/api.rb +35 -25
  26. data/lib/discordrb/bot.rb +437 -66
  27. data/lib/discordrb/cache.rb +41 -22
  28. data/lib/discordrb/commands/command_bot.rb +13 -21
  29. data/lib/discordrb/commands/container.rb +1 -1
  30. data/lib/discordrb/commands/parser.rb +7 -7
  31. data/lib/discordrb/commands/rate_limiter.rb +1 -1
  32. data/lib/discordrb/container.rb +178 -3
  33. data/lib/discordrb/data/activity.rb +1 -1
  34. data/lib/discordrb/data/application.rb +1 -0
  35. data/lib/discordrb/data/attachment.rb +38 -3
  36. data/lib/discordrb/data/audit_logs.rb +3 -3
  37. data/lib/discordrb/data/avatar_decoration.rb +26 -0
  38. data/lib/discordrb/data/call.rb +22 -0
  39. data/lib/discordrb/data/channel.rb +299 -30
  40. data/lib/discordrb/data/collectibles.rb +45 -0
  41. data/lib/discordrb/data/component.rb +229 -0
  42. data/lib/discordrb/data/embed.rb +10 -3
  43. data/lib/discordrb/data/emoji.rb +20 -1
  44. data/lib/discordrb/data/integration.rb +45 -3
  45. data/lib/discordrb/data/interaction.rb +937 -0
  46. data/lib/discordrb/data/invite.rb +1 -1
  47. data/lib/discordrb/data/member.rb +236 -44
  48. data/lib/discordrb/data/message.rb +278 -51
  49. data/lib/discordrb/data/overwrite.rb +15 -7
  50. data/lib/discordrb/data/primary_server.rb +60 -0
  51. data/lib/discordrb/data/profile.rb +2 -7
  52. data/lib/discordrb/data/reaction.rb +2 -1
  53. data/lib/discordrb/data/recipient.rb +1 -1
  54. data/lib/discordrb/data/role.rb +204 -18
  55. data/lib/discordrb/data/server.rb +194 -118
  56. data/lib/discordrb/data/server_preview.rb +68 -0
  57. data/lib/discordrb/data/snapshot.rb +110 -0
  58. data/lib/discordrb/data/user.rb +132 -12
  59. data/lib/discordrb/data/voice_region.rb +1 -0
  60. data/lib/discordrb/data/webhook.rb +99 -9
  61. data/lib/discordrb/data.rb +9 -0
  62. data/lib/discordrb/errors.rb +47 -3
  63. data/lib/discordrb/events/await.rb +1 -1
  64. data/lib/discordrb/events/channels.rb +38 -1
  65. data/lib/discordrb/events/generic.rb +2 -0
  66. data/lib/discordrb/events/guilds.rb +6 -1
  67. data/lib/discordrb/events/interactions.rb +575 -0
  68. data/lib/discordrb/events/invites.rb +2 -0
  69. data/lib/discordrb/events/members.rb +19 -2
  70. data/lib/discordrb/events/message.rb +42 -8
  71. data/lib/discordrb/events/presence.rb +23 -14
  72. data/lib/discordrb/events/raw.rb +1 -0
  73. data/lib/discordrb/events/reactions.rb +2 -1
  74. data/lib/discordrb/events/roles.rb +2 -0
  75. data/lib/discordrb/events/threads.rb +100 -0
  76. data/lib/discordrb/events/typing.rb +1 -0
  77. data/lib/discordrb/events/voice_server_update.rb +1 -0
  78. data/lib/discordrb/events/voice_state_update.rb +1 -0
  79. data/lib/discordrb/events/webhooks.rb +1 -0
  80. data/lib/discordrb/gateway.rb +57 -28
  81. data/lib/discordrb/paginator.rb +3 -3
  82. data/lib/discordrb/permissions.rb +71 -35
  83. data/lib/discordrb/version.rb +1 -1
  84. data/lib/discordrb/voice/encoder.rb +2 -2
  85. data/lib/discordrb/voice/network.rb +18 -7
  86. data/lib/discordrb/voice/sodium.rb +3 -1
  87. data/lib/discordrb/voice/voice_bot.rb +3 -3
  88. data/lib/discordrb/webhooks.rb +2 -0
  89. data/lib/discordrb/websocket.rb +0 -10
  90. data/lib/discordrb.rb +54 -5
  91. metadata +87 -25
  92. data/.circleci/config.yml +0 -126
  93. data/.codeclimate.yml +0 -16
  94. data/.travis.yml +0 -32
  95. data/bin/travis_build_docs.sh +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5c0ecfd68356ed63ea61a7b99bb5d32e358f74b23c2f729ab531e4848bc770d
4
- data.tar.gz: 4c5917f1b7a1a3e97d875a0244a8fa8e9583bce025053505b960de9e900ca16f
3
+ metadata.gz: 22a5d0696568b896315a4a63cbd262028f24cba3406461f1f9b59764194153a5
4
+ data.tar.gz: f5f516dd8e0e25512df14ab6a8b6ce68dc326e821ac92b3d9fae9f6fa84924ea
5
5
  SHA512:
6
- metadata.gz: '09b5b31c7e7f15c7053c476ae0c2fd11839b7f5b82c4dea330764da42321c8333559df72273cdffbafe91bc9452a51a4bece945a2e6b3a8774af5fce409750fb'
7
- data.tar.gz: 1743f21d2ad48858e8ebed88984fdf5cecb2ce5878ae0cbf32dbccc451175daa1d0f37c571efa100dadd94dcb169b17515bc691884d9583e00b40f57b45242ff
6
+ metadata.gz: 92fe5293a9deb5ebd253f579926ea9741835e4b019fa9cc5ae398ac3975a6d040ef611316bde03f07eabbc09cd78a468931e9e2c07a1448e5d4339cdbbbbd1b1
7
+ data.tar.gz: 456d37be600b66b43ecfa38b31d0f72113b308ebcc32f54d407f65ee6828d17b3f38ec495799eace92bc2951efcef121ad3ba572dab70bd848efd40f17293025
@@ -0,0 +1,13 @@
1
+ # Which Ruby version to use. You may need to use a more restrictive version,
2
+ # e.g. `3.0`
3
+ ARG VARIANT=3.3
4
+
5
+ # Pull Microsoft's ruby devcontainer base image
6
+ FROM mcr.microsoft.com/devcontainers/ruby:${VARIANT}
7
+
8
+ # Install libsodium dependency for voice channel interactions
9
+ RUN apt update -yq && apt install -y libsodium-dev
10
+
11
+ # Ensure we're running the latest bundler, as what ships with the Ruby image may
12
+ # not be current, and bundler will auto-downgrade to match the Gemfile.lock
13
+ RUN gem install bundler
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "Ruby",
3
+ "build": {
4
+ "dockerfile": "Dockerfile"
5
+ },
6
+
7
+ // Configure tool-specific properties.
8
+ "customizations": {
9
+ // Configure properties specific to VS Code.
10
+ "vscode": {
11
+ // Add the IDs of extensions you want installed when the container is created.
12
+ "extensions": [
13
+ "shopify.ruby-lsp"
14
+ ]
15
+ }
16
+ },
17
+
18
+ // Set the environment variables
19
+ // "runArgs": ["--env-file",".env"],
20
+
21
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
22
+ // "forwardPorts": [],
23
+
24
+ // Use 'postCreateCommand' to run commands after the container is created.
25
+ "postCreateCommand": "bash .devcontainer/postcreate.sh",
26
+
27
+ // Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
28
+ "remoteUser": "vscode"
29
+ }
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ bundle config set path vendor/bundle
4
+ bundle install --jobs=1
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  name: Bug report
3
3
  about: Report a bug to help us improve the library
4
-
5
4
  ---
6
5
 
7
6
  # Summary
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  name: Feature Request
3
3
  about: Request a new feature, or change an existing one
4
-
5
4
  ---
6
5
 
7
6
  <!---
@@ -0,0 +1,78 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ # --- Test on multiple Ruby versions ---
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby: [3.2, 3.3, 3.4]
15
+ container:
16
+ image: ruby:${{ matrix.ruby }}-alpine
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - name: Install OS packages
20
+ run: apk add git build-base ruby-dev libsodium-dev
21
+ - name: Cache bundle
22
+ uses: actions/cache@v4
23
+ with:
24
+ path: vendor/bundle
25
+ key: bundle-${{ hashFiles('Gemfile', 'discordrb.gemspec') }}-${{ matrix.ruby }}
26
+ restore-keys: |
27
+ bundle-${{ matrix.ruby }}
28
+ - name: Install dependencies
29
+ run: bundle install --path vendor/bundle
30
+ - name: Run RSpec
31
+ run: |
32
+ mkdir -p rspec
33
+ bundle exec rspec --format progress --format RspecJunitFormatter -o rspec/rspec.xml
34
+ - name: Upload test results
35
+ uses: actions/upload-artifact@v4
36
+ with:
37
+ name: rspec-results-${{ matrix.ruby }}
38
+ path: rspec/rspec.xml
39
+
40
+ # --- Rubocop ---
41
+ rubocop:
42
+ runs-on: ubuntu-latest
43
+ container:
44
+ image: ruby:3.3-alpine
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+ - name: Install OS packages
48
+ run: apk add git build-base ruby-dev libsodium-dev
49
+ - name: Cache bundle
50
+ uses: actions/cache@v4
51
+ with:
52
+ path: vendor/bundle
53
+ key: bundle-${{ hashFiles('Gemfile', 'discordrb.gemspec') }}-rubocop
54
+ - name: Install dependencies
55
+ run: bundle install --path vendor/bundle
56
+ - name: Run Rubocop
57
+ run: bundle exec rubocop
58
+
59
+ # --- Generate YARD docs ---
60
+ yard:
61
+ runs-on: ubuntu-latest
62
+ container:
63
+ image: ruby:3.3-alpine
64
+ steps:
65
+ - uses: actions/checkout@v4
66
+ - name: Install OS packages
67
+ run: apk add git build-base ruby-dev libsodium-dev
68
+ - name: Cache bundle
69
+ uses: actions/cache@v4
70
+ with:
71
+ path: vendor/bundle
72
+ key: bundle-${{ hashFiles('Gemfile', 'discordrb.gemspec') }}-yard
73
+ - name: Install dependencies
74
+ run: bundle install --path vendor/bundle
75
+ - name: Run YARD
76
+ run: |
77
+ mkdir -p docs
78
+ bundle exec yard --output-dir docs
@@ -0,0 +1,65 @@
1
+ name: "CodeQL"
2
+
3
+ on:
4
+ push:
5
+ branches: [ 'main' ]
6
+ pull_request:
7
+ # The branches below must be a subset of the branches above
8
+ branches: [ 'main' ]
9
+ schedule:
10
+ - cron: '29 6 * * 5'
11
+
12
+ jobs:
13
+ analyze:
14
+ name: Analyze
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ actions: read
18
+ contents: read
19
+ security-events: write
20
+
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ language: [ 'ruby' ]
25
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
26
+ # Use only 'java' to analyze code written in Java, Kotlin or both
27
+ # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
28
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
29
+
30
+ steps:
31
+ - name: Checkout repository
32
+ uses: actions/checkout@v3
33
+
34
+ # Initializes the CodeQL tools for scanning.
35
+ - name: Initialize CodeQL
36
+ uses: github/codeql-action/init@v3
37
+ with:
38
+ languages: ${{ matrix.language }}
39
+ # If you wish to specify custom queries, you can do so here or in a config file.
40
+ # By default, queries listed here will override any specified in a config file.
41
+ # Prefix the list here with "+" to use these queries and those in the config file.
42
+
43
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
44
+ # queries: security-extended,security-and-quality
45
+
46
+
47
+ # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
48
+ # If this step fails, then you should remove it and run the build manually (see below)
49
+ - name: Autobuild
50
+ uses: github/codeql-action/autobuild@v3
51
+
52
+ # ℹ️ Command-line programs to run using the OS shell.
53
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
54
+
55
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
56
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
57
+
58
+ # - run: |
59
+ # echo "Run, Build Application using script"
60
+ # ./location_of_script_within_repo/buildscript.sh
61
+
62
+ - name: Perform CodeQL Analysis
63
+ uses: github/codeql-action/analyze@v3
64
+ with:
65
+ category: "/language:${{matrix.language}}"
@@ -0,0 +1,54 @@
1
+ name: Deploy Docs
2
+
3
+ on:
4
+ push:
5
+ branches: [main] # deploy only on merges to main
6
+ tags:
7
+ - "v*" # deploy when a version tag (e.g., v1.0.0) is created
8
+
9
+ jobs:
10
+ deploy:
11
+ runs-on: ubuntu-latest
12
+ container:
13
+ image: ruby:3.3-alpine
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Install OS packages
19
+ run: apk add git build-base ruby-dev libsodium-dev
20
+
21
+ - name: Cache bundle
22
+ uses: actions/cache@v4
23
+ with:
24
+ path: vendor/bundle
25
+ key: bundle-${{ hashFiles('Gemfile', 'discordrb.gemspec') }}-yard
26
+
27
+ - name: Install dependencies
28
+ run: bundle install --path vendor/bundle
29
+
30
+ - name: Generate YARD documentation
31
+ run: |
32
+ mkdir -p docs
33
+ bundle exec yard --output-dir docs
34
+
35
+ - name: Determine deploy folder
36
+ id: set_folder
37
+ run: |
38
+ if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
39
+ echo "folder=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
40
+ else
41
+ echo "folder=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
42
+ fi
43
+ echo "Deploying to folder: ${{ steps.set_folder.outputs.folder }}"
44
+
45
+ - name: Deploy to GitHub Pages
46
+ uses: peaceiris/actions-gh-pages@v4
47
+ with:
48
+ github_token: ${{ secrets.GITHUB_TOKEN }}
49
+ publish_dir: docs
50
+ publish_branch: gh-pages
51
+ destination_dir: ${{ steps.set_folder.outputs.folder }}
52
+ keep_files: true
53
+ user_name: "GitHub Actions"
54
+ user_email: "ci-build@shardlab.dev"
@@ -0,0 +1,45 @@
1
+ name: Publish RubyGems + GitHub Packages
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: read
12
+ packages: write
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Validate tag matches gemspecs
18
+ run: |
19
+ TAG_VERSION="${GITHUB_REF#refs/tags/v}"
20
+ for gemspec in *.gemspec; do
21
+ GEM_VERSION=$(ruby -e "puts Gem::Specification.load('$gemspec').version")
22
+ if [ "$TAG_VERSION" != "$GEM_VERSION" ]; then
23
+ echo "::error::$gemspec version ($GEM_VERSION) does not match tag ($TAG_VERSION)"
24
+ exit 1
25
+ fi
26
+ done
27
+
28
+ - uses: rubygems/release-gem@v1
29
+ with:
30
+ api_key: ${{ secrets.RUBYGEMS_API_KEY }}
31
+
32
+ - name: Publish to GitHub Packages
33
+ env:
34
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35
+ run: |
36
+ OWNER=$(echo "${GITHUB_REPOSITORY}" | cut -d'/' -f1)
37
+ for gemspec in *.gemspec; do
38
+ gem build "$gemspec"
39
+ done
40
+ for gem_file in *.gem; do
41
+ echo "Publishing $gem_file to GitHub Packages..."
42
+ gem push "$gem_file" \
43
+ --key github \
44
+ --host "https://rubygems.pkg.github.com/${OWNER}" || true
45
+ done
@@ -0,0 +1,4 @@
1
+ {
2
+ "MD013": false,
3
+ "MD024": { "siblings_only": true }
4
+ }
data/.rubocop.yml CHANGED
@@ -1,4 +1,6 @@
1
- require: rubocop-performance
1
+ plugins:
2
+ - rubocop-performance
3
+ - rubocop-rake
2
4
 
3
5
  inherit_mode:
4
6
  merge:
@@ -6,7 +8,7 @@ inherit_mode:
6
8
 
7
9
  AllCops:
8
10
  NewCops: enable
9
- TargetRubyVersion: 2.5
11
+ TargetRubyVersion: 3.3
10
12
 
11
13
  # Disable line length checks
12
14
  Layout/LineLength:
@@ -38,6 +40,10 @@ Security/Eval:
38
40
  Style/Alias:
39
41
  Enabled: false
40
42
 
43
+ # Had to disable this globally because it's being silently autocorrected even with local disable comments?
44
+ Style/BisectedAttrAccessor:
45
+ Enabled: false
46
+
41
47
  # Prefer compact module/class defs
42
48
  Style/ClassAndModuleChildren:
43
49
  Enabled: false
@@ -60,3 +66,53 @@ Style/SingleLineBlockParams:
60
66
  Methods:
61
67
  - reduce: [m, e]
62
68
  - inject: [m, e]
69
+
70
+ ###################################
71
+ ## NEW COPS TO MAKE DECISIONS ON ##
72
+ ###################################
73
+
74
+ # TODO: Decide how you want to handle this:
75
+ # https://rubydoc.info/gems/rubocop/RuboCop/Cop/Style/HashSyntax
76
+ Style/HashSyntax:
77
+ EnforcedShorthandSyntax: either
78
+
79
+ Style/ArgumentsForwarding:
80
+ Enabled: false
81
+
82
+ Performance/StringIdentifierArgument:
83
+ Enabled: false
84
+
85
+ Style/ComparableClamp:
86
+ Enabled: false
87
+
88
+ Style/SuperArguments:
89
+ Enabled: false
90
+
91
+ Naming/BlockForwarding:
92
+ Enabled: false
93
+
94
+ Style/RedundantSelfAssignmentBranch:
95
+ Enabled: false
96
+
97
+ Performance/MapCompact:
98
+ Enabled: false
99
+
100
+ Gemspec/RequiredRubyVersion:
101
+ Enabled: false
102
+
103
+ Gemspec/DevelopmentDependencies:
104
+ Enabled: false
105
+
106
+ Style/RedundantReturn:
107
+ Enabled: false
108
+
109
+ Style/RedundantParentheses:
110
+ Enabled: false
111
+
112
+ # This will probably be a breaking change, but should happen
113
+ Style/ReturnNilInPredicateMethodDefinition:
114
+ Enabled: false
115
+
116
+ # FIXME: Disabled due to breaking tests, should probably refactor the code instead
117
+ Style/SafeNavigation:
118
+ Enabled: false