discordrb 3.3.0 → 3.5.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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +152 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
  5. data/.github/pull_request_template.md +37 -0
  6. data/.github/workflows/codeql.yml +65 -0
  7. data/.markdownlint.json +4 -0
  8. data/.rubocop.yml +39 -36
  9. data/CHANGELOG.md +874 -552
  10. data/Gemfile +2 -0
  11. data/LICENSE.txt +1 -1
  12. data/README.md +80 -86
  13. data/Rakefile +2 -0
  14. data/bin/console +1 -0
  15. data/discordrb-webhooks.gemspec +9 -6
  16. data/discordrb.gemspec +21 -18
  17. data/lib/discordrb/allowed_mentions.rb +36 -0
  18. data/lib/discordrb/api/application.rb +202 -0
  19. data/lib/discordrb/api/channel.rb +236 -47
  20. data/lib/discordrb/api/interaction.rb +54 -0
  21. data/lib/discordrb/api/invite.rb +5 -5
  22. data/lib/discordrb/api/server.rb +94 -66
  23. data/lib/discordrb/api/user.rb +17 -11
  24. data/lib/discordrb/api/webhook.rb +63 -6
  25. data/lib/discordrb/api.rb +55 -16
  26. data/lib/discordrb/await.rb +0 -1
  27. data/lib/discordrb/bot.rb +480 -93
  28. data/lib/discordrb/cache.rb +31 -24
  29. data/lib/discordrb/colour_rgb.rb +43 -0
  30. data/lib/discordrb/commands/command_bot.rb +35 -12
  31. data/lib/discordrb/commands/container.rb +21 -24
  32. data/lib/discordrb/commands/parser.rb +20 -20
  33. data/lib/discordrb/commands/rate_limiter.rb +4 -3
  34. data/lib/discordrb/container.rb +209 -20
  35. data/lib/discordrb/data/activity.rb +271 -0
  36. data/lib/discordrb/data/application.rb +50 -0
  37. data/lib/discordrb/data/attachment.rb +71 -0
  38. data/lib/discordrb/data/audit_logs.rb +345 -0
  39. data/lib/discordrb/data/channel.rb +993 -0
  40. data/lib/discordrb/data/component.rb +229 -0
  41. data/lib/discordrb/data/embed.rb +251 -0
  42. data/lib/discordrb/data/emoji.rb +82 -0
  43. data/lib/discordrb/data/integration.rb +122 -0
  44. data/lib/discordrb/data/interaction.rb +800 -0
  45. data/lib/discordrb/data/invite.rb +137 -0
  46. data/lib/discordrb/data/member.rb +372 -0
  47. data/lib/discordrb/data/message.rb +414 -0
  48. data/lib/discordrb/data/overwrite.rb +108 -0
  49. data/lib/discordrb/data/profile.rb +91 -0
  50. data/lib/discordrb/data/reaction.rb +33 -0
  51. data/lib/discordrb/data/recipient.rb +34 -0
  52. data/lib/discordrb/data/role.rb +248 -0
  53. data/lib/discordrb/data/server.rb +1004 -0
  54. data/lib/discordrb/data/user.rb +264 -0
  55. data/lib/discordrb/data/voice_region.rb +45 -0
  56. data/lib/discordrb/data/voice_state.rb +41 -0
  57. data/lib/discordrb/data/webhook.rb +238 -0
  58. data/lib/discordrb/data.rb +28 -4180
  59. data/lib/discordrb/errors.rb +46 -4
  60. data/lib/discordrb/events/bans.rb +7 -5
  61. data/lib/discordrb/events/channels.rb +3 -1
  62. data/lib/discordrb/events/guilds.rb +16 -9
  63. data/lib/discordrb/events/interactions.rb +482 -0
  64. data/lib/discordrb/events/invites.rb +125 -0
  65. data/lib/discordrb/events/members.rb +6 -2
  66. data/lib/discordrb/events/message.rb +72 -27
  67. data/lib/discordrb/events/presence.rb +35 -18
  68. data/lib/discordrb/events/raw.rb +1 -3
  69. data/lib/discordrb/events/reactions.rb +49 -4
  70. data/lib/discordrb/events/threads.rb +96 -0
  71. data/lib/discordrb/events/typing.rb +6 -4
  72. data/lib/discordrb/events/voice_server_update.rb +47 -0
  73. data/lib/discordrb/events/voice_state_update.rb +15 -10
  74. data/lib/discordrb/events/webhooks.rb +9 -6
  75. data/lib/discordrb/gateway.rb +99 -71
  76. data/lib/discordrb/id_object.rb +39 -0
  77. data/lib/discordrb/light/integrations.rb +1 -1
  78. data/lib/discordrb/light/light_bot.rb +1 -1
  79. data/lib/discordrb/logger.rb +4 -4
  80. data/lib/discordrb/paginator.rb +57 -0
  81. data/lib/discordrb/permissions.rb +159 -39
  82. data/lib/discordrb/version.rb +1 -1
  83. data/lib/discordrb/voice/encoder.rb +16 -7
  84. data/lib/discordrb/voice/network.rb +99 -47
  85. data/lib/discordrb/voice/sodium.rb +98 -0
  86. data/lib/discordrb/voice/voice_bot.rb +33 -25
  87. data/lib/discordrb/webhooks.rb +2 -0
  88. data/lib/discordrb.rb +107 -1
  89. metadata +126 -54
  90. data/.codeclimate.yml +0 -16
  91. data/.travis.yml +0 -33
  92. data/bin/travis_build_docs.sh +0 -17
  93. /data/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b25d90cb65adea4d1dac0aa33b64f6451e1c21f7dbe13c48f2ae9d40ea5e2edf
