discorb 0.9.3 → 0.10.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.
- checksums.yaml +4 -4
- data/.github/workflows/build_main.yml +2 -0
- data/Changelog.md +298 -247
- data/README.md +6 -6
- data/Rakefile +7 -1
- data/assets/banner.svg +101 -101
- data/docs/application_command.md +8 -7
- data/docs/cli/run.md +3 -3
- data/docs/extension.md +16 -22
- data/docs/license.md +5 -1
- data/examples/extension/main.rb +1 -1
- data/examples/extension/message_expander.rb +4 -6
- data/lib/discorb/app_command.rb +12 -10
- data/lib/discorb/application.rb +3 -3
- data/lib/discorb/asset.rb +2 -2
- data/lib/discorb/audit_logs.rb +7 -7
- data/lib/discorb/channel.rb +10 -10
- data/lib/discorb/client.rb +22 -23
- data/lib/discorb/common.rb +6 -25
- data/lib/discorb/components.rb +31 -3
- data/lib/discorb/embed.rb +2 -2
- data/lib/discorb/emoji.rb +3 -3
- data/lib/discorb/error.rb +2 -2
- data/lib/discorb/exe/init.rb +8 -8
- data/lib/discorb/exe/run.rb +1 -1
- data/lib/discorb/extend.rb +21 -0
- data/lib/discorb/extension.rb +60 -47
- data/lib/discorb/file.rb +19 -1
- data/lib/discorb/gateway.rb +8 -8
- data/lib/discorb/gateway_requests.rb +1 -1
- data/lib/discorb/guild.rb +7 -7
- data/lib/discorb/guild_template.rb +4 -4
- data/lib/discorb/http.rb +1 -1
- data/lib/discorb/integration.rb +3 -3
- data/lib/discorb/interaction.rb +36 -32
- data/lib/discorb/invite.rb +2 -2
- data/lib/discorb/log.rb +1 -1
- data/lib/discorb/member.rb +1 -1
- data/lib/discorb/message.rb +34 -10
- data/lib/discorb/modules.rb +15 -49
- data/lib/discorb/permission.rb +2 -2
- data/lib/discorb/presence.rb +8 -8
- data/lib/discorb/rate_limit.rb +1 -1
- data/lib/discorb/reaction.rb +1 -1
- data/lib/discorb/role.rb +2 -2
- data/lib/discorb/sticker.rb +3 -3
- data/lib/discorb/user.rb +2 -2
- data/lib/discorb/utils/colored_puts.rb +3 -3
- data/lib/discorb/utils.rb +1 -21
- data/lib/discorb/voice_state.rb +3 -3
- data/lib/discorb/webhook.rb +7 -8
- data/lib/discorb.rb +1 -1
- data/sig/discorb.rbs +2 -2
- data/template-replace/files/css/common.css +26 -0
- data/template-replace/files/favicon.png +0 -0
- data/template-replace/scripts/arrow.rb +7 -0
- data/template-replace/scripts/favicon.rb +9 -0
- data/template-replace/scripts/version.rb +20 -5
- metadata +5 -2
    
        data/lib/discorb/user.rb
    CHANGED
    
    | @@ -26,7 +26,7 @@ module Discorb | |
| 26 26 |  | 
| 27 27 | 
             
                include Discorb::Messageable
         | 
| 28 28 |  | 
| 29 | 
            -
                #  | 
| 29 | 
            +
                # @private
         | 
| 30 30 | 
             
                def initialize(client, data)
         | 
| 31 31 | 
             
                  @client = client
         | 
| 32 32 | 
             
                  @data = {}
         | 
| @@ -73,7 +73,7 @@ module Discorb | |
| 73 73 |  | 
| 74 74 | 
             
                alias app_owner? bot_owner?
         | 
| 75 75 |  | 
| 76 | 
            -
                #  | 
| 76 | 
            +
                # @private
         | 
| 77 77 | 
             
                def channel_id
         | 
