discordrb 3.3.0 → 3.4.3
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.
- checksums.yaml +4 -4
 - data/.circleci/config.yml +126 -0
 - data/.github/ISSUE_TEMPLATE/bug_report.md +39 -0
 - data/.github/ISSUE_TEMPLATE/feature_request.md +25 -0
 - data/.github/pull_request_template.md +37 -0
 - data/.rubocop.yml +34 -37
 - data/.travis.yml +5 -6
 - data/CHANGELOG.md +504 -347
 - data/Gemfile +2 -0
 - data/LICENSE.txt +1 -1
 - data/README.md +61 -79
 - data/Rakefile +2 -0
 - data/bin/console +1 -0
 - data/discordrb-webhooks.gemspec +6 -6
 - data/discordrb.gemspec +18 -18
 - data/lib/discordrb/allowed_mentions.rb +36 -0
 - data/lib/discordrb/api/channel.rb +62 -39
 - data/lib/discordrb/api/invite.rb +3 -3
 - data/lib/discordrb/api/server.rb +57 -50
 - data/lib/discordrb/api/user.rb +9 -8
 - data/lib/discordrb/api/webhook.rb +6 -6
 - data/lib/discordrb/api.rb +40 -15
 - data/lib/discordrb/await.rb +0 -1
 - data/lib/discordrb/bot.rb +175 -73
 - data/lib/discordrb/cache.rb +4 -2
 - data/lib/discordrb/colour_rgb.rb +43 -0
 - data/lib/discordrb/commands/command_bot.rb +30 -9
 - data/lib/discordrb/commands/container.rb +20 -23
 - data/lib/discordrb/commands/parser.rb +18 -18
 - data/lib/discordrb/commands/rate_limiter.rb +3 -2
 - data/lib/discordrb/container.rb +77 -17
 - data/lib/discordrb/data/activity.rb +271 -0
 - data/lib/discordrb/data/application.rb +50 -0
 - data/lib/discordrb/data/attachment.rb +56 -0
 - data/lib/discordrb/data/audit_logs.rb +345 -0
 - data/lib/discordrb/data/channel.rb +849 -0
 - data/lib/discordrb/data/embed.rb +251 -0
 - data/lib/discordrb/data/emoji.rb +82 -0
 - data/lib/discordrb/data/integration.rb +83 -0
 - data/lib/discordrb/data/invite.rb +137 -0
 - data/lib/discordrb/data/member.rb +297 -0
 - data/lib/discordrb/data/message.rb +334 -0
 - data/lib/discordrb/data/overwrite.rb +102 -0
 - data/lib/discordrb/data/profile.rb +91 -0
 - data/lib/discordrb/data/reaction.rb +33 -0
 - data/lib/discordrb/data/recipient.rb +34 -0
 - data/lib/discordrb/data/role.rb +191 -0
 - data/lib/discordrb/data/server.rb +1002 -0
 - data/lib/discordrb/data/user.rb +204 -0
 - data/lib/discordrb/data/voice_region.rb +45 -0
 - data/lib/discordrb/data/voice_state.rb +41 -0
 - data/lib/discordrb/data/webhook.rb +145 -0
 - data/lib/discordrb/data.rb +25 -4180
 - data/lib/discordrb/errors.rb +2 -1
 - data/lib/discordrb/events/bans.rb +7 -5
 - data/lib/discordrb/events/channels.rb +2 -0
 - data/lib/discordrb/events/guilds.rb +16 -9
 - data/lib/discordrb/events/invites.rb +125 -0
 - data/lib/discordrb/events/members.rb +6 -2
 - data/lib/discordrb/events/message.rb +69 -27
 - data/lib/discordrb/events/presence.rb +14 -4
 - data/lib/discordrb/events/raw.rb +1 -3
 - data/lib/discordrb/events/reactions.rb +49 -3
 - data/lib/discordrb/events/typing.rb +6 -4
 - data/lib/discordrb/events/voice_server_update.rb +47 -0
 - data/lib/discordrb/events/voice_state_update.rb +15 -10
 - data/lib/discordrb/events/webhooks.rb +9 -6
 - data/lib/discordrb/gateway.rb +72 -57
 - data/lib/discordrb/id_object.rb +39 -0
 - data/lib/discordrb/light/integrations.rb +1 -1
 - data/lib/discordrb/light/light_bot.rb +1 -1
 - data/lib/discordrb/logger.rb +4 -4
 - data/lib/discordrb/paginator.rb +57 -0
 - data/lib/discordrb/permissions.rb +103 -8
 - data/lib/discordrb/version.rb +1 -1
 - data/lib/discordrb/voice/encoder.rb +16 -7
 - data/lib/discordrb/voice/network.rb +84 -43
 - data/lib/discordrb/voice/sodium.rb +96 -0
 - data/lib/discordrb/voice/voice_bot.rb +34 -26
 - data/lib/discordrb.rb +73 -0
 - metadata +98 -60
 - /data/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +0 -0
 
    
        data/Gemfile
    CHANGED
    
    
    
        data/LICENSE.txt
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,42 +1,58 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            [](https://rubygems.org/gems/discordrb)
         
     | 
| 
       2 
2 
     | 
    
         
             
            [](https://rubygems.org/gems/discordrb)
         
     | 
| 
       3 
     | 
    
         
            -
            [](https://codeclimate.com/github/meew0/discordrb)
         
     | 
| 
       6 
     | 
    
         
            -
            [](https://codeclimate.com/github/meew0/discordrb/coverage)
         
     | 
| 
      
 3 
     | 
    
         
            +
            [](https://circleci.com/gh/shardlab/discordrb)
         
     | 
| 
      
 4 
     | 
    
         
            +
            [](http://inch-ci.org/github/shardlab/discordrb)
         
     | 
| 
       7 
5 
     | 
    
         
             
            [](https://discord.gg/cyK3Hjm)
         
     | 
| 
       8 
6 
     | 
    
         
             
            # discordrb
         
     | 
| 
       9 
7 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
            An implementation of the [Discord](https:// 
     | 
| 
      
 8 
     | 
    
         
            +
            An implementation of the [Discord](https://discord.com/) API using Ruby.
         
     | 
| 
       11 
9 
     | 
    
         | 
| 
       12 
10 
     | 
    
         
             
            ## Quick links to sections
         
     | 
| 
       13 
11 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
            * [ 
     | 
| 
       15 
     | 
    
         
            -
            * [ 
     | 
| 
       16 
     | 
    
         
            -
            * [ 
     | 
| 
       17 
     | 
    
         
            -
            * [ 
     | 
| 
       18 
     | 
    
         
            -
            * [ 
     | 
| 
       19 
     | 
    
         
            -
            * [ 
     | 
| 
       20 
     | 
    
         
            -
            * [ 
     | 
| 
      
 12 
     | 
    
         
            +
            * [Introduction](https://github.com/shardlab/discordrb#introduction)
         
     | 
| 
      
 13 
     | 
    
         
            +
            * [Dependencies](https://github.com/shardlab/discordrb#dependencies)
         
     | 
| 
      
 14 
     | 
    
         
            +
            * [Installation](https://github.com/shardlab/discordrb#installation)
         
     | 
| 
      
 15 
     | 
    
         
            +
            * [Usage](https://github.com/shardlab/discordrb#usage)
         
     | 
| 
      
 16 
     | 
    
         
            +
            * [Webhooks Client](https://github.com/shardlab/discordrb#webhooks-client)
         
     | 
| 
      
 17 
     | 
    
         
            +
            * [Support](https://github.com/shardlab/discordrb#support)
         
     | 
| 
      
 18 
     | 
    
         
            +
            * [Development](https://github.com/shardlab/discordrb#development), [Contributing](https://github.com/shardlab/discordrb#contributing)
         
     | 
| 
      
 19 
     | 
    
         
            +
            * [License](https://github.com/shardlab/discordrb#license)
         
     | 
| 
       21 
20 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
            See also: [Documentation](https://www.rubydoc.info/gems/discordrb), [Tutorials](https://github.com/ 
     | 
| 
      
 21 
     | 
    
         
            +
            See also: [Documentation](https://www.rubydoc.info/gems/discordrb), [Tutorials](https://github.com/shardlab/discordrb/wiki)
         
     | 
| 
       23 
22 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
            ##  
     | 
| 
      
 23 
     | 
    
         
            +
            ## Introduction
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            `discordrb` aims to meet the following design goals:
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            1. Full coverage of the public bot API.
         
     | 
| 
      
 28 
     | 
    
         
            +
            2. Expressive, high level abstractions for rapid development of common applications.
         
     | 
| 
      
 29 
     | 
    
         
            +
            3. Friendly to Ruby beginners and beginners of open source contribution.
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            If you enjoy using the library, consider getting involved with the community to help us improve and meet these goals!
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            **You should consider using `discordrb` if:**
         
     | 
| 
       25 
34 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 35 
     | 
    
         
            +
            - You need a bot - and fast - for small or medium sized communities, and don't want to be bogged down with "low level" details. Getting started takes minutes, and utilities like a command parser and tools for modularization make it simple to quickly add or change your bots functionality.
         
     | 
| 
      
 36 
     | 
    
         
            +
            - You like or want to learn Ruby, or want to contribute to a Ruby project. A lot of our users are new to Ruby, and eventually make their first open source contributions with us. We have an active Discord channel with experienced members who will happily help you get involved, either as a user or contributor.
         
     | 
| 
      
 37 
     | 
    
         
            +
            - You want to experiment with Discord's API or prototype concepts for Discord bots without too much commitment.
         
     | 
| 
       28 
38 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
      
 39 
     | 
    
         
            +
            **You should consider other libraries if:**
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            - You need to scale to large volumes of servers (>2,500) with lots of members. It's still possible, but it can be difficult to scale Ruby processes, and it requires more in depth knowledge to do so well. Especially if you already have a bot that is on a large amount of servers, porting to Ruby is unlikely to improve your performance in most cases.
         
     | 
| 
      
 42 
     | 
    
         
            +
            - You want full control over the library that you're using. While we expose some "lower level" interfaces, they are unstable, and only exist to serve the more powerful abstractions in the library.
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            ## Dependencies
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            * Ruby >= 2.5 supported
         
     | 
| 
      
 47 
     | 
    
         
            +
            * An installed build system for native extensions (on Windows, make sure you download the "Ruby+Devkit" version of [RubyInstaller](https://rubyinstaller.org/downloads/))
         
     | 
| 
       30 
48 
     | 
    
         | 
| 
       31 
49 
     | 
    
         
             
            ### Voice dependencies
         
     | 
| 
       32 
50 
     | 
    
         | 
| 
       33 
51 
     | 
    
         
             
            This section only applies to you if you want to use voice functionality.
         
     | 
| 
       34 
     | 
    
         
            -
            * [libsodium](https://github.com/ 
     | 
| 
       35 
     | 
    
         
            -
            * A compiled libopus distribution for your system, anywhere the script can find it. See [here](https://github.com/ 
     | 
| 
      
 52 
     | 
    
         
            +
            * [libsodium](https://github.com/shardlab/discordrb/wiki/Installing-libsodium)
         
     | 
| 
      
 53 
     | 
    
         
            +
            * A compiled libopus distribution for your system, anywhere the script can find it. See [here](https://github.com/shardlab/discordrb/wiki/Installing-libopus) for installation instructions.
         
     | 
| 
       36 
54 
     | 
    
         
             
            * [FFmpeg](https://www.ffmpeg.org/download.html) installed and in your PATH
         
     | 
| 
       37 
55 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
            In addition to this, if you're on Windows and want to use voice functionality, your installed Ruby version **needs to be 32 bit**, as otherwise Opus won't work.
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
56 
     | 
    
         
             
            ## Installation
         
     | 
| 
       41 
57 
     | 
    
         | 
| 
       42 
58 
     | 
    
         
             
            ### With Bundler
         
     | 
| 
         @@ -47,7 +63,7 @@ Using [Bundler](https://bundler.io/#getting-started), you can add discordrb to y 
     | 
|
| 
       47 
63 
     | 
    
         | 
| 
       48 
64 
     | 
    
         
             
            And then install via `bundle install`.
         
     | 
| 
       49 
65 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
            Run the [ping example](https://github.com/ 
     | 
| 
      
 66 
     | 
    
         
            +
            Run the [ping example](https://github.com/shardlab/discordrb/blob/master/examples/ping.rb) to verify that the installation works (make sure to replace the token and client ID in there with your bots'!):
         
     | 
| 
       51 
67 
     | 
    
         | 
| 
       52 
68 
     | 
    
         
             
            To run the bot while using bundler:
         
     | 
| 
       53 
69 
     | 
    
         | 
| 
         @@ -63,7 +79,7 @@ Alternatively, while Bundler is the recommended option, you can also install dis 
     | 
|
| 
       63 
79 
     | 
    
         | 
| 
       64 
80 
     | 
    
         
             
            #### Windows
         
     | 
| 
       65 
81 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
            > **Make sure you have the DevKit installed! See the [Dependencies](https://github.com/ 
     | 
| 
      
 82 
     | 
    
         
            +
            > **Make sure you have the DevKit installed! See the [Dependencies](https://github.com/shardlab/discordrb#dependencies) section)**
         
     | 
| 
       67 
83 
     | 
    
         | 
| 
       68 
84 
     | 
    
         
             
                gem install discordrb --platform=ruby
         
     | 
| 
       69 
85 
     | 
    
         | 
| 
         @@ -71,53 +87,9 @@ To run the bot: 
     | 
|
| 
       71 
87 
     | 
    
         | 
| 
       72 
88 
     | 
    
         
             
                ruby ping.rb
         
     | 
| 
       73 
89 
     | 
    
         | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
            **If you get an error like this when installing the gem**:
         
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
                ERROR:  Error installing discordrb:
         
     | 
| 
       79 
     | 
    
         
            -
                        The 'websocket-driver' native gem requires installed build tools.
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
            You're missing the development kit required to build native extensions.
         
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
            ##### RubyInstaller for ruby 2.4.3-2 and above
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
            RubyInstaller after version 2.3.3 now includes the development kit in the installer. If you do not have the development kit and have installed ruby using RubyInstaller, open a command prompt with administrator privileges and run:
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
                ridk install
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
            Select option 3, and then run
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                ridk enable
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
            To enable the changes
         
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
            ##### RubyInstaller for ruby 2.3.3 and below
         
     | 
| 
      
 90 
     | 
    
         
            +
            ### Installation Troubleshooting
         
     | 
| 
       96 
91 
     | 
    
         | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
                ruby dk.rb init
         
     | 
| 
       100 
     | 
    
         
            -
                ruby dk.rb install
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
            Then reinstall discordrb:
         
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
                gem uninstall discordrb
         
     | 
| 
       105 
     | 
    
         
            -
                bundle install
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
                # Or, if you didn't use bundler:
         
     | 
| 
       108 
     | 
    
         
            -
                gem install discordrb
         
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
            **If Ruby complains about `ffi_c` not being able to be found:**
         
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
            For example
         
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
                C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- ffi_c (LoadError)
         
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
            Your ffi setup is screwed up, first run `gem uninstall ffi` (uninstall all versions if it asks you, say yes to any unmet dependencies), then run `gem install ffi --platform=ruby` to fix it. If it says something about build tools, follow the steps in the first troubleshooting section.
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
            **If you're having trouble getting voice playback to work**:
         
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
            Look here: https://github.com/meew0/discordrb/wiki/Voice-sending#troubleshooting
         
     | 
| 
      
 92 
     | 
    
         
            +
            See https://github.com/shardlab/discordrb/wiki/FAQ#installation for a list of common problems and solutions when installing `discordrb`.
         
     | 
| 
       121 
93 
     | 
    
         | 
| 
       122 
94 
     | 
    
         
             
            ## Usage
         
     | 
| 
       123 
95 
     | 
    
         | 
| 
         @@ -137,7 +109,7 @@ bot.run 
     | 
|
| 
       137 
109 
     | 
    
         | 
| 
       138 
110 
     | 
    
         
             
            This bot responds to every "Ping!" with a "Pong!".
         
     | 
| 
       139 
111 
     | 
    
         | 
| 
       140 
     | 
    
         
            -
            See [additional examples here](https://github.com/ 
     | 
| 
      
 112 
     | 
    
         
            +
            See [additional examples here](https://github.com/shardlab/discordrb/tree/master/examples).
         
     | 
| 
       141 
113 
     | 
    
         | 
| 
       142 
114 
     | 
    
         
             
            You can find examples of projects that use discordrb by [searching for the discordrb topic on GitHub](https://github.com/topics/discordrb).
         
     | 
| 
       143 
115 
     | 
    
         | 
| 
         @@ -148,7 +120,7 @@ If you've made an open source project on GitHub that uses discordrb, consider ad 
     | 
|
| 
       148 
120 
     | 
    
         
             
            Also included is a webhooks client, which can be used as a separate gem `discordrb-webhooks`. This special client can be used to form requests to Discord webhook URLs in a high-level manner.
         
     | 
| 
       149 
121 
     | 
    
         | 
| 
       150 
122 
     | 
    
         
             
            - [`discordrb-webhooks` documentation](https://www.rubydoc.info/gems/discordrb-webhooks)
         
     | 
| 
       151 
     | 
    
         
            -
            - [More information about webhooks](https://support. 
     | 
| 
      
 123 
     | 
    
         
            +
            - [More information about webhooks](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks)
         
     | 
| 
       152 
124 
     | 
    
         
             
            - [Embed visualizer tool](https://leovoel.github.io/embed-visualizer/) - Includes a discordrb code generator for forming embeds
         
     | 
| 
       153 
125 
     | 
    
         | 
| 
       154 
126 
     | 
    
         
             
            ### Usage
         
     | 
| 
         @@ -156,7 +128,7 @@ Also included is a webhooks client, which can be used as a separate gem `discord 
     | 
|
| 
       156 
128 
     | 
    
         
             
            ```ruby
         
     | 
| 
       157 
129 
     | 
    
         
             
            require 'discordrb/webhooks'
         
     | 
| 
       158 
130 
     | 
    
         | 
| 
       159 
     | 
    
         
            -
            WEBHOOK_URL = 'https:// 
     | 
| 
      
 131 
     | 
    
         
            +
            WEBHOOK_URL = 'https://discord.com/api/webhooks/424070213278105610/yByxDncRvHi02mhKQheviQI2erKkfRRwFcEp0MMBfib1ds6ZHN13xhPZNS2-fJo_ApSw'.freeze
         
     | 
| 
       160 
132 
     | 
    
         | 
| 
       161 
133 
     | 
    
         
             
            client = Discordrb::Webhooks::Client.new(url: WEBHOOK_URL)
         
     | 
| 
       162 
134 
     | 
    
         
             
            client.execute do |builder|
         
     | 
| 
         @@ -173,19 +145,29 @@ end 
     | 
|
| 
       173 
145 
     | 
    
         | 
| 
       174 
146 
     | 
    
         
             
            ## Support
         
     | 
| 
       175 
147 
     | 
    
         | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
      
 148 
     | 
    
         
            +
            If you need help or have a question, you can:
         
     | 
| 
       177 
149 
     | 
    
         | 
| 
       178 
     | 
    
         
            -
             
     | 
| 
      
 150 
     | 
    
         
            +
            1. Join our [Discord channel](https://discord.gg/cyK3Hjm). This is the fastest means of getting support.
         
     | 
| 
      
 151 
     | 
    
         
            +
            2. [Open an issue](https://github.com/shardlab/discordrb/issues). Be sure to read the issue template, and provide as much detail as you can.
         
     | 
| 
       179 
152 
     | 
    
         | 
| 
       180 
     | 
    
         
            -
             
     | 
| 
      
 153 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
       181 
154 
     | 
    
         | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
      
 155 
     | 
    
         
            +
            Thank you for your interest in contributing!
         
     | 
| 
      
 156 
     | 
    
         
            +
            Bug reports and pull requests are welcome on GitHub at https://github.com/shardlab/discordrb.
         
     | 
| 
       183 
157 
     | 
    
         | 
| 
       184 
     | 
    
         
            -
             
     | 
| 
      
 158 
     | 
    
         
            +
            In general, we recommend starting by discussing what you would like to contribute in the [Discord channel](https://discord.gg/cyK3Hjm).
         
     | 
| 
      
 159 
     | 
    
         
            +
            There are usually a handful of people working on things for the library, and what you're looking for may already be on the way.
         
     | 
| 
       185 
160 
     | 
    
         | 
| 
       186 
     | 
    
         
            -
             
     | 
| 
      
 161 
     | 
    
         
            +
            Additionally, there is a chance what you are looking for might already exist, or we decided not to pursue it for some reason.
         
     | 
| 
      
 162 
     | 
    
         
            +
            Be sure to use the search feature on our documentation, GitHub, and Discord to see if this might be the case.
         
     | 
| 
       187 
163 
     | 
    
         | 
| 
       188 
     | 
    
         
            -
             
     | 
| 
      
 164 
     | 
    
         
            +
            ## Development setup
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
            **This section is for developing discordrb itself! If you just want to make a bot, see the [Installation](https://github.com/shardlab/discordrb#installation) section.**
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
            After checking out the repo, run `bin/setup` to install dependencies. You can then run tests via `bundle exec rspec spec`. Make sure to run rubocop also: `bundle exec rubocop`. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
            To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
         
     | 
| 
       189 
171 
     | 
    
         | 
| 
       190 
172 
     | 
    
         
             
            ## License
         
     | 
| 
       191 
173 
     | 
    
         | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/bin/console
    CHANGED
    
    
    
        data/discordrb-webhooks.gemspec
    CHANGED
    
    | 
         @@ -1,18 +1,18 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #  
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            lib = File.expand_path(' 
     | 
| 
      
 3 
     | 
    
         
            +
            lib = File.expand_path('lib', __dir__)
         
     | 
| 
       4 
4 
     | 
    
         
             
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
       5 
5 
     | 
    
         
             
            require 'discordrb/webhooks/version'
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       8 
8 
     | 
    
         
             
              spec.name          = 'discordrb-webhooks'
         
     | 
| 
       9 
9 
     | 
    
         
             
              spec.version       = Discordrb::Webhooks::VERSION
         
     | 
| 
       10 
     | 
    
         
            -
              spec.authors       = [ 
     | 
| 
      
 10 
     | 
    
         
            +
              spec.authors       = %w[meew0 swarley]
         
     | 
| 
       11 
11 
     | 
    
         
             
              spec.email         = ['']
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
              spec.summary       = 'Webhook client for discordrb'
         
     | 
| 
       14 
14 
     | 
    
         
             
              spec.description   = "A client for Discord's webhooks to fit alongside [discordrb](https://rubygems.org/gems/discordrb)."
         
     | 
| 
       15 
     | 
    
         
            -
              spec.homepage      = 'https://github.com/ 
     | 
| 
      
 15 
     | 
    
         
            +
              spec.homepage      = 'https://github.com/shardlab/discordrb'
         
     | 
| 
       16 
16 
     | 
    
         
             
              spec.license       = 'MIT'
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
              spec.files         = `git ls-files -z lib/discordrb/webhooks/`.split("\x0") + ['lib/discordrb/webhooks.rb']
         
     | 
| 
         @@ -20,7 +20,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       20 
20 
     | 
    
         
             
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         
     | 
| 
       21 
21 
     | 
    
         
             
              spec.require_paths = ['lib']
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
              spec.add_dependency 'rest-client', '>= 2. 
     | 
| 
      
 23 
     | 
    
         
            +
              spec.add_dependency 'rest-client', '>= 2.0.0'
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
              spec.required_ruby_version = '>= 2. 
     | 
| 
      
 25 
     | 
    
         
            +
              spec.required_ruby_version = '>= 2.5'
         
     | 
| 
       26 
26 
     | 
    
         
             
            end
         
     | 
    
        data/discordrb.gemspec
    CHANGED
    
    | 
         @@ -1,44 +1,44 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #  
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            lib = File.expand_path(' 
     | 
| 
      
 3 
     | 
    
         
            +
            lib = File.expand_path('lib', __dir__)
         
     | 
| 
       4 
4 
     | 
    
         
             
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
       5 
5 
     | 
    
         
             
            require 'discordrb/version'
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       8 
8 
     | 
    
         
             
              spec.name          = 'discordrb'
         
     | 
| 
       9 
9 
     | 
    
         
             
              spec.version       = Discordrb::VERSION
         
     | 
| 
       10 
     | 
    
         
            -
              spec.authors       = [ 
     | 
| 
      
 10 
     | 
    
         
            +
              spec.authors       = %w[meew0 swarley]
         
     | 
| 
       11 
11 
     | 
    
         
             
              spec.email         = ['']
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
              spec.summary       = 'Discord API for Ruby'
         
     | 
| 
       14 
     | 
    
         
            -
              spec.description   = 'A Ruby implementation of the Discord (https:// 
     | 
| 
       15 
     | 
    
         
            -
              spec.homepage      = 'https://github.com/ 
     | 
| 
      
 14 
     | 
    
         
            +
              spec.description   = 'A Ruby implementation of the Discord (https://discord.com) API.'
         
     | 
| 
      
 15 
     | 
    
         
            +
              spec.homepage      = 'https://github.com/shardlab/discordrb'
         
     | 
| 
       16 
16 
     | 
    
         
             
              spec.license       = 'MIT'
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
              spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|examples|lib/discordrb/webhooks)/}) }
         
     | 
| 
       19 
19 
     | 
    
         
             
              spec.bindir        = 'exe'
         
     | 
| 
       20 
20 
     | 
    
         
             
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         
     | 
| 
       21 
21 
     | 
    
         
             
              spec.metadata = {
         
     | 
| 
       22 
     | 
    
         
            -
                'changelog_uri' => 'https://github.com/ 
     | 
| 
      
 22 
     | 
    
         
            +
                'changelog_uri' => 'https://github.com/shardlab/discordrb/blob/master/CHANGELOG.md'
         
     | 
| 
       23 
23 
     | 
    
         
             
              }
         
     | 
| 
       24 
24 
     | 
    
         
             
              spec.require_paths = ['lib']
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
              spec.add_dependency ' 
     | 
| 
      
 26 
     | 
    
         
            +
              spec.add_dependency 'ffi', '>= 1.9.24'
         
     | 
| 
       27 
27 
     | 
    
         
             
              spec.add_dependency 'opus-ruby'
         
     | 
| 
      
 28 
     | 
    
         
            +
              spec.add_dependency 'rest-client', '>= 2.0.0'
         
     | 
| 
       28 
29 
     | 
    
         
             
              spec.add_dependency 'websocket-client-simple', '>= 0.3.0'
         
     | 
| 
       29 
     | 
    
         
            -
              spec.add_dependency 'rbnacl', '~> 3.4.0' # 24: update
         
     | 
| 
       30 
     | 
    
         
            -
              spec.add_dependency 'ffi', '>= 1.9.24'
         
     | 
| 
       31 
30 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
              spec.add_dependency 'discordrb-webhooks', '~> 3.3 
     | 
| 
      
 31 
     | 
    
         
            +
              spec.add_dependency 'discordrb-webhooks', '~> 3.4.3'
         
     | 
| 
       33 
32 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
              spec.required_ruby_version = '>= 2. 
     | 
| 
      
 33 
     | 
    
         
            +
              spec.required_ruby_version = '>= 2.5'
         
     | 
| 
       35 
34 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
              spec.add_development_dependency 'bundler', ' 
     | 
| 
       37 
     | 
    
         
            -
              spec.add_development_dependency 'rake', '~>  
     | 
| 
       38 
     | 
    
         
            -
              spec.add_development_dependency ' 
     | 
| 
       39 
     | 
    
         
            -
              spec.add_development_dependency ' 
     | 
| 
       40 
     | 
    
         
            -
              spec.add_development_dependency 'rspec', '~> 3.4.0'
         
     | 
| 
      
 35 
     | 
    
         
            +
              spec.add_development_dependency 'bundler', '>= 1.10', '< 3'
         
     | 
| 
      
 36 
     | 
    
         
            +
              spec.add_development_dependency 'rake', '~> 13.0'
         
     | 
| 
      
 37 
     | 
    
         
            +
              spec.add_development_dependency 'redcarpet', '~> 3.5.0' # YARD markdown formatting
         
     | 
| 
      
 38 
     | 
    
         
            +
              spec.add_development_dependency 'rspec', '~> 3.10.0'
         
     | 
| 
       41 
39 
     | 
    
         
             
              spec.add_development_dependency 'rspec-prof', '~> 0.0.7'
         
     | 
| 
       42 
     | 
    
         
            -
              spec.add_development_dependency 'rubocop', ' 
     | 
| 
       43 
     | 
    
         
            -
              spec.add_development_dependency ' 
     | 
| 
      
 40 
     | 
    
         
            +
              spec.add_development_dependency 'rubocop', '~> 1.4.0'
         
     | 
| 
      
 41 
     | 
    
         
            +
              spec.add_development_dependency 'rubocop-performance', '~> 1.0'
         
     | 
| 
      
 42 
     | 
    
         
            +
              spec.add_development_dependency 'simplecov', '~> 0.19.0'
         
     | 
| 
      
 43 
     | 
    
         
            +
              spec.add_development_dependency 'yard', '~> 0.9.9'
         
     | 
| 
       44 
44 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'discordrb/id_object'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module Discordrb
         
     | 
| 
      
 6 
     | 
    
         
            +
              # Builder class for `allowed_mentions` when sending messages.
         
     | 
| 
      
 7 
     | 
    
         
            +
              class AllowedMentions
         
     | 
| 
      
 8 
     | 
    
         
            +
                # @return [Array<"users", "roles", "everyone">, nil]
         
     | 
| 
      
 9 
     | 
    
         
            +
                attr_accessor :parse
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                # @return [Array<String, Integer>, nil]
         
     | 
| 
      
 12 
     | 
    
         
            +
                attr_accessor :users
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                # @return [Array<String, Integer>, nil]
         
     | 
| 
      
 15 
     | 
    
         
            +
                attr_accessor :roles
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                # @param parse [Array<"users", "roles", "everyone">] Mention types that can be inferred from the message.
         
     | 
| 
      
 18 
     | 
    
         
            +
                #   `users` and `roles` allow for all mentions of the respective type to ping. `everyone` allows usage of `@everyone` and `@here`
         
     | 
| 
      
 19 
     | 
    
         
            +
                # @param users [Array<User, String, Integer>] Users or user IDs that can be pinged. Cannot be used in conjunction with `"users"` in `parse`
         
     | 
| 
      
 20 
     | 
    
         
            +
                # @param roles [Array<Role, String, Integer>] Roles or role IDs that can be pinged. Cannot be used in conjunction with `"roles"` in `parse`
         
     | 
| 
      
 21 
     | 
    
         
            +
                def initialize(parse: nil, users: nil, roles: nil)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  @parse = parse
         
     | 
| 
      
 23 
     | 
    
         
            +
                  @users = users
         
     | 
| 
      
 24 
     | 
    
         
            +
                  @roles = roles
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                # @!visibility private
         
     | 
| 
      
 28 
     | 
    
         
            +
                def to_hash
         
     | 
| 
      
 29 
     | 
    
         
            +
                  {
         
     | 
| 
      
 30 
     | 
    
         
            +
                    parse: @parse,
         
     | 
| 
      
 31 
     | 
    
         
            +
                    users: @users&.map { |user| user.is_a?(IDObject) ? user.id : user },
         
     | 
| 
      
 32 
     | 
    
         
            +
                    roles: @roles&.map { |role| role.is_a?(IDObject) ? role.id : role }
         
     | 
| 
      
 33 
     | 
    
         
            +
                  }.compact
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     |