discordrb 3.3.0 → 3.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +126 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +39 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +25 -0
  5. data/.github/pull_request_template.md +37 -0
  6. data/.rubocop.yml +34 -37
  7. data/.travis.yml +5 -6
  8. data/CHANGELOG.md +504 -347
  9. data/Gemfile +2 -0
  10. data/LICENSE.txt +1 -1
  11. data/README.md +61 -79
  12. data/Rakefile +2 -0
  13. data/bin/console +1 -0
  14. data/discordrb-webhooks.gemspec +6 -6
  15. data/discordrb.gemspec +18 -18
  16. data/lib/discordrb/allowed_mentions.rb +36 -0
  17. data/lib/discordrb/api/channel.rb +62 -39
  18. data/lib/discordrb/api/invite.rb +3 -3
  19. data/lib/discordrb/api/server.rb +57 -50
  20. data/lib/discordrb/api/user.rb +9 -8
  21. data/lib/discordrb/api/webhook.rb +6 -6
  22. data/lib/discordrb/api.rb +40 -15
  23. data/lib/discordrb/await.rb +0 -1
  24. data/lib/discordrb/bot.rb +175 -73
  25. data/lib/discordrb/cache.rb +4 -2
  26. data/lib/discordrb/colour_rgb.rb +43 -0
  27. data/lib/discordrb/commands/command_bot.rb +30 -9
  28. data/lib/discordrb/commands/container.rb +20 -23
  29. data/lib/discordrb/commands/parser.rb +18 -18
  30. data/lib/discordrb/commands/rate_limiter.rb +3 -2
  31. data/lib/discordrb/container.rb +77 -17
  32. data/lib/discordrb/data/activity.rb +271 -0
  33. data/lib/discordrb/data/application.rb +50 -0
  34. data/lib/discordrb/data/attachment.rb +56 -0
  35. data/lib/discordrb/data/audit_logs.rb +345 -0
  36. data/lib/discordrb/data/channel.rb +849 -0
  37. data/lib/discordrb/data/embed.rb +251 -0
  38. data/lib/discordrb/data/emoji.rb +82 -0
  39. data/lib/discordrb/data/integration.rb +83 -0
  40. data/lib/discordrb/data/invite.rb +137 -0
  41. data/lib/discordrb/data/member.rb +297 -0
  42. data/lib/discordrb/data/message.rb +334 -0
  43. data/lib/discordrb/data/overwrite.rb +102 -0
  44. data/lib/discordrb/data/profile.rb +91 -0
  45. data/lib/discordrb/data/reaction.rb +33 -0
  46. data/lib/discordrb/data/recipient.rb +34 -0
  47. data/lib/discordrb/data/role.rb +191 -0
  48. data/lib/discordrb/data/server.rb +1002 -0
  49. data/lib/discordrb/data/user.rb +204 -0
  50. data/lib/discordrb/data/voice_region.rb +45 -0
  51. data/lib/discordrb/data/voice_state.rb +41 -0
  52. data/lib/discordrb/data/webhook.rb +145 -0
  53. data/lib/discordrb/data.rb +25 -4180
  54. data/lib/discordrb/errors.rb +2 -1
  55. data/lib/discordrb/events/bans.rb +7 -5
  56. data/lib/discordrb/events/channels.rb +2 -0
  57. data/lib/discordrb/events/guilds.rb +16 -9
  58. data/lib/discordrb/events/invites.rb +125 -0
  59. data/lib/discordrb/events/members.rb +6 -2
  60. data/lib/discordrb/events/message.rb +69 -27
  61. data/lib/discordrb/events/presence.rb +14 -4
  62. data/lib/discordrb/events/raw.rb +1 -3
  63. data/lib/discordrb/events/reactions.rb +49 -3
  64. data/lib/discordrb/events/typing.rb +6 -4
  65. data/lib/discordrb/events/voice_server_update.rb +47 -0
  66. data/lib/discordrb/events/voice_state_update.rb +15 -10
  67. data/lib/discordrb/events/webhooks.rb +9 -6
  68. data/lib/discordrb/gateway.rb +72 -57
  69. data/lib/discordrb/id_object.rb +39 -0
  70. data/lib/discordrb/light/integrations.rb +1 -1
  71. data/lib/discordrb/light/light_bot.rb +1 -1
  72. data/lib/discordrb/logger.rb +4 -4
  73. data/lib/discordrb/paginator.rb +57 -0
  74. data/lib/discordrb/permissions.rb +103 -8
  75. data/lib/discordrb/version.rb +1 -1
  76. data/lib/discordrb/voice/encoder.rb +16 -7
  77. data/lib/discordrb/voice/network.rb +84 -43
  78. data/lib/discordrb/voice/sodium.rb +96 -0
  79. data/lib/discordrb/voice/voice_bot.rb +34 -26
  80. data/lib/discordrb.rb +73 -0
  81. metadata +98 -60
  82. /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: a5c0ecfd68356ed63ea61a7b99bb5d32e358f74b23c2f729ab531e4848bc770d