| 78 78 | 
             
                  Async do
         | 
| 79 79 | 
             
                    next @dm_channel_id if @dm_channel_id
         | 
| @@ -1,14 +1,14 @@ | |
| 1 | 
            -
            #  | 
| 1 | 
            +
            # @private
         | 
| 2 2 | 
             
            def sputs(text)
         | 
| 3 3 | 
             
              puts "\e[92m#{text}\e[m"
         | 
| 4 4 | 
             
            end
         | 
| 5 5 |  | 
| 6 | 
            -
            #  | 
| 6 | 
            +
            # @private
         | 
| 7 7 | 
             
            def eputs(text)
         | 
| 8 8 | 
             
              puts "\e[91m#{text}\e[m"
         | 
| 9 9 | 
             
            end
         | 
| 10 10 |  | 
| 11 | 
            -
            #  | 
| 11 | 
            +
            # @private
         | 
| 12 12 | 
             
            def iputs(text)
         | 
| 13 13 | 
             
              puts "\e[90m#{text}\e[m"
         | 
| 14 14 | 
             
            end
         | 
    
        data/lib/discorb/utils.rb
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            module Discorb
         | 
| 4 | 
            -
              #  | 
| 4 | 
            +
              # @private
         | 
| 5 5 | 
             
              module Utils
         | 
| 6 6 | 
             
                def try(object, message, ...)
         | 
| 7 7 | 
             
                  if object.respond_to?(message)
         | 
| @@ -14,23 +14,3 @@ module Discorb | |
| 14 14 | 
             
                module_function :try
         | 
| 15 15 | 
             
              end
         | 
| 16 16 | 
             
            end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
            class Async::Node	
         | 
| 19 | 
            -
              def description
         | 
| 20 | 
            -
                @object_name ||= "#{self.class}:0x#{object_id.to_s(16)}#{@transient ? ' transient' : nil}"
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                if @annotation
         | 
| 23 | 
            -
                  "#{@object_name} #{@annotation}"
         | 
| 24 | 
            -
                elsif line = self.backtrace(0, 1)&.first
         | 
| 25 | 
            -
                  "#{@object_name} #{line}"
         | 
| 26 | 
            -
                else
         | 
| 27 | 
            -
                  @object_name
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
              end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
              def to_s
         | 
| 32 | 
            -
                "\#<#{self.description}>"
         | 
| 33 | 
            -
              end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
              alias inspect to_s
         | 
| 36 | 
            -
            end
         | 
    
        data/lib/discorb/voice_state.rb
    CHANGED
    
    | @@ -43,7 +43,7 @@ module Discorb | |
| 43 43 | 
             
                #   @macro client_cache
         | 
| 44 44 | 
             
                #   @return [Discorb::User] The user this voice state is for.
         | 
| 45 45 |  | 
| 46 | 
            -
                #  | 
| 46 | 
            +
                # @private
         | 
| 47 47 | 
             
                def initialize(client, data)
         | 
| 48 48 | 
             
                  @client = client
         | 
| 49 49 | 
             
                  _set_data(data)
         | 
| @@ -132,7 +132,7 @@ module Discorb | |
| 132 132 | 
             
                  2 => :guild_only,
         | 
| 133 133 | 
             
                }
         | 
| 134 134 |  | 
| 135 | 
            -
                #  | 
| 135 | 
            +
                # @private
         | 
| 136 136 | 
             
                def initialize(client, data, no_cache: false)
         | 
| 137 137 | 
             
                  @client = client
         | 
| 138 138 | 
             
                  @data = data
         | 
| @@ -238,7 +238,7 @@ module Discorb | |
| 238 238 | 
             
                attr_reader :custom
         | 
| 239 239 | 
             
                alias custom? custom
         | 
| 240 240 |  | 
| 241 | 
            -
                #  | 
| 241 | 
            +
                # @private
         | 
