discorb 0.10.2 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ea8e05d77b37b7a269b43dff64422e3d49b08d6c09a639d40dc019baaa26a8c
4
- data.tar.gz: c8ea6f45759aaf22112f6400f7d950fb09f427f98d01302a18094ad3d6a3ae08
3
+ metadata.gz: 5f6ee34f3af585d7ddac79ba4a4e27e860d6e9bb5035fba753d05ef9051a33ae
4
+ data.tar.gz: 6bee85cd879565d96930f9bceecb0dc0f7e0f0f7a2538f95890b65d48289a7a8
5
5
  SHA512:
6
- metadata.gz: b3f5e77107192aec6943087251c5b61ab1476eb421ddb0297d61178e5146466a5a59c50f4665a2b81c362d927765259142ed1bc08ed9c07e3018102becab3294
7
- data.tar.gz: b88f74d4f3e0f0025f7086e95c2b1e2b96ed19a35a258a72dd29f1814986465ac9fdd8443f920fe8b7dcd610d35871b59354ba8cc6b478bcf883797cd17d463d
6
+ metadata.gz: f9ad567614fd083bf93f84291944196f6d0ef4ff20db5052ab13fef078d0ab50e5be71fb553701c0ff9332da630e6d6d6969371528db6bd8830f2a25542e1837
7
+ data.tar.gz: 450323783abfcdbdfb9db7517bda56b26c651dd7c4df18212fb11c624ff16016df01d1d8126ac9dc2cff0cd532b07afba406e16db154f917ca85d55f89f41139
data/Changelog.md CHANGED
@@ -4,6 +4,13 @@
4
4
 
5
5
  ## v0.10
6
6
 
7
+ ### v0.10.3
8
+
9
+ - Add: Support role icons
10
+ - Fix: Fix version order
11
+ - Change: Use `exec` instead of `system` in `discorb run`
12
+ - Add: Add `Extension.loaded`
13
+
7
14
  ### v0.10.2
8
15
 
9
16
  - Change: `discorb init` is now `discorb new`
data/Rakefile CHANGED
@@ -156,7 +156,7 @@ namespace :document do
156
156
  Rake::Task["document:replace:html"].execute
157
157
  Rake::Task["document:replace:css"].execute
158
158
  Rake::Task["document:replace:eol"].execute
159
- tags = `git tag`.force_encoding("utf-8").split("\n")
159
+ tags = `git tag`.force_encoding("utf-8").split("\n").sort_by { |t| t[1..].split(".").map(&:to_i) }
160
160
  tags.each do |tag|
161
161
  sh "git checkout #{tag} -f"
162
162
  iputs "Building #{tag}"
data/docs/extension.md CHANGED
@@ -84,3 +84,33 @@ class MyExtension < Discorb::Extension
84
84
  end
85
85
  end
86
86
  ```
87
+
88
+ ## Receiving Arguments on load
89
+
90
+ You can receive arguments by adding some arguments to `#initialize`.
91
+
92
+ ```ruby
93
+ class MyExtension < Discorb::Extension
94
+ def initialize(client, arg1, arg2)
95
+ super(client)
96
+ # @client = client will also work, but it's not recommended.
97
+ @arg1 = arg1
98
+ @arg2 = arg2
99
+ end
100
+ end
101
+
102
+ client.load_extension(MyExtension, "arg1", "arg2")
103
+
104
+ ```
105
+
106
+ ## Do something on load
107
+
108
+ You can do something on load by overriding `.loaded`. Client and arguments will be passed to it.
109
+
110
+ ```ruby
111
+ class MyExtension < Discorb::Extension
112
+ def self.loaded(client)
113
+ puts "This extension is loaded to #{client}"
114
+ end
115
+ end
116
+ ```
@@ -401,6 +401,9 @@ module Discorb
401
401
  cmd.define_singleton_method(:extension) { ins.name }
402
402
  @commands << cmd
403
403
  end
404
+
405
+ cls = ins.class
406
+ cls.loaded(self, ...) if cls.respond_to? :loaded
404
407
  @bottom_commands += ins.class.bottom_commands
405
408
  @extensions[ins.class.name] = ins
406
409
  ins
@@ -4,7 +4,7 @@ module Discorb
4
4
  # @return [String] The API base URL.
5
5
  API_BASE_URL = "https://discord.com/api/v9"
6
6
  # @return [String] The version of discorb.
7
- VERSION = "0.10.2"
7
+ VERSION = "0.10.3"
8
8
  # @return [String] The user agent for the bot.
9
9
  USER_AGENT = "DiscordBot (https://discorb-lib.github.io #{VERSION}) Ruby/#{RUBY_VERSION}"
10
10
 
@@ -71,9 +71,9 @@ ENV["DISCORB_CLI_TITLE"] = options[:title]
71
71
 
72
72
  if File.exist? script
73
73
  if options[:bundler]
74
- system "bundle exec ruby #{script}"
74
+ exec "bundle exec ruby #{script}"
75
75
  else
76
- system "ruby #{script}"
76
+ exec "ruby #{script}"
77
77
  end
78
78
  else
79
79
  eputs "Could not load script: \e[31m#{script}\e[91m"
data/lib/discorb/role.rb CHANGED
@@ -26,6 +26,10 @@ module Discorb
26
26
  # @return [Boolean] Whether the role is a default role.
27
27
  attr_reader :mentionable
28
28
  alias mentionable? mentionable
29
+ # @return [Discorb::Asset, nil] The icon of the role.
30
+ attr_reader :custom_icon
31
+ # @return [Discorb::Emoji, nil] The emoji of the role.
32
+ attr_reader :emoji
29
33
 
30
34
  # @!attribute [r] mention
31
35
  # @return [String] The mention of the role.
@@ -33,6 +37,8 @@ module Discorb
33
37
  # @return [Boolean] Whether the role has a color.
34
38
  # @!attribute [r] tag
35
39
  # @return [Discorb::Role::Tag] The tag of the role.
40
+ # @!attribute [r] icon
41
+ # @return [Discorb::Asset, Discorb::Emoji] The icon of the role.
36
42
 
37
43
  include Comparable
38
44
 
@@ -44,6 +50,10 @@ module Discorb
44
50
  _set_data(data)
45
51
  end
46
52
 
53
+ def icon
54
+ @custom_icon || @emoji
55
+ end
56
+
47
57
  #
48
58
  # Compares two roles by their position.
49
59
  #
@@ -182,6 +192,8 @@ module Discorb
182
192
  @managed = data[:managed]
183
193
  @mentionable = data[:mentionable]
184
194
  @tags = data[:tags] || {}
195
+ @custom_icon = data[:icon] ? Asset.new(self, data[:icon], path: "role-icons/#{@id}") : nil
196
+ @emoji = data[:unicode_emoji] ? UnicodeEmoji.new(data[:unicode_emoji]) : nil
185
197
  @guild.roles[@id] = self unless data[:no_cache]
186
198
  @data.update(data)
187
199
  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.10.2
4
+ version: 0.10.3
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-10-03 00:00:00.000000000 Z
11
+ date: 2021-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async