4
+ data.tar.gz: 4c5917f1b7a1a3e97d875a0244a8fa8e9583bce025053505b960de9e900ca16f
5
5
  SHA512:
6
- metadata.gz: 5bb79daa3219ec1c75f637ccaf39c71e943ba2e162c02ca46fd2775e7a746d4cfecafda8af8402d215936660249b96ae441632444d7718688badf19ae38f72fe
7
- data.tar.gz: 71110b5df4bade1aac8d54b708bbc93b5a91d61c146eb56e9aa25a94f9dd0ff0f291db4c0c28589f095ab9fa19ed9204e50a0aaa920557c6fdc802d88eaa733a
6
+ metadata.gz: '09b5b31c7e7f15c7053c476ae0c2fd11839b7f5b82c4dea330764da42321c8333559df72273cdffbafe91bc9452a51a4bece945a2e6b3a8774af5fce409750fb'
7
+ data.tar.gz: 1743f21d2ad48858e8ebed88984fdf5cecb2ce5878ae0cbf32dbccc451175daa1d0f37c571efa100dadd94dcb169b17515bc691884d9583e00b40f57b45242ff
@@ -0,0 +1,126 @@
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_25:
31
+ docker:
32
+ - image: ruby:2.5-alpine
33
+ steps:
34
+ - setup-env
35
+ - run:
36
+ name: Run RSpec
37
+ command: bundle exec rspec
38
+
39
+ test_ruby_26:
40
+ docker:
41
+ - image: ruby:2.6-alpine
42
+ steps:
43
+ - setup-env
44
+ - run:
45
+ name: Run RSpec
46
+ command: bundle exec rspec
47
+
48
+ test_ruby_27:
49
+ docker:
50
+ - image: ruby:2.7-alpine
51
+ steps:
52
+ - setup-env
53
+ - run:
54
+ name: Run RSpec
55
+ command: bundle exec rspec
56
+
57
+ rubocop:
58
+ docker:
59
+ - image: ruby:2.5-alpine
60
+ steps:
61
+ - setup-env
62
+ - run:
63
+ name: Run Rubocop
64
+ command: bundle exec rubocop -P
65
+
66
+ yard:
67
+ docker:
68
+ - image: ruby:2.5-alpine
69
+ steps:
70
+ - setup-env
71
+ - attach_workspace:
72
+ at: /tmp/workspace
73
+ - run:
74
+ name: Run YARD
75
+ command: bundle exec yard --output-dir /tmp/workspace/docs
76
+ - persist_to_workspace:
77
+ root: /tmp/workspace
78
+ paths:
79
+ - docs
80
+
81
+ pages:
82
+ machine: true
83
+ steps:
84
+ - attach_workspace:
85
+ at: /tmp/workspace
86
+ - run:
87
+ name: Clone docs
88
+ command: git clone $CIRCLE_REPOSITORY_URL -b gh-pages .
89
+ - add_ssh_keys:
90
+ fingerprints:
91
+ - "9a:4c:50:94:23:46:81:74:41:97:87:04:4e:59:4b:4e"
92
+ - run:
93
+ name: Push updated docs
94
+ command: |
95
+ git config user.name "Circle CI"
96
+ git config user.email "ci-build@shardlab.dev"
97
+
98
+ SOURCE_BRANCH=$CIRCLE_BRANCH
99
+ if [ -n "$CIRCLE_TAG" ]; then
100
+ SOURCE_BRANCH=$CIRCLE_TAG
101
+ fi
102
+
103
+ mkdir -p $SOURCE_BRANCH
104
+ rm -rf $SOURCE_BRANCH/*
105
+ cp -r /tmp/workspace/docs/. ./$SOURCE_BRANCH/
106
+
107
+ git add $SOURCE_BRANCH
108
+ git commit --allow-empty -m "[skip ci] Deploy docs"
109
+ git push -u origin gh-pages
110
+
111
+ workflows:
112
+ test:
113
+ jobs:
114
+ - test_ruby_25
115
+ - test_ruby_26
116
+ - test_ruby_27
117
+ - rubocop
118
+ - yard
119
+ deploy:
120
+ jobs:
121
+ - yard:
122
+ filters: {branches: {only: main}, tags: {only: /^v.*/}}
123
+ - pages:
124
+ requires:
125
+ - yard
126
+ filters: {branches: {only: main}, tags: {only: /^v.*/}}
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: Bug report
3
+ about: Report a bug to help us improve the library
4
+
5
+ ---
6
+
7
+ # Summary
8
+
9
+ <!---
10
+ First, please check to see that another issue or pull request (open or closed)
11
+ already addresses the problem you are facing. If you are not sure, please ask
12
+ in the Discord channel (link below).
13
+
14
+ Describe the bug you are encountering with as much detail as you can.
15
+ If you are not sure if a small detail is relevant, include it anyways!
16
+
17
+ Include simple code examples that will reproduce the bug.
18
+ Include any exceptions you are encountering in your logs, including
19
+ the initial error message and the backtrace that follows.
20
+
21
+ Stuck or need help? Join the Discord! https://discord.gg/cyK3Hjm
22
+ -->
23
+
24
+ ---
25
+
26
+ ## Environment
27
+
28
+ <!---
29
+ These are some commands to run to give us basic information about
30
+ your Ruby environment. Some issues may be version, OS, or hardware specific.
31
+ --->
32
+
33
+ **Ruby version:**
34
+
35
+ <!--- Paste full output of `ruby -v` here --->
36
+
37
+ **Discordrb version:**
38
+
39
+ <!--- Paste full output of `gem list discordrb` or `bundle list discordrb` here --->
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: Feature Request
3
+ about: Request a new feature, or change an existing one
4
+
5
+ ---
6
+
7
+ <!---
8
+ Describe your feature request in as much detail as you can here.
9
+
10
+ Include why you want this feature. For example:
11
+
12
+ - It is a feature supported by Discord's API, but missing from the library
13
+
14
+ - It is a feature that would simplify a lot of your bots code
15
+
16
+ - It is a feature present in other popular Discord libraries
17
+
18
+ Include simple code examples (pseudocode is fine) that demonstrate
19
+ what you want to do.
20
+
21
+ Do your best to think about how this new feature would impact the code
22
+ of other people who use discordrb, and not just your own bot's codebase.
23
+
24
+ Stuck or need help? Join the Discord! https://discord.gg/cyK3Hjm
25
+ --->
@@ -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
data/.rubocop.yml CHANGED
@@ -1,44 +1,58 @@
1
- # Disable all metrics.
2
- Metrics/AbcSize:
3
- Enabled: false
1
+ require: rubocop-performance
4
2
 