4
- data.tar.gz: 31e41074b2304456f73413af20ca1850757e34566af21067a4989656d78feb77
3
+ metadata.gz: 256d58c280ec27b90dbe4c160b04853b72fede9123336085343141e4d0e6ad4a
4
+ data.tar.gz: 8f4db65b7491433052cc99b1a0e633fc773efd8076edbd4ad44a5bc3ed4b5a14
5
5
  SHA512:
6
- metadata.gz: 5bb79daa3219ec1c75f637ccaf39c71e943ba2e162c02ca46fd2775e7a746d4cfecafda8af8402d215936660249b96ae441632444d7718688badf19ae38f72fe
7
- data.tar.gz: 71110b5df4bade1aac8d54b708bbc93b5a91d61c146eb56e9aa25a94f9dd0ff0f291db4c0c28589f095ab9fa19ed9204e50a0aaa920557c6fdc802d88eaa733a
6
+ metadata.gz: ed49c17ab20befc243747a942d4401b513670220d76632b796df000e9232bebd5d6f58c6ce7a1bb5a16f03d8d88ec1b2c5c6131e1ddd20784cf4b7248111a979
7
+ data.tar.gz: 01fb50074b67c0bcb3c96ed2cc4e76aad57600e94fa22793c588e66c98fddd796f7a7087817b9d7926975e28e956d950ce7fd1d778e73edf26c32be49dabbedb
@@ -0,0 +1,152 @@
1
+ version: 2.1
2
+
3
+ commands:
4
+ setup-env:
5
+ description: Sets up the testing environment
6
+ steps:
7
+ - run:
8
+ name: Install OS packages
9
+ command: apk add git build-base ruby-dev ruby-etc ruby-json libsodium
10
+ - checkout
11
+ - run:
12
+ name: "Ruby version"
13
+ command: |
14
+ ruby -v
15
+ echo $RUBY_VERSION > ruby_version.txt
16
+ - restore_cache:
17
+ keys:
18
+ - bundle-cache-v1-{{ checksum "ruby_version.txt" }}-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "discordrb.gemspec" }}
19
+ - bundle-cache-v1-{{ checksum "ruby_version.txt" }}-{{ .Branch }}
20
+ - bundle-cache-v1-{{ checksum "ruby_version.txt" }}
21
+ - run:
22
+ name: Install dependencies
23
+ command: bundle install --path vendor/bundle
24
+ - save_cache:
25
+ key: bundle-cache-v1-{{ checksum "ruby_version.txt" }}-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "discordrb.gemspec" }}
26
+ paths:
27
+ - ./vendor/bundle
28
+
29
+ jobs:
30
+ test_ruby_27:
31
+ docker:
32
+ - image: ruby:2.7-alpine
33
+ steps:
34
+ - setup-env
35
+ - run:
36
+ name: Run RSpec
37
+ command: bundle exec rspec --format progress --format RspecJunitFormatter -o ~/rspec/rspec.xml
38
+ - store_test_results:
39
+ path: ~/rspec
40
+
41
+ test_ruby_30:
42
+ docker:
43
+ - image: ruby:3.0-alpine
44
+ steps:
45
+ - setup-env
46
+ - run:
47
+ name: Run RSpec
48
+ command: bundle exec rspec --format progress --format RspecJunitFormatter -o ~/rspec/rspec.xml
49
+ - store_test_results:
50
+ path: ~/rspec
51
+
52
+
53
+ test_ruby_31:
54
+ docker:
55
+ - image: ruby:3.1-alpine
56
+ steps:
57
+ - setup-env
58
+ - run:
59
+ name: Run RSpec
60
+ command: bundle exec rspec --format progress --format RspecJunitFormatter -o ~/rspec/rspec.xml
61
+
62
+ rubocop:
63
+ docker:
64
+ - image: ruby:2.7-alpine
65
+ steps:
66
+ - setup-env
67
+ - run:
68
+ name: Run Rubocop
69
+ command: bundle exec rubocop
70
+
71
+ yard:
72
+ docker:
73
+ - image: ruby:2.7-alpine
74
+ steps:
75
+ - setup-env
76
+ - attach_workspace:
77
+ at: /tmp/workspace
78
+ - run:
79
+ name: Run YARD
80
+ command: bundle exec yard --output-dir /tmp/workspace/docs
81
+ - persist_to_workspace:
82
+ root: /tmp/workspace
83
+ paths:
84
+ - docs
85
+
86
+ pages:
87
+ docker:
88
+ - image: alpine
89
+ steps:
90
+ - run:
91
+ name: Install OS packages
92
+ command: apk add git openssh-client-default
93
+ - attach_workspace:
94
+ at: /tmp/workspace
95
+ - run:
96
+ name: Clone docs
97
+ command: |
98
+ mkdir -p ~/.ssh
99
+
100
+ echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=' >> ~/.ssh/known_hosts
101
+
102
+ git clone $CIRCLE_REPOSITORY_URL -b gh-pages .
103
+ - add_ssh_keys:
104
+ fingerprints:
105
+ - "9a:4c:50:94:23:46:81:74:41:97:87:04:4e:59:4b:4e"
106
+ - run:
107
+ name: Push updated docs
108
+ command: |
109
+ git config user.name "Circle CI"
110
+ git config user.email "ci-build@shardlab.dev"
111
+
112
+ SOURCE_BRANCH=$CIRCLE_BRANCH
113
+ if [ -n "$CIRCLE_TAG" ]; then
114
+ SOURCE_BRANCH=$CIRCLE_TAG
115
+ fi
116
+
117
+ mkdir -p $SOURCE_BRANCH
118
+ rm -rf $SOURCE_BRANCH/*
119
+ cp -r /tmp/workspace/docs/. ./$SOURCE_BRANCH/
120
+
121
+ git add $SOURCE_BRANCH
122
+ git commit --allow-empty -m "[skip ci] Deploy docs"
123
+ git push -u origin gh-pages
124
+
125
+ workflows:
126
+ test:
127
+ jobs:
128
+ - test_ruby_27
129
+ - test_ruby_30
130
+ - test_ruby_31
131
+ - rubocop
132
+ - yard
133
+ deploy:
134
+ jobs:
135
+ - yard:
136
+ filters:
137
+ branches:
138
+ only:
139
+ - main
140
+ - slash_commands
141
+ tags:
142
+ only: /^v.*/
143
+ - pages:
144
+ requires:
145
+ - yard
146
+ filters:
147
+ branches:
148
+ only:
149
+ - main
150
+ - slash_commands
151
+ tags:
152
+ only: /^v.*/
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: Bug report
3
+ about: Report a bug to help us improve the library
4
+ ---
5
+
6
+ # Summary
7
+
8
+ <!---
9
+ First, please check to see that another issue or pull request (open or closed)
10
+ already addresses the problem you are facing. If you are not sure, please ask
11
+ in the Discord channel (link below).
12
+
13
+ Describe the bug you are encountering with as much detail as you can.
14
+ If you are not sure if a small detail is relevant, include it anyways!
15
+
16
+ Include simple code examples that will reproduce the bug.
17
+ Include any exceptions you are encountering in your logs, including
18
+ the initial error message and the backtrace that follows.
19
+
20
+ Stuck or need help? Join the Discord! https://discord.gg/cyK3Hjm
21
+ -->
22
+
23
+ ---
24
+
25
+ ## Environment
26
+
27
+ <!---
28
+ These are some commands to run to give us basic information about
29
+ your Ruby environment. Some issues may be version, OS, or hardware specific.
30
+ --->
31
+
32
+ **Ruby version:**
33
+
34
+ <!--- Paste full output of `ruby -v` here --->
35
+
36
+ **Discordrb version:**
37
+
38
+ <!--- Paste full output of `gem list discordrb` or `bundle list discordrb` here --->
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: Feature Request
3
+ about: Request a new feature, or change an existing one
4
+ ---
5
+
6
+ <!---
7
+ Describe your feature request in as much detail as you can here.
8
+
9
+ Include why you want this feature. For example:
10
+
11
+ - It is a feature supported by Discord's API, but missing from the library
12
+
13
+ - It is a feature that would simplify a lot of your bots code
14
+
15
+ - It is a feature present in other popular Discord libraries
16
+
17
+ Include simple code examples (pseudocode is fine) that demonstrate
18
+ what you want to do.
19
+
20
+ Do your best to think about how this new feature would impact the code
21
+ of other people who use discordrb, and not just your own bot's codebase.
22
+
23
+ Stuck or need help? Join the Discord! https://discord.gg/cyK3Hjm
24
+ --->
@@ -0,0 +1,37 @@
1
+ # Summary
2
+
3
+ <!---
4
+ Describe the general goal of your pull request here:
5
+
6
+ - Include details about any issues you encountered that inspired
7
+ the pull request, such as bugs or missing features.
8
+
9
+ - If adding or changing features, include a small example that showcases
10
+ the new behavior.
11
+
12
+ - Reference any related issues or pull requests.
13
+
14
+ Stuck or need help? Join the Discord! https://discord.gg/cyK3Hjm
15
+ --->
16
+
17
+ ---
18
+
19
+ <!---
20
+ List each individual change you made to the library here in the appropriate
21
+ section in short, bulleted sentences.
22
+
23
+ This will aid in reviewing your pull request, and for adding it to the
24
+ changelog later.
25
+
26
+ You may remove sections that have no items if you want.
27
+ --->
28
+
29
+ ## Added
30
+
31
+ ## Changed
32
+
33
+ ## Deprecated
34
+
35
+ ## Removed
36
+
37
+ ## Fixed
@@ -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@v2
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@v2
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@v2
64
+ with:
65
+ category: "/language:${{matrix.language}}"
@@ -0,0 +1,4 @@
1
+ {
2
+ "MD013": false,
3
+ "MD024": { "siblings_only": true }
4
+ }
data/.rubocop.yml CHANGED
@@ -1,44 +1,64 @@
1
- # Disable all metrics.
2
- Metrics/AbcSize:
3
- Enabled: false
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rake
4
4
 