| 242 242 | 
             
                def initialize(data)
         | 
| 243 243 | 
             
                  @id = data[:id]
         | 
| 244 244 | 
             
                  @name = data[:name]
         | 
    
        data/lib/discorb/webhook.rb
    CHANGED
    
    | @@ -22,7 +22,7 @@ module Discorb | |
| 22 22 | 
             
                # @return [String] The URL of the webhook.
         | 
| 23 23 | 
             
                attr_reader :token
         | 
| 24 24 |  | 
| 25 | 
            -
                #  | 
| 25 | 
            +
                # @private
         | 
| 26 26 | 
             
                def initialize(client, data)
         | 
| 27 27 | 
             
                  @name = data[:name]
         | 
| 28 28 | 
             
                  @guild_id = data[:guild_id] && Snowflake.new(data[:guild_id])
         | 
| @@ -154,7 +154,6 @@ module Discorb | |
| 154 154 | 
             
                    payload[:content] = content if content != :unset
         | 
| 155 155 | 
             
                    payload[:embeds] = embed ? [embed.to_hash] : [] if embed != :unset
         | 
| 156 156 | 
             
                    payload[:embeds] = embeds.map(&:to_hash) if embeds != :unset
         | 
| 157 | 
            -
                    attachments = [attachment] if attachment != :unset
         | 
| 158 157 | 
             
                    payload[:attachments] = attachments.map(&:to_hash) if attachments != :unset
         | 
| 159 158 | 
             
                    payload[:allowed_mentions] = allowed_mentions if allowed_mentions != :unset
         | 
| 160 159 | 
             
                    files = [file] if file != :unset
         | 
| @@ -209,7 +208,7 @@ module Discorb | |
| 209 208 | 
             
                  # @!attribute [r] url
         | 
| 210 209 | 
             
                  #   @return [String] The URL of the webhook.
         | 
| 211 210 |  | 
| 212 | 
            -
                  #  | 
| 211 | 
            +
                  # @private
         | 
| 213 212 | 
             
                  def initialize(client, data)
         | 
| 214 213 | 
             
                    super
         | 
| 215 214 | 
             
                    @token = data[:token]
         | 
| @@ -231,7 +230,7 @@ module Discorb | |
| 231 230 | 
             
                  #   Represents a source channel of follower webhook.
         | 
| 232 231 | 
             
                  #   @return [Discorb::Channel, Discorb::Webhook::FollowerWebhook::Channel] The source channel of follower webhook.
         | 
| 233 232 |  | 
| 234 | 
            -
                  #  | 
| 233 | 
            +
                  # @private
         | 
| 235 234 | 
             
                  def initialize(client, data)
         | 
| 236 235 | 
             
                    super
         | 
| 237 236 | 
             
                    @source_guild = FollowerWebhook::Guild.new(data[:source_guild])
         | 
| @@ -257,7 +256,7 @@ module Discorb | |
| 257 256 | 
             
                    # @return [Discorb::Asset] The icon of the guild.
         | 
| 258 257 | 
             
                    attr_reader :icon
         | 
| 259 258 |  | 
| 260 | 
            -
                    #  | 
| 259 | 
            +
                    # @private
         | 
| 261 260 | 
             
                    def initialize(data)
         | 
| 262 261 | 
             
                      @id = Snowflake.new(data[:id])
         | 
| 263 262 | 
             
                      @name = data[:name]
         | 
| @@ -274,7 +273,7 @@ module Discorb | |
| 274 273 | 
             
                    # @return [String] The name of the channel.
         | 
| 275 274 | 
             
                    attr_reader :name
         | 
| 276 275 |  | 
| 277 | 
            -
                    #  | 
| 276 | 
            +
                    # @private
         | 
| 278 277 | 
             
                    def initialize(data)
         | 
| 279 278 | 
             
                      @id = Snowflake.new(data[:id])
         | 
| 280 279 | 
             
                      @name = data[:name]
         | 