5
- Metrics/BlockNesting:
6
- Enabled: false
3
+ inherit_mode:
4
+ merge:
5
+ - AllowedNames
7
6
 
8
- Metrics/BlockLength:
9
- Enabled: false
7
+ AllCops:
8
+ NewCops: enable
9
+ TargetRubyVersion: 2.5
10
10
 
11
- Metrics/ClassLength:
11
+ # Disable line length checks
12
+ Layout/LineLength:
12
13
  Enabled: false
13
14
 
14
- Metrics/ModuleLength:
15
+ # TODO: Larger refactor
16
+ Lint/MissingSuper:
15
17
  Enabled: false
16
18
 
17
- Metrics/CyclomaticComplexity:
19
+ # Allow 'Pokémon-style' exception handling
20
+ Lint/RescueException:
18
21
  Enabled: false
19
22
 
20
- Metrics/LineLength:
23
+ # Disable all metrics.
24
+ Metrics:
21
25
  Enabled: false
22
26
 
23
- Metrics/MethodLength:
24
- Enabled: false
27
+ # Allow some common and/or obvious short method params
28
+ Naming/MethodParameterName:
29
+ AllowedNames:
30
+ - e
25
31
 
26
- Metrics/ParameterLists:
27
- Enabled: false
32
+ # Ignore `eval` in the examples folder
33
+ Security/Eval:
34
+ Exclude:
35
+ - examples/**/*
28
36
 