5
- Metrics/BlockNesting:
6
- Enabled: false
5
+ inherit_mode:
6
+ merge:
7
+ - AllowedNames
7
8
 
8
- Metrics/BlockLength:
9
- Enabled: false
9
+ AllCops:
10
+ NewCops: enable
11
+ TargetRubyVersion: 2.7
10
12
 
11
- Metrics/ClassLength:
13
+ # Disable line length checks
14
+ Layout/LineLength:
12
15
  Enabled: false
13
16
 
14
- Metrics/ModuleLength:
17
+ # TODO: Larger refactor
18
+ Lint/MissingSuper:
15
19
  Enabled: false
16
20
 
17
- Metrics/CyclomaticComplexity:
21
+ # Allow 'Pokémon-style' exception handling
22
+ Lint/RescueException:
18
23
  Enabled: false
19
24
 
20
- Metrics/LineLength:
25
+ # Disable all metrics.
26
+ Metrics:
21
27
  Enabled: false
22
28
 
23
- Metrics/MethodLength:
24
- Enabled: false
29
+ # Allow some common and/or obvious short method params
30
+ Naming/MethodParameterName:
31
+ AllowedNames:
32
+ - e
25
33
 
26
- Metrics/ParameterLists:
34
+ # Ignore `eval` in the examples folder
35
+ Security/Eval:
36
+ Exclude:
37
+ - examples/**/*
38
+
39
+ # https://stackoverflow.com/q/4763121/
40
+ Style/Alias:
27
41
  Enabled: false