| @@ -299,7 +298,7 @@ module Discorb | |
| 299 298 | 
             
                  # @return [Discorb::Snowflake] The ID of the guild.
         | 
| 300 299 | 
             
                  attr_reader :guild_id
         | 
| 301 300 |  | 
| 302 | 
            -
                  #  | 
| 301 | 
            +
                  # @private
         | 
| 303 302 | 
             
                  def initialize(webhook, data, client = nil)
         | 
| 304 303 | 
             
                    @client = client
         | 
| 305 304 | 
             
                    @webhook = webhook
         | 
| @@ -371,7 +370,7 @@ module Discorb | |
| 371 370 | 
             
                    # @return [String] The discriminator of the author.
         | 
| 372 371 | 
             
                    attr_reader :discriminator
         | 
| 373 372 |  | 
| 374 | 
            -
                    #  | 
| 373 | 
            +
                    # @private
         | 
| 375 374 | 
             
                    def initialize(data)
         | 
| 376 375 | 
             
                      @data = data
         | 
| 377 376 | 
             
                      @bot = data[:bot]
         | 
    
        data/lib/discorb.rb
    CHANGED
    
    
    
        data/sig/discorb.rbs
    CHANGED
    
    | @@ -13,7 +13,7 @@ module Discorb | |
| 13 13 |  | 
| 14 14 | 
             
              def macro: () -> void
         | 
| 15 15 |  | 
| 16 | 
            -
              #  | 
| 16 | 
            +
              # @private
         | 
| 17 17 | 
             
              class Logger
         | 
| 18 18 | 
             
                def initialize: (untyped _out, untyped colorize_log, untyped level) -> void
         | 
| 19 19 |  | 
| @@ -2132,7 +2132,7 @@ module Discorb | |
| 2132 2132 | 
             
                def to_s: () -> String
         | 
| 2133 2133 | 
             
              end
         | 
| 2134 2134 |  | 
| 2135 | 
            -
              #  | 
| 2135 | 
            +
              # @private
         | 
| 2136 2136 | 
             
              module Utils
         | 
| 2137 2137 | 
             
                def try: (untyped object, untyped message) -> untyped
         | 
| 2138 2138 |  | 
| @@ -527,4 +527,30 @@ dd pre.code { | |
| 527 527 | 
             
              padding: 9px 14px;
         | 
| 528 528 | 
             
              border-radius: 4px;
         | 
| 529 529 | 
             
              border: 1px solid var(--background-tertiary);
         | 
| 530 | 
            +
              overflow-x: scroll;
         | 
| 531 | 
            +
            }
         | 
| 532 | 
            +
             | 
| 533 | 
            +
            #main {
         | 
| 534 | 
            +
              max-width: 100vw;
         | 
| 535 | 
            +
            }
         | 
| 536 | 
            +
             | 
| 537 | 
            +
            #search input{
         | 
| 538 | 
            +
              appearance: none;
         | 
| 539 | 
            +
            }
         | 
| 540 | 
            +
             | 
| 541 | 
            +
            .fixed_header{
         | 
| 542 | 
            +
              padding-bottom: 0;
         | 
| 543 | 
            +
              height: 80px;
         | 
| 544 | 
            +
            }
         | 
| 545 | 
            +
             | 
| 546 | 
            +
            #full_list_header{
         | 
| 547 | 
            +
              font-size: 1.2em;
         | 
| 548 | 
            +
            }
         | 
| 549 | 
            +
             | 
| 550 | 
            +
            #search{
         | 
| 551 | 
            +
              display: inline !important;
         | 
| 552 | 
            +
            }
         | 
| 553 | 
            +
             | 
| 554 | 
            +
            p.signature, h3.signature, p.signature tt, h3.signature tt{
         | 
| 555 | 
            +
              font-family: var(--monospace-font);
         | 
| 530 556 | 
             
            }
         | 