29
- Metrics/PerceivedComplexity:
37
+ # https://stackoverflow.com/q/4763121/
38
+ Style/Alias:
30
39
  Enabled: false
31
40
 
32
41
  # Prefer compact module/class defs
33
42
  Style/ClassAndModuleChildren:
34
43
  Enabled: false
35
44
 
36
- # Allow CamelCase constants as well as SCREAMING_SNAKE_CASE
37
- Style/ConstantName:
45
+ # So RuboCop doesn't complain about application IDs
46
+ Style/NumericLiterals:
47
+ Exclude:
48
+ - examples/**/*
49
+
50
+ # TODO: Requires breaking changes
51
+ Style/OptionalBooleanParameter:
38
52
  Enabled: false
39
53
 
40
- # Allow 'Pokémon-style' exception handling
41
- Lint/RescueException:
54
+ # Prefer explicit arguments in case global variables like `$;` or `$,` are changed
55
+ Style/RedundantArgument:
42
56
  Enabled: false
43
57
 
44
58
  # Prefer |m, e| for the `reduce` block arguments
@@ -46,20 +60,3 @@ Style/SingleLineBlockParams:
46
60
  Methods:
47
61
  - reduce: [m, e]
48
62
  - 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/*
data/.travis.yml CHANGED
@@ -1,13 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.10
4
- - 2.3.7
5
- - 2.4.4
6
- - 2.5.1
3
+ - 2.5
4
+ - 2.6
7
5
  before_script:
8
6
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 -o ./cc-test-reporter
9
7
  - chmod +x ./cc-test-reporter
10
8
  - ./cc-test-reporter before-build
9
+ - sudo apt-get install libsodium-dev
11
10
  script:
12
11
  - bundle exec rspec spec
13
12
  - bundle exec rubocop -c .rubocop.yml
@@ -22,7 +21,7 @@ deploy:
22
21
  local-dir: docs
23
22
  on:
24
23
  branch: master
25
- rvm: 2.5.1
24
+ rvm: 2.6
26
25
  - provider: pages
27
26
  skip-cleanup: true
28
27
  github-token: $GITHUB_TOKEN
@@ -30,4 +29,4 @@ deploy:
30
29
  local-dir: docs
31
30
  on:
32
31
  tags: true
33
- rvm: 2.5.1
32
+ rvm: 2.6