28
42
 
29
- Metrics/PerceivedComplexity:
43
+ # Had to disable this globally because it's being silently autocorrected even with local disable comments?
44
+ Style/BisectedAttrAccessor:
30
45
  Enabled: false
31
46
 
32
47
  # Prefer compact module/class defs
33
48
  Style/ClassAndModuleChildren:
34
49
  Enabled: false
35
50
 
36
- # Allow CamelCase constants as well as SCREAMING_SNAKE_CASE
37
- Style/ConstantName:
51
+ # So RuboCop doesn't complain about application IDs
52
+ Style/NumericLiterals:
53
+ Exclude:
54
+ - examples/**/*
55
+
56
+ # TODO: Requires breaking changes
57
+ Style/OptionalBooleanParameter:
38
58
  Enabled: false
39
59
 
40
- # Allow 'Pokémon-style' exception handling
41
- Lint/RescueException:
60
+ # Prefer explicit arguments in case global variables like `$;` or `$,` are changed
61
+ Style/RedundantArgument:
42
62
  Enabled: false
43
63
 
44
64
  # Prefer |m, e| for the `reduce` block arguments
@@ -46,20 +66,3 @@ Style/SingleLineBlockParams:
46
66
  Methods:
47
67
  - reduce: [m, e]
48
68
  - inject: [m, e]
49
-
50
- AllCops:
51
- TargetRubyVersion: 2.2
52
-
53
- # https://stackoverflow.com/q/4763121
54
- Style/Alias:
55
- Enabled: false
56
-
57
- # So RuboCop doesn't complain about application IDs
58
- Style/NumericLiterals:
59
- Exclude:
60
- - examples/*
61
-
62
- # Ignore `eval` in the examples folder
63
- Security/Eval:
64
- Exclude:
65
- - examples/*