| Binary file | 
| @@ -4,21 +4,36 @@ def build_version_sidebar(dir, version) | |
| 4 4 | 
             
              raw.gsub!(template, "")
         | 
| 5 5 | 
             
              res = +""
         | 
| 6 6 | 
             
              i = 0
         | 
| 7 | 
            -
              `git tag`.force_encoding("utf-8").split("\n").each.with_index do |tag|
         | 
| 7 | 
            +
              `git tag`.force_encoding("utf-8").split("\n").reverse.each.with_index do |tag|
         | 
| 8 8 | 
             
                i += 1
         | 
| 9 9 | 
             
                sha = `git rev-parse #{tag}`.force_encoding("utf-8").strip
         | 
| 10 | 
            -
                 | 
| 10 | 
            +
                tag_version = tag.delete_prefix("v")
         | 
| 11 11 | 
             
                cls = i % 2 == 0 ? "even" : "odd"
         | 
| 12 | 
            -
                if  | 
| 12 | 
            +
                if tag_version == version
         | 
| 13 13 | 
             
                  cls += " current"
         | 
| 14 14 | 
             
                end
         | 
| 15 | 
            -
                res += template | 
| 15 | 
            +
                res += template
         | 
| 16 | 
            +
                  .gsub("!version!", tag_version)
         | 
| 17 | 
            +
                  .gsub("!path!", "/" + tag_version)
         | 
| 18 | 
            +
                  .gsub("!class!", cls)
         | 
| 19 | 
            +
                  .gsub("!sha!", sha)
         | 
| 16 20 | 
             
              end
         | 
| 17 21 | 
             
              i += 1
         | 
| 18 22 | 
             
              cls = i % 2 == 0 ? "even" : "odd"
         | 
| 19 23 | 
             
              if version == "main"
         | 
| 20 24 | 
             
                cls += " current"
         | 
| 21 25 | 
             
              end
         | 
| 22 | 
            -
              res | 
| 26 | 
            +
              res.insert 0, template
         | 
| 27 | 
            +
                           .gsub("!version!", "main")
         | 
| 28 | 
            +
                           .gsub("!path!", "/main")
         | 
| 29 | 
            +
                           .gsub("!class!", cls)
         | 
| 30 | 
            +
                           .gsub("!sha!", "Latest on GitHub")
         | 
| 31 | 
            +
              i += 1
         | 
| 32 | 
            +
              cls = i % 2 == 0 ? "even" : "odd"
         | 
| 33 | 
            +
              res.insert 0, template
         | 
| 34 | 
            +
                           .gsub("!version!", "Latest")
         | 
| 35 | 
            +
                           .gsub("!path!", "/")
         | 
| 36 | 
            +
                           .gsub("!class!", cls)
         | 
| 37 | 
            +
                           .gsub("!sha!", "Latest on RubyGems")
         | 
| 23 38 | 
             
              File.write(dir + "/version_list.html", raw.gsub("<!--replace-->", res))
         | 
| 24 39 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: discorb
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.10.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - sevenc-nanashi
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021- | 
| 11 | 
            +
            date: 2021-10-02 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: async
         | 
| @@ -179,7 +179,10 @@ files: | |
| 179 179 | 
             
            - po/yard.pot
         | 
| 180 180 | 
             
            - sig/discorb.rbs
         | 
| 181 181 | 
             
            - template-replace/files/css/common.css
         | 
| 182 | 
            +
            - template-replace/files/favicon.png
         | 
| 182 183 | 
             
            - template-replace/resources/version_list.html
         | 
| 184 | 
            +
            - template-replace/scripts/arrow.rb
         | 
| 185 | 
            +
            - template-replace/scripts/favicon.rb
         | 
| 183 186 | 
             
            - template-replace/scripts/index.rb
         | 
| 184 187 | 
             
            - template-replace/scripts/sidebar.rb
         | 
| 185 188 | 
             
            - template-replace/scripts/version.rb
         |